Fixing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@126083 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
76881ba240
commit
b948491c64
|
@ -16,7 +16,8 @@ import org.gcube.accounting.analytics.NumberedFilter;
|
|||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
|
||||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.junit.Before;
|
||||
|
@ -37,14 +38,15 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
|||
@Before
|
||||
public void before() throws Exception{
|
||||
super.before();
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||
AccountingPersistenceBackendQueryConfiguration configuration = new
|
||||
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class);
|
||||
|
||||
/*
|
||||
configuration.addProperty(AccountingPersistenceQueryCouchDB.DB_NAME, "my_couchapp_test");
|
||||
String url = configuration.getProperty(AccountingPersistenceQueryCouchDB.URL_PROPERTY_KEY);
|
||||
url = url.replace("accounting-d-d4s.d4science.org", "couchdb01-d-d4s.d4science.org:5984");
|
||||
configuration.addProperty(AccountingPersistenceQueryCouchDB.URL_PROPERTY_KEY, url);
|
||||
*/
|
||||
accountingPersistenceQueryCouchDB = new AccountingPersistenceQueryCouchDB();
|
||||
accountingPersistenceQueryCouchDB.prepareConnection(configuration);
|
||||
}
|
||||
|
@ -71,6 +73,35 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
|||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testTimeSeriesEmptyFilter() throws Exception {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
startTime.set(2015, Calendar.OCTOBER, 9);
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.set(2015, Calendar.OCTOBER, 16);
|
||||
|
||||
List<Filter> filters = new ArrayList<Filter>();
|
||||
|
||||
TemporalConstraint temporalConstraint =
|
||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||
|
||||
logger.trace("\n\n");
|
||||
|
||||
Class<AggregatedJobUsageRecord> clz =
|
||||
AggregatedJobUsageRecord.class;
|
||||
|
||||
SortedMap<Calendar, Info> timeSeries =
|
||||
accountingPersistenceQueryCouchDB.getTimeSeries(clz,
|
||||
temporalConstraint, filters);
|
||||
|
||||
logger.debug("Time Series for {}:\n{}", filters,
|
||||
printCalendarMap(timeSeries));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTop() throws Exception {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
|
@ -88,8 +119,8 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
|||
|
||||
logger.trace("\n\n");
|
||||
|
||||
Class<AggregatedServiceUsageRecord> clz =
|
||||
AggregatedServiceUsageRecord.class;
|
||||
Class<AggregatedJobUsageRecord> clz =
|
||||
AggregatedJobUsageRecord.class;
|
||||
|
||||
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
||||
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
||||
|
@ -114,5 +145,31 @@ public class AccountingPersistenceQueryCouchDBTest extends ScopedTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTop2() throws Exception {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
startTime.set(2016, Calendar.FEBRUARY, 23);
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.set(2016, Calendar.MARCH, 23);
|
||||
|
||||
List<Filter> filters = new ArrayList<Filter>();
|
||||
Filter filter = new Filter("consumerId", null);
|
||||
filters.add(filter);
|
||||
|
||||
TemporalConstraint temporalConstraint =
|
||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||
|
||||
logger.trace("\n\n");
|
||||
|
||||
Class<AggregatedStorageUsageRecord> clz =
|
||||
AggregatedStorageUsageRecord.class;
|
||||
|
||||
Map<NumberedFilter, SortedMap<Calendar, Info>> map =
|
||||
accountingPersistenceQueryCouchDB.getTopValues(clz,
|
||||
temporalConstraint, filters);
|
||||
|
||||
logger.debug("Top Query Results :\n{}", printMap(map));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ public class CouchDBQueryPluginTest extends ScopedTest {
|
|||
|
||||
@Test
|
||||
public void testLaunch() throws Exception {
|
||||
logger.debug("Starting to test launch");
|
||||
logger.debug("Starting to test launch()");
|
||||
AccountingPersistenceFactory.initAccountingPackages();
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
inputs.put(CouchDBQueryPlugin.DELAY_MILLIS, 1000*10); // Delay 10 sec
|
||||
inputs.put(CouchDBQueryPlugin.DELAY_MILLIS, 1000*5); // Delay 10 sec
|
||||
inputs.put(CouchDBQueryPlugin.MAX_RETRY_NUMBER, 0); // No Retry
|
||||
CouchDBQueryPlugin couchDBQueryPlugin = new CouchDBQueryPlugin(null);
|
||||
couchDBQueryPlugin.launch(inputs);
|
||||
logger.debug("-------------- launch test finished");
|
||||
logger.debug("-------------- launch() test finished");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ScopedTest {
|
|||
@Before
|
||||
public void before() throws Exception{
|
||||
//SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
ScopeProvider.instance.set("/gcube/devNext");
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
Loading…
Reference in New Issue