use of org.janusgraph.testutil.FeatureFlag in project janusgraph by JanusGraph.
the class JanusGraphTest method testUnsettingTTL.
@Test
@FeatureFlag(feature = JanusGraphFeature.CellTtl)
public void testUnsettingTTL() throws InterruptedException {
int initialTTLMillis = 2000;
// Define schema: one edge label with a short ttl
EdgeLabel likes = mgmt.makeEdgeLabel("likes").make();
mgmt.setTTL(likes, Duration.ofMillis(initialTTLMillis));
mgmt.commit();
graph.tx().rollback();
// Insert two vertices with a TTLed edge
JanusGraphVertex v1 = graph.addVertex();
JanusGraphVertex v2 = graph.addVertex();
v1.addEdge("likes", v2);
graph.tx().commit();
// Let the edge die
Thread.sleep((long) Math.ceil(initialTTLMillis * 1.25));
// Edge should be gone
assertEquals(2, Iterators.size(graph.vertices()));
assertEquals(0, Iterators.size(graph.edges()));
graph.tx().rollback();
// Remove the TTL on the edge label
mgmt = graph.openManagement();
mgmt.setTTL(mgmt.getEdgeLabel("likes"), Duration.ZERO);
mgmt.commit();
Thread.sleep(1L);
// Check that the edge is still gone, add a new edge
assertEquals(2, Iterators.size(graph.vertices()));
assertEquals(0, Iterators.size(graph.edges()));
v1 = graph.addVertex();
v2 = graph.addVertex();
v1.addEdge("likes", v2);
graph.tx().commit();
// Sleep past when it would have expired under the original config
Thread.sleep((long) Math.ceil(initialTTLMillis * 1.25));
// Edge must not be dead
assertEquals(4, Iterators.size(graph.vertices()));
assertEquals(1, Iterators.size(graph.edges()));
graph.tx().rollback();
}
use of org.janusgraph.testutil.FeatureFlag in project janusgraph by JanusGraph.
the class KeyColumnValueStoreTest method testOrderedGetKeysRespectsKeyLimit.
/**
* Verify that
* {@link KeyColumnValueStore#getKeys(KeyRangeQuery, StoreTransaction)}
* treats the lower key bound as inclusive and the upper key bound as
* exclusive. Verify that keys less than the start and greater than or equal
* to the end containing matching columns are not returned.
*
* @throws BackendException
*/
@Test
@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testOrderedGetKeysRespectsKeyLimit(TestInfo testInfo) throws BackendException {
Preconditions.checkState(4 <= numKeys && 4 <= numColumns);
final long minKey = KeyValueStoreUtil.idOffset + 1;
final long maxKey = KeyValueStoreUtil.idOffset + numKeys - 2;
final long expectedKeyCount = maxKey - minKey;
String[][] values = generateValues();
loadValues(values);
final SliceQuery columnSlice = new SliceQuery(BufferUtil.zeroBuffer(8), BufferUtil.oneBuffer(8)).setLimit(1);
KeyIterator keys;
keys = store.getKeys(new KeyRangeQuery(BufferUtil.getLongBuffer(minKey), BufferUtil.getLongBuffer(maxKey), columnSlice), tx);
assertEquals(expectedKeyCount, KeyValueStoreUtil.count(keys));
clopen();
keys = store.getKeys(new KeyRangeQuery(BufferUtil.getLongBuffer(minKey), BufferUtil.getLongBuffer(maxKey), columnSlice), tx);
assertEquals(expectedKeyCount, KeyValueStoreUtil.count(keys));
}
use of org.janusgraph.testutil.FeatureFlag in project janusgraph by JanusGraph.
the class KeyColumnValueStoreTest method testGetKeysWithSliceQuery.
@Test
@FeatureFlag(feature = JanusGraphFeature.UnorderedScan)
public void testGetKeysWithSliceQuery(TestInfo testInfo) throws Exception {
populateDBWith100Keys();
tx.commit();
tx = startTx();
KeyIterator keyIterator = store.getKeys(new SliceQuery(new ReadArrayBuffer("b".getBytes()), new ReadArrayBuffer("c".getBytes())), tx);
examineGetKeysResults(keyIterator, 0, 100);
}
use of org.janusgraph.testutil.FeatureFlag in project janusgraph by JanusGraph.
the class JanusGraphTest method testEdgeTTLWithIndex.
@Test
@Tag(TestCategory.BRITTLE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.CellTtl)
public void testEdgeTTLWithIndex() throws Exception {
// 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, desc, 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();
JanusGraphVertex 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.janusgraph.testutil.FeatureFlag in project janusgraph by JanusGraph.
the class JanusGraphTest method testVertexTTLWithCompositeIndex.
@Test
@FeatureFlag(feature = JanusGraphFeature.CellTtl)
public void testVertexTTLWithCompositeIndex() throws Exception {
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
PropertyKey time = mgmt.makePropertyKey("time").dataType(Long.class).make();
final JanusGraphIndex index1 = mgmt.buildIndex("index1", Vertex.class).addKey(name).buildCompositeIndex();
final JanusGraphIndex index2 = mgmt.buildIndex("index2", Vertex.class).addKey(name).addKey(time).buildCompositeIndex();
VertexLabel label1 = mgmt.makeVertexLabel("event").setStatic().make();
mgmt.setTTL(label1, Duration.ofSeconds(1));
assertEquals(Duration.ZERO, mgmt.getTTL(name));
assertEquals(Duration.ZERO, mgmt.getTTL(time));
assertEquals(Duration.ofSeconds(1), mgmt.getTTL(label1));
mgmt.commit();
JanusGraphVertex v1 = tx.addVertex(T.label, "event", "name", "some event", "time", System.currentTimeMillis());
tx.commit();
Object id = v1.id();
v1 = getV(graph, id);
assertNotNull(v1);
assertNotEmpty(graph.query().has("name", "some event").vertices());
Thread.sleep(1001);
graph.tx().rollback();
v1 = getV(graph, id);
assertNull(v1);
assertEmpty(graph.query().has("name", "some event").vertices());
}
Aggregations