Reorganizing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@151094 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5fe99072dc
commit
4d791f6fd9
|
@ -14,6 +14,8 @@ import org.gcube.accounting.persistence.AccountingPersistence;
|
|||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
||||
import org.gcube.documentstore.persistence.PersistenceBackendFactory;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.gcube.testutility.TestUsageRecord;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -25,14 +27,15 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class AccountingTest {
|
||||
public class AccountingTest extends ScopedTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AccountingTest.class);
|
||||
|
||||
private AccountingPersistence accountingPersistence;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
public void before() throws Exception{
|
||||
PersistenceBackendFactory.forceImmediateRediscovery(ScopedTest.getCurrentContext());
|
||||
accountingPersistence = AccountingPersistenceFactory.getPersistence();
|
||||
}
|
||||
|
||||
|
@ -48,7 +51,7 @@ public class AccountingTest {
|
|||
@Test
|
||||
public void accountingServiceUsageRecordStressTest() throws InvalidValueException, NotAggregatableRecordsExceptions {
|
||||
|
||||
for(int i=0; i<2; i++){
|
||||
for(int i=0; i<1000; i++){
|
||||
ServiceUsageRecord sur = TestUsageRecord.createTestServiceUsageRecord();
|
||||
sur.setScope(TestUsageRecord.TEST_SCOPE);
|
||||
accountingPersistence.account(sur);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
*/
|
||||
package org.gcube.documentstore.persistence;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -21,8 +19,8 @@ public class PersistenceBackendFactoryTest {
|
|||
public void parsingTest() throws Exception {
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(null);
|
||||
logger.debug("{}", persistenceBackend);
|
||||
PersistenceBackendFactory.flushAll(100, TimeUnit.MILLISECONDS);
|
||||
PersistenceBackendFactory.flush(null, 100, TimeUnit.MILLISECONDS);
|
||||
persistenceBackend.flush(100, TimeUnit.MILLISECONDS);
|
||||
PersistenceBackendFactory.flushAll();
|
||||
PersistenceBackendFactory.flush(null);
|
||||
persistenceBackend.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
|
|||
|
||||
logger.debug(" START -----------------------------------------------");
|
||||
logger.debug("Flushing the buffered records");
|
||||
persistence.flush(timeout, timeUnit);
|
||||
persistence.flush();
|
||||
logger.debug(" END -----------------------------------------------");
|
||||
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
|
||||
persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
|
||||
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);
|
||||
FallbackMonitor temporalDataPersistenceBackendMonitor = new FallbackMonitor(persistenceBackend);
|
||||
|
||||
temporalDataPersistenceBackendMonitor.run();
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
|
|||
PersistenceBackendFactory.setFallbackLocation(null);
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
|
||||
//persistenceBackend.setFallback((FallbackPersistenceBackend) persistenceBackend);
|
||||
PersistenceBackendMonitor temporalDataPersistenceBackendMonitor = new PersistenceBackendMonitor(persistenceBackend);
|
||||
FallbackMonitor temporalDataPersistenceBackendMonitor = new FallbackMonitor(persistenceBackend);
|
||||
|
||||
temporalDataPersistenceBackendMonitor.run();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package org.gcube.documentstore.persistence;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
|
||||
|
@ -25,9 +24,6 @@ public class PersistenceBackendTest extends ScopedTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(PersistenceBackendTest.class);
|
||||
|
||||
public static final long timeout = 5000;
|
||||
public static final TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
|
||||
public static PersistenceBackend getPersistence() throws Exception{
|
||||
AccountingPersistenceFactory.initAccountingPackages();
|
||||
PersistenceBackendFactory.setFallbackLocation(null);
|
||||
|
@ -47,7 +43,7 @@ public class PersistenceBackendTest extends ScopedTest {
|
|||
}
|
||||
}, 1);
|
||||
|
||||
persistence.flush(timeout, timeUnit);
|
||||
persistence.flush();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,7 +57,7 @@ public class PersistenceBackendTest extends ScopedTest {
|
|||
}
|
||||
}, 1);
|
||||
|
||||
persistence.flush(timeout, timeUnit);
|
||||
persistence.flush();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -87,7 +83,7 @@ public class PersistenceBackendTest extends ScopedTest {
|
|||
persistence.account(usageRecord);
|
||||
}
|
||||
});
|
||||
persistence.flush(timeout, timeUnit);
|
||||
persistence.flush();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
*/
|
||||
package org.gcube.documentstore.persistence;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
|
@ -29,11 +27,19 @@ public class PersistenceCouchBaseTest extends ScopedTest {
|
|||
public void persistenceIsCouchBase() throws ObjectNotFound, Exception {
|
||||
PersistenceBackendFactory.setFallbackLocation(null);
|
||||
FallbackPersistenceBackend fallbackPersistenceBackend = PersistenceBackendFactory.createFallback(ScopedTest.getCurrentContext());
|
||||
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.rediscoverPersistenceBackend(fallbackPersistenceBackend, ScopedTest.getCurrentContext());
|
||||
|
||||
Assert.assertTrue(persistenceBackend instanceof PersistenceCouchBase);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistenceIsCouchBaseForcingImmediateRediscovery() throws ObjectNotFound, Exception {
|
||||
PersistenceBackendFactory.setFallbackLocation(null);
|
||||
String context = ScopedTest.getCurrentContext();
|
||||
PersistenceBackendFactory.forceImmediateRediscovery(context);
|
||||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(context);
|
||||
Assert.assertTrue(persistenceBackend instanceof PersistenceCouchBase);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testJsonNodeUsageRecordConversions() throws Exception {
|
||||
|
@ -57,21 +63,4 @@ public class PersistenceCouchBaseTest extends ScopedTest {
|
|||
Assert.assertEquals(0, r.compareTo(record));
|
||||
}
|
||||
|
||||
public void testProxyWithTestConfiguration() throws Exception{
|
||||
// Production-Preproduction Nodes
|
||||
URL url = new URL("http://pc-frosini.isti.cnr.it");
|
||||
|
||||
PersistenceBackendConfiguration persitenceConfiguration = PersistenceBackendConfiguration.getUnconfiguredInstance();
|
||||
persitenceConfiguration.addProperty(PersistenceCouchBase.URL_PROPERTY_KEY, url.toString());
|
||||
//persitenceConfiguration.addProperty(AccountingPersistenceCouchBase.USERNAME_PROPERTY_KEY, "");
|
||||
persitenceConfiguration.addProperty(PersistenceCouchBase.PASSWORD_PROPERTY_KEY, "");
|
||||
persitenceConfiguration.addProperty(PersistenceCouchBase.BUCKET_NAME_PROPERTY_KEY,"accounting");
|
||||
|
||||
PersistenceCouchBase couchBase = new PersistenceCouchBase();
|
||||
couchBase.prepareConnection(persitenceConfiguration);
|
||||
|
||||
Record record = TestUsageRecord.createTestServiceUsageRecord();
|
||||
couchBase.reallyAccount(record);
|
||||
}
|
||||
|
||||
}
|
|
@ -36,6 +36,7 @@ public class TestUsageRecord {
|
|||
public final static String TEST_SERVICE_CLASS = "TestServiceClass";
|
||||
public final static String TEST_SERVICE_NAME = "TestServiceName";
|
||||
public final static String TEST_CALLED_METHOD = "TestCalledMethod";
|
||||
public final static String TEST_CALLER_QUALIFIER = "TestCalledQualifier";
|
||||
|
||||
public final static String TEST_CALLER_HOST = "remotehost";
|
||||
public final static String TEST_HOST = "localhost";
|
||||
|
@ -84,7 +85,8 @@ public class TestUsageRecord {
|
|||
usageRecord.setServiceClass(TEST_SERVICE_CLASS);
|
||||
usageRecord.setServiceName(TEST_SERVICE_NAME);
|
||||
usageRecord.setCalledMethod(TEST_CALLED_METHOD);
|
||||
|
||||
usageRecord.setCallerQualifier(TEST_CALLER_QUALIFIER);
|
||||
|
||||
usageRecord.setDuration(generateRandomLong(MIN_DURATION, MAX_DURATION));
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
|
|
Loading…
Reference in New Issue