|
|
|
@ -2,7 +2,9 @@ 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;
|
|
|
|
@ -18,279 +20,227 @@ import org.junit.Test;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class AccountingAggregatorPluginTest extends ContextTest {
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AccountingAggregatorPluginTest.class);
|
|
|
|
|
|
|
|
|
|
public static final String ROOT_PROD = "/d4science.research-infrastructures.eu";
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void aggregateJob() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.MONTHLY;
|
|
|
|
|
//type aggregation
|
|
|
|
|
|
|
|
|
|
private void aggregate(String recordType, AggregationType aggregationType, Calendar aggregationStartCalendar,
|
|
|
|
|
Calendar aggregationEndCalendar) throws Exception {
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, JobUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
|
|
|
|
|
|
|
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.NOVEMBER, 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
|
|
|
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.DECEMBER, 1);
|
|
|
|
|
/*
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, recordType);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER,
|
|
|
|
|
aggregationStartCalendar == null);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, false);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, false);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, false);
|
|
|
|
|
|
|
|
|
|
if (aggregationStartCalendar != null) {
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT
|
|
|
|
|
.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER,
|
|
|
|
|
aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aggregationStartCalendar != null && aggregationEndCalendar != null) {
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT
|
|
|
|
|
.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER,
|
|
|
|
|
aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (aggregationStartCalendar != null && aggregationEndCalendar != null) {
|
|
|
|
|
while (aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
|
|
|
|
plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
aggregationStartCalendar.add(aggregationType.getCalendarField(), 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT
|
|
|
|
|
.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
|
|
|
|
plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
aggregationStartCalendar.add(aggregationType.getCalendarField(), 1);
|
|
|
|
|
aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void aggregateStorageStatus() throws Exception {
|
|
|
|
|
public void aggregateJobUsageRecord() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.MONTHLY;
|
|
|
|
|
//type aggregation
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, StorageStatusRecord.class.newInstance().getRecordType());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
|
|
|
|
|
|
|
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.MAY, 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
|
|
|
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.JULY, 1);
|
|
|
|
|
/*
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
|
|
|
|
plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
aggregationStartCalendar.add(aggregationType.getCalendarField(), 1);
|
|
|
|
|
aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
String recordType = JobUsageRecord.class.newInstance().getRecordType();
|
|
|
|
|
|
|
|
|
|
boolean allAgregationTypes = true;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
} else {
|
|
|
|
|
for (AggregationType at : AggregationType.values()) {
|
|
|
|
|
aggregate(recordType, at, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void aggregateStorageUsage() throws Exception {
|
|
|
|
|
public void aggregateStorageStatusRecord() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.MONTHLY;
|
|
|
|
|
//type aggregation51170
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, StorageUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
|
|
|
|
|
|
|
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.APRIL, 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
|
|
|
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.MAY, 1);
|
|
|
|
|
/*
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
//Thread.sleep(TimeUnit.MINUTES.toMillis(1));
|
|
|
|
|
aggregationStartCalendar.add(aggregationType.getCalendarField(), 1);
|
|
|
|
|
aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
|
|
|
|
|
|
|
|
|
|
boolean allAgregationTypes = 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);
|
|
|
|
|
} else {
|
|
|
|
|
for (AggregationType at : AggregationType.values()) {
|
|
|
|
|
aggregate(recordType, at, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void aggregateStorageUsageRecord() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
String recordType = StorageUsageRecord.class.newInstance().getRecordType();
|
|
|
|
|
|
|
|
|
|
boolean allAgregationTypes = 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);
|
|
|
|
|
} else {
|
|
|
|
|
for (AggregationType at : AggregationType.values()) {
|
|
|
|
|
aggregate(recordType, at, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void aggregateService() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
//ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.MONTHLY;
|
|
|
|
|
//type aggregation
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, ServiceUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, true);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
|
|
|
|
|
|
|
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.SEPTEMBER, 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(aggregationType, aggregationStartCalendar, 1);
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.JULY, 1);
|
|
|
|
|
/*
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
//Thread.sleep(TimeUnit.MINUTES.toMillis(1));
|
|
|
|
|
aggregationStartCalendar.add(aggregationType.getCalendarField(), 1);
|
|
|
|
|
aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
|
|
|
|
|
|
|
|
|
|
boolean allAgregationTypes = true;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
} else {
|
|
|
|
|
for (AggregationType at : AggregationType.values()) {
|
|
|
|
|
aggregate(recordType, at, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void testRecovery() throws Exception {
|
|
|
|
|
public void aggregateAll() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Set<String> allRecordTypes = new HashSet<>();
|
|
|
|
|
allRecordTypes.add(ServiceUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
allRecordTypes.add(JobUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
allRecordTypes.add(StorageUsageRecord.class.newInstance().getRecordType());
|
|
|
|
|
allRecordTypes.add(StorageStatusRecord.class.newInstance().getRecordType());
|
|
|
|
|
|
|
|
|
|
for (AggregationType at : AggregationType.values()) {
|
|
|
|
|
for(String recordType : allRecordTypes) {
|
|
|
|
|
aggregate(recordType, at, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
@Test
|
|
|
|
|
public void testRecovery() throws Exception {
|
|
|
|
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
|
|
|
// ContextTest.setContextByName(ROOT_PROD);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
AggregationType aggregationType = AggregationType.DAILY;
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.RECOVERY.name());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, AggregationType.MONTHLY.name());
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 0));
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(24, 00));
|
|
|
|
|
|
|
|
|
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.MAY, 1);
|
|
|
|
|
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
|
|
|
// Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.MAY, 1);
|
|
|
|
|
// String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
// logger.trace("{} : {}",AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
// inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
|
|
|
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JUNE, 1);
|
|
|
|
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
|
|
|
|
|
// Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JUNE, 1);
|
|
|
|
|
// String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
|
|
|
|
// logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
// inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
|
|
|
|
|
|
|
|
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}",plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
aggregationStartCalendar.add(Calendar.MONTH, 1);
|
|
|
|
|
aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
|
|
|
|
|
|
|
|
|
plugin.launch(inputs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// while(aggregationStartCalendar.before(aggregationEndCalendar)) {
|
|
|
|
|
// plugin.launch(inputs); aggregationStartCalendar.add(Calendar.MONTH, 1);
|
|
|
|
|
// aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
|
|
|
|
// inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|