use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method shouldCreateCQLSessionWithStringConfigurationOnly.
@Test
public void shouldCreateCQLSessionWithStringConfigurationOnly() {
WriteConfiguration wc = getConfiguration();
String dataStaxConfiguration = prepareDataStaxConfiguration(wc);
wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), false);
wc.set(ConfigElement.getPath(STRING_CONFIGURATION), dataStaxConfiguration);
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
assertDoesNotThrow(() -> {
graph.traversal().V().hasNext();
graph.tx().rollback();
});
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method shouldCreateCQLSessionWithResourceAndStringConfigurations.
@Test
public void shouldCreateCQLSessionWithResourceAndStringConfigurations() {
WriteConfiguration wc = getConfiguration();
String dataStaxConfiguration = prepareDataStaxContactPointsOnlyConfiguration(wc);
wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), false);
wc.set(ConfigElement.getPath(RESOURCE_CONFIGURATION), "datastaxResourceTestConfigWithoutContactPoints.conf");
wc.set(ConfigElement.getPath(STRING_CONFIGURATION), dataStaxConfiguration);
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
assertDoesNotThrow(() -> {
graph.traversal().V().hasNext();
graph.tx().rollback();
});
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method testMetaDataGraphConfig.
@ParameterizedTest
@MethodSource("getMetadataConfigs")
public void testMetaDataGraphConfig(String partitionerName, boolean schemaEnabled, boolean tokenMapEnabled) {
WriteConfiguration wc = getConfiguration();
String currentPartitionerName = getCurrentPartitionerName();
if (partitionerName != null)
wc.set(ConfigElement.getPath(PARTITIONER_NAME), partitionerName);
assertNull(wc.get(ConfigElement.getPath(METADATA_SCHEMA_ENABLED), METADATA_SCHEMA_ENABLED.getDatatype()));
assertNull(wc.get(ConfigElement.getPath(METADATA_TOKEN_MAP_ENABLED), METADATA_TOKEN_MAP_ENABLED.getDatatype()));
wc.set(ConfigElement.getPath(METADATA_SCHEMA_ENABLED), schemaEnabled);
wc.set(ConfigElement.getPath(METADATA_TOKEN_MAP_ENABLED), tokenMapEnabled);
if (// not matching
tokenMapEnabled && partitionerName != null && !partitionerName.equals(currentPartitionerName) || // not provided and cannot be retrieved
!tokenMapEnabled && partitionerName == null) {
assertThrows(IllegalArgumentException.class, () -> JanusGraphFactory.open(wc));
} else {
JanusGraphFactory.open(wc);
}
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method testCustomConfigUsedByTx.
@Test
public void testCustomConfigUsedByTx() {
WriteConfiguration wc = getConfiguration();
wc.set(ConfigElement.getPath(READ_CONSISTENCY), "ALL");
wc.set(ConfigElement.getPath(WRITE_CONSISTENCY), "ALL");
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.buildTransaction().customOption(ConfigElement.getPath(READ_CONSISTENCY), "ONE").customOption(ConfigElement.getPath(WRITE_CONSISTENCY), "TWO").start();
assertEquals("ONE", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(READ_CONSISTENCY));
assertEquals("TWO", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(WRITE_CONSISTENCY));
tx.rollback();
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method shouldGracefullyCloseGraphWhichLostAConnection.
@Test
public void shouldGracefullyCloseGraphWhichLostAConnection() {
WriteConfiguration wc = getConfiguration();
wc.set(ConfigElement.getPath(EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME), 60000);
wc.set(ConfigElement.getPath(PARALLEL_BACKEND_EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME), 60000);
wc.set(ConfigElement.getPath(IDS_RENEW_TIMEOUT), 10000);
wc.set(ConfigElement.getPath(CONNECTION_TIMEOUT), 10000);
wc.set(ConfigElement.getPath(HEARTBEAT_TIMEOUT), 10000);
if (graph != null && graph.isOpen()) {
graph.close();
}
Set<Thread> threadsFromPossibleOtherOpenedConnections = Thread.getAllStackTraces().keySet().stream().filter(thread -> {
String threadNameLowercase = thread.getName().toLowerCase();
return thread.isAlive() && (threadNameLowercase.startsWith("cql") || threadNameLowercase.startsWith("janusgraph"));
}).collect(Collectors.toSet());
boolean flakyTest = !threadsFromPossibleOtherOpenedConnections.isEmpty();
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
assertDoesNotThrow(() -> {
graph.traversal().V().hasNext();
graph.tx().rollback();
});
Set<Thread> threadsToAwait = Thread.getAllStackTraces().keySet().stream().filter(thread -> {
String threadNameLowercase = thread.getName().toLowerCase();
return thread.isAlive() && !threadsFromPossibleOtherOpenedConnections.contains(thread) && (threadNameLowercase.startsWith("cql") || threadNameLowercase.startsWith("janusgraph"));
}).collect(Collectors.toSet());
cqlContainer.stop();
graph.close();
for (Thread thread : threadsToAwait) {
if (thread.isAlive()) {
if (flakyTest) {
log.warn("Test shouldGracefullyCloseGraphWhichLostAConnection is currently running in flaky mode " + "because there were open instances available before the test started. " + "Thus, we don't fail this test because we can't be sure that current thread {} " + "is leaked or were created by other JanusGraph instances.", thread.getName());
} else {
fail("Thread " + thread.getName() + " was alive but expected to be terminated");
}
}
}
}
Aggregations