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());
}
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());
}
}
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);
}
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;
}
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);
}
Aggregations