Reorganizing tests

This commit is contained in:
Luca Frosini 2024-02-15 10:30:21 +01:00
parent 3194c529d5
commit 13282e6236
3 changed files with 46 additions and 164 deletions

View File

@ -162,7 +162,7 @@ public class ContextTest {
@BeforeClass
public static void beforeClass() throws Exception {
setContextByName(DEFAULT_TEST_SCOPE);
setContextByName(ROOT_PROD);
}
@AfterClass

View File

@ -77,170 +77,56 @@ public class AccountingAggregatorPluginTest extends ContextTest {
@JsonIgnore
@Test
public void aggregateJobUsageRecord() throws Exception {
ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
String recordType = JobUsageRecord.class.newInstance().getRecordType();
boolean allAgregationTypes = true;
boolean forceRerun = false;
boolean forceEarlyAggregation = false;
if (!allAgregationTypes) {
AggregationType aggregationType = AggregationType.DAILY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
// Calendar aggregationEndCalendar =
// Utility.getEndCalendarFromStartCalendar(aggregationType,
// aggregationStartCalendar, 1);
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRerun, forceEarlyAggregation);
} else {
for (AggregationType at : AggregationType.values()) {
aggregate(recordType, at, null, null, forceRerun, forceEarlyAggregation);
}
}
}
@JsonIgnore
@Test
public void aggregateStorageStatusRecord() throws Exception {
ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
boolean allAgregationTypes = false;
boolean forceRerun = false;
boolean forceEarlyAggregation = false;
if (!allAgregationTypes) {
AggregationType aggregationType = AggregationType.DAILY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
// Calendar aggregationEndCalendar =
// Utility.getEndCalendarFromStartCalendar(aggregationType,
// aggregationStartCalendar, 1);
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRerun, forceEarlyAggregation);
} else {
for (AggregationType at : AggregationType.values()) {
aggregate(recordType, at, null, null, forceRerun, forceEarlyAggregation);
}
}
}
@JsonIgnore
@Test
public void aggregateStorageUsageRecord() throws Exception {
ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
boolean allAgregationTypes = false;
boolean forceRerun = false;
boolean forceEarlyAggregation = false;
if (!allAgregationTypes) {
AggregationType aggregationType = AggregationType.DAILY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
// Calendar aggregationEndCalendar =
// Utility.getEndCalendarFromStartCalendar(aggregationType,
// aggregationStartCalendar, 1);
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRerun, forceEarlyAggregation);
} else {
for (AggregationType at : AggregationType.values()) {
aggregate(recordType, at, null, null, forceRerun, forceEarlyAggregation);
}
}
}
// @JsonIgnore
@Test
public void aggregateService() throws Exception {
// ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
public void aggregateAllServiceUsageRecord() throws Exception {
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
boolean allAgregationTypes = false;
boolean forceRerun = true;
boolean forceEarlyAggregation = false;
if (!allAgregationTypes) {
AggregationType aggregationType = AggregationType.YEARLY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2019, Calendar.JANUARY, 1);
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
// Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2015, Calendar.JANUARY, 1);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRerun, forceEarlyAggregation);
} else {
for (AggregationType at : AggregationType.values()) {
aggregate(recordType, at, null, null, forceRerun, forceEarlyAggregation);
}
}
aggregateEverything(recordType);
}
@Test
public void aggregateAprilService() throws Exception {
// ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
boolean allAgregationTypes = false;
boolean forceRerun = true;
boolean forceEarlyAggregation = false;
if (!allAgregationTypes) {
AggregationType aggregationType = AggregationType.MONTHLY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2023, Calendar.APRIL, 1);
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
// Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2015, Calendar.JANUARY, 1);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRerun, forceEarlyAggregation);
} else {
for (AggregationType at : AggregationType.values()) {
aggregate(recordType, at, null, null, forceRerun, forceEarlyAggregation);
}
}
}
// @JsonIgnore
@JsonIgnore
@Test
public void aggregateAllStorageUsageRecord() throws Exception {
// ContextTest.setContextByName(GCUBE);
// ContextTest.setContextByName(ROOT_PROD);
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
aggregateAll(recordType);
aggregateEverything(recordType);
}
public void aggregateAll(String recordType) throws Exception {
@JsonIgnore
@Test
public void aggregateAllJobUsageRecord() throws Exception {
String recordType = JobUsageRecord.class.newInstance().getRecordType();
aggregateEverything(recordType);
}
@Test
public void aggregateAllStorageStatusRecord() throws Exception {
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
aggregateOneShot(recordType);
// aggregateEverything(recordType);
}
public void aggregateOneShot(String recordType) throws Exception {
boolean forceRestart = true;
boolean forceEarlyAggregation = false;
AggregationType aggregationType = AggregationType.YEARLY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JANUARY, 1);
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation);
}
public void aggregateEverything(String recordType) throws Exception {
boolean forceRestart = true;
boolean forceEarlyAggregation = false;
AggregationType aggregationType = AggregationType.YEARLY;
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2020, Calendar.JANUARY, 1);
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2015, Calendar.JANUARY, 1);
Calendar end = Utility.getAggregationStartCalendar(2021, Calendar.JANUARY, 1);
// while (aggregationStartCalendar.before(end)) {
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
// aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation);
// aggregationStartCalendar = Calendar.getInstance();
// aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
//
// }
while (aggregationStartCalendar.before(end)) {
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation);
aggregationStartCalendar = Calendar.getInstance();
aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
}
aggregationType = AggregationType.MONTHLY;
aggregationStartCalendar = Calendar.getInstance();
@ -251,21 +137,17 @@ public class AccountingAggregatorPluginTest extends ContextTest {
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, forceEarlyAggregation);
aggregationStartCalendar = Calendar.getInstance();
aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
}
aggregationType = AggregationType.DAILY;
aggregationStartCalendar = Calendar.getInstance();
aggregationStartCalendar.setTimeInMillis(end.getTimeInMillis());
aggregationStartCalendar = Utility.getAggregationStartCalendar(2024, Calendar.FEBRUARY, 6);
end = Utility.getAggregationStartCalendar(2024, Calendar.FEBRUARY, 9);
// while (aggregationStartCalendar.before(end)) {
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
// aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, true);
// aggregationStartCalendar = Calendar.getInstance();
// aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
//
// }
aggregationStartCalendar = end;
end = Utility.getAggregationStartCalendar(2024, Calendar.FEBRUARY, 14);
while (aggregationStartCalendar.before(end)) {
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar, forceRestart, true);
aggregationStartCalendar = Calendar.getInstance();
aggregationStartCalendar.setTimeInMillis(aggregationEndCalendar.getTimeInMillis());
}
}

View File

@ -10,7 +10,7 @@
<logger name="org.gcube" level="ERROR" />
<logger name="org.gcube.accounting.aggregator" level="TRACE" />
<logger name="org.gcube.accounting.aggregator" level="INFO" />
<root level="WARN">
<appender-ref ref="STDOUT" />