Fixed tests
This commit is contained in:
parent
3a90441a22
commit
34c9207468
|
@ -2,7 +2,9 @@ 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;
|
||||||
|
@ -18,233 +20,183 @@ import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class AccountingAggregatorPluginTest extends ContextTest {
|
public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(AccountingAggregatorPluginTest.class);
|
private static Logger logger = LoggerFactory.getLogger(AccountingAggregatorPluginTest.class);
|
||||||
|
|
||||||
public static final String ROOT_PROD = "/d4science.research-infrastructures.eu";
|
public static final String ROOT_PROD = "/d4science.research-infrastructures.eu";
|
||||||
|
|
||||||
@JsonIgnore
|
private void aggregate(String recordType, AggregationType aggregationType, Calendar aggregationStartCalendar,
|
||||||
@Test
|
Calendar aggregationEndCalendar) throws Exception {
|
||||||
public void aggregateJob() throws Exception {
|
|
||||||
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
|
||||||
// ContextTest.setContextByName(ROOT_PROD);
|
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
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.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
||||||
|
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, recordType);
|
||||||
|
|
||||||
|
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER,
|
||||||
|
aggregationStartCalendar == null);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, false);
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, JobUsageRecord.class.newInstance().getRecordType());
|
if (aggregationStartCalendar != null && aggregationEndCalendar != null) {
|
||||||
|
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT
|
||||||
inputs.put(AccountingAggregatorPlugin.RESTART_FROM_LAST_AGGREGATION_DATE_INPUT_PARAMETER, false);
|
.format(aggregationEndCalendar.getTime());
|
||||||
|
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER,
|
||||||
inputs.put(AccountingAggregatorPlugin.FORCE_EARLY_AGGREGATION, true);
|
aggregationEndDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.FORCE_RERUN, true);
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
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);
|
|
||||||
*/
|
|
||||||
|
|
||||||
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
||||||
logger.debug("Going to launch {} with inputs {}", plugin.getName(), inputs);
|
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);
|
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
|
@JsonIgnore
|
||||||
@Test
|
@Test
|
||||||
public void aggregateStorageStatus() throws Exception {
|
public void aggregateJobUsageRecord() throws Exception {
|
||||||
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
||||||
// ContextTest.setContextByName(ROOT_PROD);
|
// ContextTest.setContextByName(ROOT_PROD);
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
String recordType = JobUsageRecord.class.newInstance().getRecordType();
|
||||||
|
|
||||||
|
boolean allAgregationTypes = true;
|
||||||
|
|
||||||
AggregationType aggregationType = AggregationType.MONTHLY;
|
if (!allAgregationTypes) {
|
||||||
//type aggregation
|
AggregationType aggregationType = AggregationType.DAILY;
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
|
||||||
|
// Calendar aggregationEndCalendar =
|
||||||
|
// Utility.getEndCalendarFromStartCalendar(aggregationType,
|
||||||
|
// aggregationStartCalendar, 1);
|
||||||
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar);
|
||||||
|
} else {
|
||||||
|
for (AggregationType at : AggregationType.values()) {
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
aggregate(recordType, at, null, null);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Test
|
@Test
|
||||||
public void aggregateStorageUsage() throws Exception {
|
public void aggregateStorageStatusRecord() throws Exception {
|
||||||
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
||||||
// ContextTest.setContextByName(ROOT_PROD);
|
// ContextTest.setContextByName(ROOT_PROD);
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
String recordType = StorageStatusRecord.class.newInstance().getRecordType();
|
||||||
|
|
||||||
|
boolean allAgregationTypes = false;
|
||||||
|
|
||||||
AggregationType aggregationType = AggregationType.MONTHLY;
|
if (!allAgregationTypes) {
|
||||||
//type aggregation51170
|
AggregationType aggregationType = AggregationType.DAILY;
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
|
||||||
|
// Calendar aggregationEndCalendar =
|
||||||
|
// Utility.getEndCalendarFromStartCalendar(aggregationType,
|
||||||
|
// aggregationStartCalendar, 1);
|
||||||
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar);
|
||||||
|
} else {
|
||||||
|
for (AggregationType at : AggregationType.values()) {
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
aggregate(recordType, at, null, null);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
@JsonIgnore
|
||||||
@Test
|
@Test
|
||||||
public void aggregateService() throws Exception {
|
public void aggregateService() throws Exception {
|
||||||
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
||||||
//ContextTest.setContextByName(ROOT_PROD);
|
// ContextTest.setContextByName(ROOT_PROD);
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
String recordType = ServiceUsageRecord.class.newInstance().getRecordType();
|
||||||
|
|
||||||
|
boolean allAgregationTypes = true;
|
||||||
|
|
||||||
AggregationType aggregationType = AggregationType.MONTHLY;
|
if (!allAgregationTypes) {
|
||||||
//type aggregation
|
AggregationType aggregationType = AggregationType.DAILY;
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.name());
|
Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 10);
|
||||||
|
// Calendar aggregationEndCalendar =
|
||||||
|
// Utility.getEndCalendarFromStartCalendar(aggregationType,
|
||||||
|
// aggregationStartCalendar, 1);
|
||||||
|
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2021, Calendar.NOVEMBER, 11);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.AGGREGATE.name());
|
aggregate(recordType, aggregationType, aggregationStartCalendar, aggregationEndCalendar);
|
||||||
|
} else {
|
||||||
|
for (AggregationType at : AggregationType.values()) {
|
||||||
|
aggregate(recordType, at, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Test
|
||||||
|
public void aggregateAll() throws Exception {
|
||||||
|
ContextTest.setContextByName(ROOT_DEV_SCOPE);
|
||||||
|
// ContextTest.setContextByName(ROOT_PROD);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_START_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(0, 10));
|
Set<String> allRecordTypes = new HashSet<>();
|
||||||
inputs.put(AccountingAggregatorPlugin.PERSIST_END_TIME_INPUT_PARAMETER, Utility.getPersistTimeParameter(23, 59));
|
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()) {
|
||||||
inputs.put(AccountingAggregatorPlugin.RECORD_TYPE_INPUT_PARAMETER, ServiceUsageRecord.class.newInstance().getRecordType());
|
for(String recordType : allRecordTypes) {
|
||||||
|
aggregate(recordType, at, null, null);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -257,40 +209,38 @@ public class AccountingAggregatorPluginTest extends ContextTest {
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
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.ELABORATION_TYPE_INPUT_PARAMETER, ElaborationType.RECOVERY.name());
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, AggregationType.MONTHLY.name());
|
inputs.put(AccountingAggregatorPlugin.AGGREGATION_TYPE_INPUT_PARAMETER, aggregationType.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);
|
// Calendar aggregationStartCalendar = Utility.getAggregationStartCalendar(2017, Calendar.MAY, 1);
|
||||||
String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
// String aggregationStartDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationStartCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
// logger.trace("{} : {}",AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
// inputs.put(AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationStartDate);
|
||||||
|
|
||||||
|
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, false);
|
||||||
|
|
||||||
inputs.put(AccountingAggregatorPlugin.FORCE_RESTART, true);
|
|
||||||
|
|
||||||
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
// Calendar aggregationEndCalendar = Utility.getEndCalendarFromStartCalendar(AggregationType.MONTHLY, aggregationStartCalendar, 1);
|
||||||
Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JUNE, 1);
|
// Calendar aggregationEndCalendar = Utility.getAggregationStartCalendar(2017, Calendar.JUNE, 1);
|
||||||
String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
// String aggregationEndDate = AccountingAggregatorPlugin.AGGREGATION_START_DATE_DATE_FORMAT.format(aggregationEndCalendar.getTime());
|
||||||
logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
// logger.trace("{} : {}", AccountingAggregatorPlugin.AGGREGATION_START_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
// inputs.put(AccountingAggregatorPlugin.AGGREGATION_END_DATE_INPUT_PARAMETER, aggregationEndDate);
|
||||||
|
|
||||||
|
|
||||||
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
AccountingAggregatorPlugin plugin = new AccountingAggregatorPlugin();
|
||||||
logger.debug("Going to launch {} with inputs {}",plugin.getName(), inputs);
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
plugin.launch(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);
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.accounting.aggregator.plugin;
|
package org.gcube.accounting.aggregator.plugin;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -244,7 +243,7 @@ public class MyTest {
|
||||||
aggregationStartTime.getTime(), aggregationEndTime);
|
aggregationStartTime.getTime(), aggregationEndTime);
|
||||||
AggregationStatus aggregationStatus = new AggregationStatus(aggregationInfo);
|
AggregationStatus aggregationStatus = new AggregationStatus(aggregationInfo);
|
||||||
|
|
||||||
Elaborator elaborator = new Elaborator(aggregationStatus, Utility.getPersistTimeDate("8:00"), Utility.getPersistTimeDate("18:00"));
|
Elaborator elaborator = new Elaborator(aggregationStatus);
|
||||||
|
|
||||||
boolean allowed = elaborator.isAggregationAllowed();
|
boolean allowed = elaborator.isAggregationAllowed();
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
|
@ -269,27 +268,6 @@ public class MyTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStartAndEndTime() throws ParseException{
|
|
||||||
String pattern = new String("yyyy/MM/dd HH:mm Z");
|
|
||||||
|
|
||||||
Calendar now = Utility.getUTCCalendarInstance();
|
|
||||||
logger.info("It's {}", Utility.getUTCDateFormat(pattern).format(now.getTime()));
|
|
||||||
|
|
||||||
String startTimeString = Utility.getPersistTimeParameter(0, 10);
|
|
||||||
Date startTime = Utility.getPersistTimeDate(startTimeString);
|
|
||||||
logger.info("Start Time {}", Utility.getUTCDateFormat(pattern).format(startTime));
|
|
||||||
|
|
||||||
String endTimeString = Utility.getPersistTimeParameter(23, 59);
|
|
||||||
Date endTime = Utility.getPersistTimeDate(endTimeString);
|
|
||||||
logger.info("End Time {}", Utility.getUTCDateFormat(pattern).format(endTime));
|
|
||||||
|
|
||||||
logger.info("{}", now.getTime().after(startTime));
|
|
||||||
logger.info("{}", now.getTime().before(endTime));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String ROOT_PROD = "/d4science.research-infrastructures.eu";
|
public static final String ROOT_PROD = "/d4science.research-infrastructures.eu";
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
|
|
Loading…
Reference in New Issue