Fixing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@126311 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b948491c64
commit
d037d92c42
|
@ -8,7 +8,6 @@ import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
import org.gcube.accounting.analytics.Filter;
|
import org.gcube.accounting.analytics.Filter;
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
|
@ -16,8 +15,9 @@ import org.gcube.accounting.analytics.NumberedFilter;
|
||||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||||
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
|
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
|
||||||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
|
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
|
||||||
|
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.testutility.ScopedTest;
|
import org.gcube.testutility.ScopedTest;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -73,15 +73,11 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTimeSeriesEmptyFilter() throws Exception {
|
public void testTimeSeriesEmptyFilter() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2015, Calendar.OCTOBER, 9);
|
startTime.set(2016, Calendar.JANUARY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.set(2015, Calendar.OCTOBER, 16);
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
|
|
||||||
|
@ -91,27 +87,32 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
||||||
|
|
||||||
logger.trace("\n\n");
|
logger.trace("\n\n");
|
||||||
|
|
||||||
Class<AggregatedJobUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz =
|
||||||
AggregatedJobUsageRecord.class;
|
AggregatedServiceUsageRecord.class;
|
||||||
|
|
||||||
SortedMap<Calendar, Info> timeSeries =
|
SortedMap<Calendar, Info> timeSeries =
|
||||||
accountingPersistenceQueryCouchDB.getTimeSeries(clz,
|
accountingPersistenceQueryCouchDB.getTimeSeries(clz,
|
||||||
temporalConstraint, filters);
|
temporalConstraint, filters);
|
||||||
|
|
||||||
logger.debug("Time Series for {}:\n{}", filters,
|
logger.debug("Backend: Time Series for {}:\n{}", filters,
|
||||||
|
printCalendarMap(timeSeries));
|
||||||
|
|
||||||
|
|
||||||
|
AccountingPersistenceQuery apq =
|
||||||
|
AccountingPersistenceQueryFactory.getInstance();
|
||||||
|
timeSeries = apq.getTimeSeries(clz,temporalConstraint, filters, true);
|
||||||
|
|
||||||
|
logger.debug("Factory: Time Series for {}:\n{}", filters,
|
||||||
printCalendarMap(timeSeries));
|
printCalendarMap(timeSeries));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTop() throws Exception {
|
public void testTop() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2015, Calendar.OCTOBER, 9);
|
startTime.set(2016, Calendar.JANUARY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.set(2015, Calendar.OCTOBER, 16);
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
Filter filter = new Filter("consumerId", null);
|
|
||||||
filters.add(filter);
|
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint =
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
|
@ -119,55 +120,85 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
||||||
|
|
||||||
logger.trace("\n\n");
|
logger.trace("\n\n");
|
||||||
|
|
||||||
Class<AggregatedJobUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz =
|
||||||
AggregatedJobUsageRecord.class;
|
AggregatedServiceUsageRecord.class;
|
||||||
|
|
||||||
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
||||||
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
||||||
temporalConstraint, filters);
|
temporalConstraint, filters, "consumerId",
|
||||||
|
AccountingPersistenceQuery.getDefaultOrderingProperties(clz));
|
||||||
|
|
||||||
logger.debug("Top Query Results :\n{}", printMap(map));
|
logger.debug("Backend: Top Query Results :\n{}\n", printMap(map));
|
||||||
|
|
||||||
|
AccountingPersistenceQuery apq =
|
||||||
|
AccountingPersistenceQueryFactory.getInstance();
|
||||||
|
map = apq.getTopValues(clz,
|
||||||
|
temporalConstraint, filters, "consumerId",
|
||||||
|
AccountingPersistenceQuery.getDefaultOrderingProperties(clz),
|
||||||
|
true, 3);
|
||||||
|
|
||||||
|
logger.debug("Factory: Top Query Results :\n{}\n", printMap(map));
|
||||||
|
|
||||||
|
logger.debug("\n\n\n");
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
SortedSet<NumberedFilter> possibleValues =
|
SortedSet<NumberedFilter> possibleValues =
|
||||||
accountingPersistenceQueryCouchDB.getNextPossibleValues(clz,
|
accountingPersistenceQueryCouchDB.getNextPossibleValues(clz,
|
||||||
temporalConstraint, filters);
|
temporalConstraint, filters, "consumerId",
|
||||||
|
AccountingPersistenceQuery.getDefaultOrderingProperties(clz));
|
||||||
|
|
||||||
logger.debug("Possibile Values :\n{}", possibleValues);
|
logger.debug("Backend: Possibile Values :\n{}\n", possibleValues);
|
||||||
|
|
||||||
filter.setValue("UNKNOWN");
|
possibleValues = apq.getNextPossibleValues(clz,
|
||||||
|
temporalConstraint, filters, "consumerId",
|
||||||
|
AccountingPersistenceQuery.getDefaultOrderingProperties(clz));
|
||||||
|
|
||||||
|
logger.debug("Factory: Possibile Values :\n{}\n", possibleValues);
|
||||||
|
|
||||||
|
logger.debug("\n\n\n");
|
||||||
|
|
||||||
|
if(possibleValues.size()>0){
|
||||||
|
filters.add(possibleValues.first());
|
||||||
|
}
|
||||||
SortedMap<Calendar, Info> timeSeries =
|
SortedMap<Calendar, Info> timeSeries =
|
||||||
accountingPersistenceQueryCouchDB.getTimeSeries(clz,
|
accountingPersistenceQueryCouchDB.getTimeSeries(clz,
|
||||||
temporalConstraint, filters);
|
temporalConstraint, filters);
|
||||||
|
|
||||||
logger.debug("Time Series for {}:\n{}", filter,
|
logger.debug("Backend: Time Series for {}:\n{}\n", possibleValues.first(),
|
||||||
printCalendarMap(timeSeries));
|
printCalendarMap(timeSeries));
|
||||||
|
|
||||||
|
timeSeries = apq.getTimeSeries(clz, temporalConstraint, filters);
|
||||||
|
|
||||||
|
logger.debug("Factory: Time Series for {}:\n{}\n", possibleValues.first(),
|
||||||
|
printCalendarMap(timeSeries));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTop2() throws Exception {
|
public void testTop2() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2016, Calendar.FEBRUARY, 23);
|
startTime.set(2016, Calendar.JANUARY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
Calendar endTime = Calendar.getInstance();
|
||||||
endTime.set(2016, Calendar.MARCH, 23);
|
|
||||||
|
|
||||||
List<Filter> filters = new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
Filter filter = new Filter("consumerId", null);
|
Filter filter = new Filter("serviceClass", "VREManagement");
|
||||||
filters.add(filter);
|
filters.add(filter);
|
||||||
|
|
||||||
|
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint =
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
|
||||||
logger.trace("\n\n");
|
logger.trace("\n\n");
|
||||||
|
|
||||||
Class<AggregatedStorageUsageRecord> clz =
|
Class<AggregatedServiceUsageRecord> clz =
|
||||||
AggregatedStorageUsageRecord.class;
|
AggregatedServiceUsageRecord.class;
|
||||||
|
|
||||||
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
||||||
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
||||||
temporalConstraint, filters);
|
temporalConstraint, filters, "serviceName",
|
||||||
|
AccountingPersistenceQuery.getDefaultOrderingProperties(clz));
|
||||||
|
|
||||||
logger.debug("Top Query Results :\n{}", printMap(map));
|
logger.debug("Top Query Results :\n{}", printMap(map));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.testutility.ScopedTest;
|
import org.gcube.testutility.ScopedTest;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -19,6 +21,11 @@ public class CouchDBQueryPluginTest extends ScopedTest {
|
||||||
*/
|
*/
|
||||||
private static Logger logger = LoggerFactory.getLogger(CouchDBQueryPluginTest.class);
|
private static Logger logger = LoggerFactory.getLogger(CouchDBQueryPluginTest.class);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() throws Exception{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLaunch() throws Exception {
|
public void testLaunch() throws Exception {
|
||||||
logger.debug("Starting to test launch()");
|
logger.debug("Starting to test launch()");
|
||||||
|
|
Loading…
Reference in New Issue