Search in sources :

Example 16 with Category

use of org.junit.experimental.categories.Category in project titan by thinkaurelius.

the class TitanGraphTest method testEdgeTTLWithIndex.

@Category({ BrittleTests.class })
@Test
public void testEdgeTTLWithIndex() throws Exception {
    if (!features.hasCellTTL()) {
        return;
    }
    // artificially low TTL for test
    int ttl = 1;
    final PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make();
    EdgeLabel wavedAt = mgmt.makeEdgeLabel("wavedAt").signature(time).make();
    mgmt.buildEdgeIndex(wavedAt, "timeindex", Direction.BOTH, decr, time);
    mgmt.buildIndex("edge-time", Edge.class).addKey(time).buildCompositeIndex();
    mgmt.setTTL(wavedAt, Duration.ofSeconds(ttl));
    assertEquals(Duration.ZERO, mgmt.getTTL(time));
    assertEquals(Duration.ofSeconds(ttl), mgmt.getTTL(wavedAt));
    mgmt.commit();
    TitanVertex v1 = graph.addVertex(), v2 = graph.addVertex();
    v1.addEdge("wavedAt", v2, "time", 42);
    assertTrue(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
    assertNotEmpty(v1.query().direction(Direction.OUT).edges());
    assertNotEmpty(graph.query().has("time", 42).edges());
    graph.tx().commit();
    long commitTime = System.currentTimeMillis();
    assertTrue(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
    assertNotEmpty(v1.query().direction(Direction.OUT).edges());
    assertNotEmpty(graph.query().has("time", 42).edges());
    Thread.sleep(commitTime + (ttl * 1000L + 100) - System.currentTimeMillis());
    graph.tx().rollback();
    assertFalse(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
    assertEmpty(v1.query().direction(Direction.OUT).edges());
    assertEmpty(graph.query().has("time", 42).edges());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) EdgeLabel(com.thinkaurelius.titan.core.EdgeLabel) PropertyKey(com.thinkaurelius.titan.core.PropertyKey) Category(org.junit.experimental.categories.Category) RelationCategory(com.thinkaurelius.titan.graphdb.internal.RelationCategory) ElementCategory(com.thinkaurelius.titan.graphdb.internal.ElementCategory) Test(org.junit.Test)

Example 17 with Category

use of org.junit.experimental.categories.Category in project titan by thinkaurelius.

the class TitanGraphTest method testEdgeTTLLimitedByVertexTTL.

@Category({ BrittleTests.class })
@Test
public void testEdgeTTLLimitedByVertexTTL() throws Exception {
    if (!features.hasCellTTL()) {
        return;
    }
    Boolean dbCache = config.get("cache.db-cache", Boolean.class);
    if (null == dbCache) {
        dbCache = false;
    }
    EdgeLabel likes = mgmt.makeEdgeLabel("likes").make();
    // long edge TTL will be overridden by short vertex TTL
    mgmt.setTTL(likes, Duration.ofSeconds(42));
    EdgeLabel dislikes = mgmt.makeEdgeLabel("dislikes").make();
    mgmt.setTTL(dislikes, Duration.ofSeconds(1));
    EdgeLabel indifferentTo = mgmt.makeEdgeLabel("indifferentTo").make();
    VertexLabel label1 = mgmt.makeVertexLabel("person").setStatic().make();
    mgmt.setTTL(label1, Duration.ofSeconds(2));
    assertEquals(Duration.ofSeconds(42), mgmt.getTTL(likes));
    assertEquals(Duration.ofSeconds(1), mgmt.getTTL(dislikes));
    assertEquals(Duration.ZERO, mgmt.getTTL(indifferentTo));
    assertEquals(Duration.ofSeconds(2), mgmt.getTTL(label1));
    mgmt.commit();
    TitanVertex v1 = tx.addVertex("person");
    TitanVertex v2 = tx.addVertex();
    Edge v1LikesV2 = v1.addEdge("likes", v2);
    Edge v1DislikesV2 = v1.addEdge("dislikes", v2);
    Edge v1IndifferentToV2 = v1.addEdge("indifferentTo", v2);
    tx.commit();
    long commitTime = System.currentTimeMillis();
    Object v1Id = v1.id();
    Object v2id = v2.id();
    Object v1LikesV2Id = v1LikesV2.id();
    Object v1DislikesV2Id = v1DislikesV2.id();
    Object v1IndifferentToV2Id = v1IndifferentToV2.id();
    v1 = getV(graph, v1Id);
    v2 = getV(graph, v2id);
    v1LikesV2 = getE(graph, v1LikesV2Id);
    v1DislikesV2 = getE(graph, v1DislikesV2Id);
    v1IndifferentToV2 = getE(graph, v1IndifferentToV2Id);
    assertNotNull(v1);
    assertNotNull(v2);
    assertNotNull(v1LikesV2);
    assertNotNull(v1DislikesV2);
    assertNotNull(v1IndifferentToV2);
    assertNotEmpty(v2.query().direction(Direction.IN).labels("likes").edges());
    assertNotEmpty(v2.query().direction(Direction.IN).labels("dislikes").edges());
    assertNotEmpty(v2.query().direction(Direction.IN).labels("indifferentTo").edges());
    Thread.sleep(commitTime + 1001L - System.currentTimeMillis());
    graph.tx().rollback();
    v1 = getV(graph, v1Id);
    v2 = getV(graph, v2id);
    v1LikesV2 = getE(graph, v1LikesV2Id);
    v1DislikesV2 = getE(graph, v1DislikesV2Id);
    v1IndifferentToV2 = getE(graph, v1IndifferentToV2Id);
    assertNotNull(v1);
    assertNotNull(v2);
    assertNotNull(v1LikesV2);
    // this edge has expired
    assertNull(v1DislikesV2);
    assertNotNull(v1IndifferentToV2);
    assertNotEmpty(v2.query().direction(Direction.IN).labels("likes").edges());
    // expired
    assertEmpty(v2.query().direction(Direction.IN).labels("dislikes").edges());
    assertNotEmpty(v2.query().direction(Direction.IN).labels("indifferentTo").edges());
    Thread.sleep(commitTime + 2001L - System.currentTimeMillis());
    graph.tx().rollback();
    v1 = getV(graph, v1Id);
    v2 = getV(graph, v2id);
    v1LikesV2 = getE(graph, v1LikesV2Id);
    v1DislikesV2 = getE(graph, v1DislikesV2Id);
    v1IndifferentToV2 = getE(graph, v1IndifferentToV2Id);
    // the vertex itself has expired
    assertNull(v1);
    assertNotNull(v2);
    // all incident edges have necessarily expired
    assertNull(v1LikesV2);
    assertNull(v1DislikesV2);
    assertNull(v1IndifferentToV2);
    if (dbCache) {
    /* TODO: uncomment
            assertNotEmpty(v2.query().direction(Direction.IN).labels("likes").edges());
            assertNotEmpty(v2.query().direction(Direction.IN).labels("dislikes").edges());
            assertNotEmpty(v2.query().direction(Direction.IN).labels("indifferentTo").edges());
            */
    } else {
        assertEmpty(v2.query().direction(Direction.IN).labels("likes").edges());
        assertEmpty(v2.query().direction(Direction.IN).labels("dislikes").edges());
        assertEmpty(v2.query().direction(Direction.IN).labels("indifferentTo").edges());
    }
}
Also used : TitanVertex(com.thinkaurelius.titan.core.TitanVertex) BaseVertexLabel(com.thinkaurelius.titan.graphdb.types.system.BaseVertexLabel) VertexLabel(com.thinkaurelius.titan.core.VertexLabel) EdgeLabel(com.thinkaurelius.titan.core.EdgeLabel) TitanEdge(com.thinkaurelius.titan.core.TitanEdge) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Category(org.junit.experimental.categories.Category) RelationCategory(com.thinkaurelius.titan.graphdb.internal.RelationCategory) ElementCategory(com.thinkaurelius.titan.graphdb.internal.ElementCategory) Test(org.junit.Test)

Example 18 with Category

use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.

the class ClientMapIssueTest method testOperationNotBlockingAfterClusterShutdown.

@Test
@Category(NightlyTest.class)
public void testOperationNotBlockingAfterClusterShutdown() throws InterruptedException {
    Config config = getConfig();
    HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
    HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setExecutorPoolSize(1);
    clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
    clientConfig.setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), "10");
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    final IMap<String, String> map = client.getMap(randomMapName());
    map.put(randomString(), randomString());
    instance1.getLifecycleService().terminate();
    instance2.getLifecycleService().terminate();
    final CountDownLatch latch = new CountDownLatch(1);
    new Thread() {

        public void run() {
            try {
                map.get(randomString());
            } catch (Exception ignored) {
            } finally {
                latch.countDown();
            }
        }
    }.start();
    assertOpenEventually(latch);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) CountDownLatch(java.util.concurrent.CountDownLatch) Category(org.junit.experimental.categories.Category) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with Category

use of org.junit.experimental.categories.Category in project gradle by gradle.

the class CategoryFilter method shouldRun.

private boolean shouldRun(final Description description, final Description parent) {
    final Set<Class<?>> categories = new HashSet<Class<?>>();
    Category annotation = description.getAnnotation(Category.class);
    if (annotation != null) {
        categories.addAll(Arrays.asList(annotation.value()));
    }
    if (parent != null) {
        annotation = parent.getAnnotation(Category.class);
        if (annotation != null) {
            categories.addAll(Arrays.asList(annotation.value()));
        }
    }
    boolean result = inclusions.isEmpty();
    for (Class<?> category : categories) {
        if (matches(category, inclusions)) {
            result = true;
            break;
        }
    }
    if (result) {
        for (Class<?> category : categories) {
            if (matches(category, exclusions)) {
                result = false;
                break;
            }
        }
    }
    return result;
}
Also used : Category(org.junit.experimental.categories.Category) HashSet(java.util.HashSet)

Example 20 with Category

use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.

the class MapLockTest method testLockEvictionWithMigration.

@Category(NightlyTest.class)
@Test
public void testLockEvictionWithMigration() throws Exception {
    final TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);
    final Config config = getConfig();
    final HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config);
    final String name = randomString();
    final IMap<Integer, Object> map = instance1.getMap(name);
    for (int i = 0; i < 1000; i++) {
        map.lock(i, 20, TimeUnit.SECONDS);
    }
    final HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config);
    final HazelcastInstance instance3 = nodeFactory.newHazelcastInstance(config);
    for (int i = 0; i < 1000; i++) {
        assertTrue(map.isLocked(i));
    }
    final CountDownLatch latch = new CountDownLatch(1000);
    Thread t = new Thread(new Runnable() {

        public void run() {
            for (int i = 0; i < 1000; i++) {
                map.lock(i);
                latch.countDown();
            }
        }
    });
    t.start();
    assertOpenEventually(latch);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Category(org.junit.experimental.categories.Category) NightlyTest(com.hazelcast.test.annotation.NightlyTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Category (org.junit.experimental.categories.Category)479 Test (org.junit.Test)476 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)148 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)121 File (java.io.File)68 VM (org.apache.geode.test.dunit.VM)65 KV (org.apache.beam.sdk.values.KV)62 Instant (org.joda.time.Instant)60 ArrayList (java.util.ArrayList)52 Matchers.containsString (org.hamcrest.Matchers.containsString)49 StringUtils.byteArrayToJsonString (org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString)41 Region (org.apache.geode.cache.Region)35 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)34 Host (org.apache.geode.test.dunit.Host)34 Properties (java.util.Properties)32 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)31 Cache (org.apache.geode.cache.Cache)26 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)25 IOException (java.io.IOException)24 CacheException (org.apache.geode.cache.CacheException)24