Search in sources :

Example 41 with Parameters

use of junitparams.Parameters in project aion by aionnetwork.

the class ConcurrencyTest method testConcurrentPutBatch.

@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentPutBatch(Properties dbDef) throws InterruptedException {
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    // create distinct threads with
    List<Runnable> threads = new ArrayList<>();
    for (int i = 0; i < CONCURRENT_THREADS; i++) {
        addThread4PutBatch(threads, db, "key-" + i);
    }
    // run threads
    assertConcurrent("Testing putBatch(...) ", threads, TIME_OUT);
    // check that all values were added
    assertThat(db.keys().size()).isEqualTo(3 * CONCURRENT_THREADS);
    // ensuring close
    db.close();
    assertThat(db.isClosed()).isTrue();
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 42 with Parameters

use of junitparams.Parameters in project aion by aionnetwork.

the class ConcurrencyTest method testConcurrentUpdate.

@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentUpdate(Properties dbDef) throws InterruptedException {
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
    // open database
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    // create distinct threads with
    List<Runnable> threads = new ArrayList<>();
    int threadSetCount = CONCURRENT_THREADS / 4;
    if (threadSetCount < 3) {
        threadSetCount = 3;
    }
    for (int i = 0; i < threadSetCount; i++) {
        String keyStr = "key-" + i + ".";
        // 1. thread that puts entry
        addThread4Put(threads, db, keyStr);
        // 2. thread that deletes entry
        addThread4Delete(threads, db, keyStr);
        // 3. thread that puts entries
        addThread4PutBatch(threads, db, keyStr);
        // 4. thread that deletes entry
        addThread4DeleteBatch(threads, db, keyStr);
    }
    // run threads and check for exceptions
    assertConcurrent("Testing concurrent updates. ", threads, TIME_OUT);
    // check that db is unlocked after updates
    assertThat(db.isLocked()).isFalse();
    // ensuring close
    db.close();
    assertThat(db.isClosed()).isTrue();
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 43 with Parameters

use of junitparams.Parameters in project aion by aionnetwork.

the class ConcurrencyTest method testConcurrentPut.

@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentPut(Properties dbDef) throws InterruptedException {
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    // create distinct threads with
    List<Runnable> threads = new ArrayList<>();
    for (int i = 0; i < CONCURRENT_THREADS; i++) {
        addThread4Put(threads, db, "key-" + i);
    }
    // run threads
    assertConcurrent("Testing put(...) ", threads, TIME_OUT);
    // check that all values were added
    assertThat(db.keys().size()).isEqualTo(CONCURRENT_THREADS);
    // ensuring close
    db.close();
    assertThat(db.isClosed()).isTrue();
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 44 with Parameters

use of junitparams.Parameters in project protoman by spotify.

the class EnumDefaultValueTest method testAllowedName.

@Parameters(method = "allowedNames")
@Test
public void testAllowedName(final String name) throws Exception {
    final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
    final ImmutableList<ValidationViolation> violations = schemaValidator.validate(DescriptorSet.empty(), candidate);
    assertThat(violations, is(empty()));
}
Also used : ValidationViolation(com.spotify.protoman.validation.ValidationViolation) DescriptorSet(com.spotify.protoman.descriptor.DescriptorSet) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 45 with Parameters

use of junitparams.Parameters in project protoman by spotify.

the class EnumNamingRuleTest method testAllowedName_existing.

@Parameters(method = "allowedNames")
@Test
public void testAllowedName_existing(final String name) throws Exception {
    final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
    final ImmutableList<ValidationViolation> violations = schemaValidator.validate(candidate, candidate);
    assertThat(violations, is(empty()));
}
Also used : ValidationViolation(com.spotify.protoman.validation.ValidationViolation) DescriptorSet(com.spotify.protoman.descriptor.DescriptorSet) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

Parameters (junitparams.Parameters)311 Test (org.junit.Test)311 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)55 DescriptorSet (com.spotify.protoman.descriptor.DescriptorSet)43 ValidationViolation (com.spotify.protoman.validation.ValidationViolation)43 SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)41 QueryDataSource (org.apache.druid.query.QueryDataSource)30 TableDataSource (org.apache.druid.query.TableDataSource)30 GlobalTableDataSource (org.apache.druid.query.GlobalTableDataSource)26 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)26 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)24 Method (java.lang.reflect.Method)19 LookupDataSource (org.apache.druid.query.LookupDataSource)19 IByteArrayKeyValueDatabase (org.aion.base.db.IByteArrayKeyValueDatabase)18 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)17 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)13 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)12 Owner (org.candlepin.model.Owner)12 Product (org.candlepin.model.Product)12 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)11