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.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.accounting.aggregator.ContextTest;
|
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
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void aggregateAllServiceUsageRecord() throws Exception {
|
public void aggregateAllServiceUsageRecord() throws Exception {
|
||||||
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
|
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
|
||||||
// aggregateOneShot(recordType);
|
// aggregateOneShot(recordType);
|
||||||
// aggregateEverything(recordType);
|
// aggregateEverything(recordType);
|
||||||
|
// restart(recordType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
@ -114,7 +89,8 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
public void aggregateAllStorageStatusRecord() throws Exception {
|
public void aggregateAllStorageStatusRecord() throws Exception {
|
||||||
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
|
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
|
||||||
// aggregateOneShot(recordType);
|
// aggregateOneShot(recordType);
|
||||||
// aggregateEverything(recordType);
|
// aggregateEverything(recordType);
|
||||||
|
// restart(recordType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
@ -122,7 +98,8 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
public void aggregateAllJobUsageRecord() throws Exception {
|
public void aggregateAllJobUsageRecord() throws Exception {
|
||||||
String recordType = JobUsageRecord.class.newInstance().getRecordType();
|
String recordType = JobUsageRecord.class.newInstance().getRecordType();
|
||||||
// aggregateOneShot(recordType);
|
// aggregateOneShot(recordType);
|
||||||
// aggregateEverything(recordType);
|
// aggregateEverything(recordType);
|
||||||
|
// restart(recordType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
@ -131,9 +108,26 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
|
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
|
||||||
// aggregateOneShot(recordType);
|
// aggregateOneShot(recordType);
|
||||||
// aggregateEverything(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 {
|
public void aggregateOneShot(String recordType) throws Exception {
|
||||||
boolean forceRestart = true;
|
boolean forceRestart = true;
|
||||||
boolean forceEarlyAggregation = true;
|
boolean forceEarlyAggregation = true;
|
||||||
|
@ -144,7 +138,6 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void aggregateEverything(String recordType) throws Exception {
|
public void aggregateEverything(String recordType) throws Exception {
|
||||||
|
|
||||||
boolean forceRestart = true;
|
boolean forceRestart = true;
|
||||||
boolean forceEarlyAggregation = false;
|
boolean forceEarlyAggregation = false;
|
||||||
|
|
||||||
|
@ -161,7 +154,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
aggregationType = AggregationType.MONTHLY;
|
aggregationType = AggregationType.MONTHLY;
|
||||||
aggregationStartCalendar = Calendar.getInstance();
|
aggregationStartCalendar = Calendar.getInstance();
|
||||||
aggregationStartCalendar.setTimeInMillis(end.getTimeInMillis());
|
aggregationStartCalendar.setTimeInMillis(end.getTimeInMillis());
|
||||||
end = Utility.getAggregationStartCalendar(2023, Calendar.NOVEMBER, 1);
|
end = Utility.getAggregationStartCalendar(2023, Calendar.DECEMBER, 1);
|
||||||
while (aggregationStartCalendar.before(end)) {
|
while (aggregationStartCalendar.before(end)) {
|
||||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation, false);
|
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation, false);
|
||||||
|
@ -171,7 +164,9 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
|
|
||||||
aggregationType = AggregationType.DAILY;
|
aggregationType = AggregationType.DAILY;
|
||||||
aggregationStartCalendar = end;
|
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)) {
|
while (aggregationStartCalendar.before(end)) {
|
||||||
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
||||||
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, true, false);
|
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, true, false);
|
||||||
|
@ -181,6 +176,7 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testRecovery() throws Exception {
|
public void testRecovery() throws Exception {
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
|
|
Loading…
Reference in New Issue