Fixed Test
This commit is contained in:
parent
daaf484e17
commit
02a67aa9b8
|
@ -2,9 +2,7 @@ package org.gcube.accounting.aggregator.plugin;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.aggregator.ContextTest;
|
||||
|
@ -77,36 +75,13 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void aggregateRecordDaily() throws Exception {
|
||||
Set<String> types = new HashSet<>();
|
||||
types.add(ServiceUsageRecord.class.newInstance().getRecordType());
|
||||
types.add(StorageUsageRecord.class.newInstance().getRecordType());
|
||||
types.add(JobUsageRecord.class.newInstance().getRecordType());
|
||||
|
||||
boolean forceRestart = true;
|
||||
boolean forceEarlyAggregation = true;
|
||||
|
||||
for(String recordType : types) {
|
||||
AggregationType aggregationType = AggregationType.DAILY;
|
||||
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2024, Calendar.MARCH, 1);
|
||||
Calendar end = Utility.getAggregationStartCalendar(2024, Calendar.MARCH, 2);
|
||||
while (aggregationStartCalendar.before(end)) {
|
||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation, false);
|
||||
aggregationStartCalendar = Calendar.getInstance();
|
||||
aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void aggregateAllServiceUsageRecord() throws Exception {
|
||||
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
|
||||
// aggregateOneShot(recordType);
|
||||
// aggregateEverything(recordType);
|
||||
// restart(recordType);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
@ -115,6 +90,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
|
||||
// aggregateOneShot(recordType);
|
||||
// aggregateEverything(recordType);
|
||||
// restart(recordType);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
@ -123,6 +99,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
String recordType = JobUsageRecord.class.newInstance().getRecordType();
|
||||
// aggregateOneShot(recordType);
|
||||
// aggregateEverything(recordType);
|
||||
// restart(recordType);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
@ -131,8 +108,25 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
|
||||
// aggregateOneShot(recordType);
|
||||
// aggregateEverything(recordType);
|
||||
// restart(recordType);
|
||||
}
|
||||
|
||||
public void restart(String recordType) throws Exception {
|
||||
boolean forceRestart = true;
|
||||
boolean forceEarlyAggregation = true;
|
||||
|
||||
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2024, Calendar.MARCH, 4);
|
||||
AggregationType aggregationType = AggregationType.DAILY;
|
||||
Calendar now = Calendar.getInstance();
|
||||
Calendar end = Utility.getAggregationStartCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)+1);
|
||||
// end = Utility.getAggregationStartCalendar(2024, Calendar.MARCH, 1);
|
||||
while (aggregationStartCalendar.before(end)) {
|
||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation, false);
|
||||
aggregationStartCalendar = Calendar.getInstance();
|
||||
aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public void aggregateOneShot(String recordType) throws Exception {
|
||||
boolean forceRestart = true;
|
||||
|
@ -144,7 +138,6 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
}
|
||||
|
||||
public void aggregateEverything(String recordType) throws Exception {
|
||||
|
||||
boolean forceRestart = true;
|
||||
boolean forceEarlyAggregation = false;
|
||||
|
||||
|
@ -161,7 +154,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
aggregationType = AggregationType.MONTHLY;
|
||||
aggregationStartCalendar = Calendar.getInstance();
|
||||
aggregationStartCalendar.setTimeInMillis(end.getTimeInMillis());
|
||||
end = Utility.getAggregationStartCalendar(2023, Calendar.NOVEMBER, 1);
|
||||
end = Utility.getAggregationStartCalendar(2023, Calendar.DECEMBER, 1);
|
||||
while (aggregationStartCalendar.before(end)) {
|
||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation, false);
|
||||
|
@ -171,7 +164,9 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
|
||||
aggregationType = AggregationType.DAILY;
|
||||
aggregationStartCalendar = end;
|
||||
end = Utility.getAggregationStartCalendar(2024, Calendar.FEBRUARY, 29);
|
||||
Calendar now = Calendar.getInstance();
|
||||
end = Utility.getAggregationStartCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
|
||||
// end = Utility.getAggregationStartCalendar(2024, Calendar.MARCH, 1);
|
||||
while (aggregationStartCalendar.before(end)) {
|
||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, true, false);
|
||||
|
@ -181,6 +176,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
|||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testRecovery() throws Exception {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
|
|
Loading…
Reference in New Issue