Skip to content

Commit

Permalink
#12. Use testcontainers instead of compose. Use org.foundationdb arti…
Browse files Browse the repository at this point in the history
…facts and latest fdb image

Signed-off-by: Christopher Jackson <[email protected]>
  • Loading branch information
jackson-chris committed Jul 10, 2020
1 parent 000c6b8 commit b26f5fc
Show file tree
Hide file tree
Showing 21 changed files with 179 additions and 118 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ target/
.idea
*.iml

# FDB test configuration generated by the FDB test container
src/test/resources/etc

jub*.xml

# Eclipse Files #
.classpath
.project
.settings
.metadata
32 changes: 7 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<dependency.plugin.version>2.10</dependency.plugin.version>
<test.skip.default>false</test.skip.default>
<test.skip.tp>true</test.skip.tp>
<testcontainers.version>1.14.3</testcontainers.version>
</properties>

<developers>
Expand All @@ -34,25 +35,6 @@
</license>
</licenses>

<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>palantir</id>
<name>bintray></name>
<url>https://dl.bintray.com/palantir/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.janusgraph</groupId>
Expand All @@ -66,15 +48,15 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.apple</groupId>
<artifactId>foundationdb</artifactId>
<groupId>org.foundationdb</groupId>
<artifactId>fdb-java</artifactId>
<version>${foundationdb.version}</version>
</dependency>
<dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-junit4</artifactId>
<version>0.33.0</version>
<scope>test</scope>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
63 changes: 63 additions & 0 deletions src/test/java/com/experoinc/janusgraph/FoundationDBContainer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.experoinc.janusgraph;

import java.io.IOException;
import java.net.ServerSocket;

import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.FixedHostPortGenericContainer;

public class FoundationDBContainer extends FixedHostPortGenericContainer<FoundationDBContainer> {

public static final String DEFAULT_IMAGE_AND_TAG = "foundationdb/foundationdb:6.2.20";
private static final Integer DEFAULT_PORT = 4500;
private static final String FDB_CLUSTER_FILE_ENV_KEY = "FDB_CLUSTER_FILE";
private static final String FDB_NETWORKING_MODE_ENV_KEY = "FDB_NETWORKING_MODE";
private static final String FDB_PORT_ENV_KEY = "FDB_PORT";
private static final String DEFAULT_NETWORKING_MODE = "host";
private static final String DEFAULT_CLUSTER_FILE_PARENT_DIR = "/etc/foundationdb";
private static final String DEFAULT_CLUSTER_FILE_PATH = DEFAULT_CLUSTER_FILE_PARENT_DIR + "/" + "fdb.cluster";
private static final String DEFAULT_VOLUME_SOURCE_PATH = "./fdb";


public FoundationDBContainer(String dockerImageName) {
super(dockerImageName);
Integer port = findRandomOpenPortOnAllLocalInterfaces();
this.addFixedExposedPort(port, port);
this.addExposedPorts(port);
this.addEnv(FDB_CLUSTER_FILE_ENV_KEY, DEFAULT_CLUSTER_FILE_PATH);
this.addEnv(FDB_PORT_ENV_KEY, port.toString());
this.addEnv(FDB_NETWORKING_MODE_ENV_KEY, DEFAULT_NETWORKING_MODE);
this.withClasspathResourceMapping(DEFAULT_VOLUME_SOURCE_PATH, DEFAULT_CLUSTER_FILE_PARENT_DIR, BindMode.READ_WRITE);
}

public FoundationDBContainer(){
this(DEFAULT_IMAGE_AND_TAG);
}

private Integer findRandomOpenPortOnAllLocalInterfaces() {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
} catch (Exception e) {
System.err.println("Couldn't open random socket, using default!");
return DEFAULT_PORT;
}
}

@Override
public void start() {
super.start();
// initialize the database
Container.ExecResult lsResult;
try {
lsResult = this.execInContainer("fdbcli", "--exec", "configure new single ssd");
} catch (UnsupportedOperationException | IOException | InterruptedException e) {
throw new ContainerLaunchException("Container startup failed. Failed to initialized the database.");
}
if(lsResult.getExitCode() != 0) {
throw new ContainerLaunchException("Container startup failed. Failed to initialized the database.");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

package com.experoinc.janusgraph;

import com.palantir.docker.compose.DockerComposeRule;
import com.palantir.docker.compose.connection.waiting.HealthChecks;
import org.janusgraph.StorageSetup;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import org.janusgraph.diskstorage.configuration.WriteConfiguration;
Expand All @@ -41,18 +39,12 @@ public static ModifiableConfiguration getFoundationDBConfiguration(final String
.set(STORAGE_BACKEND,"com.experoinc.janusgraph.diskstorage.foundationdb.FoundationDBStoreManager")
.set(DIRECTORY, graphName)
.set(DROP_ON_CLEAR, false)
.set(CLUSTER_FILE_PATH, "src/test/resources/etc/fdb.cluster")
.set(CLUSTER_FILE_PATH, "target/test-classes/fdb/fdb.cluster")
.set(ISOLATION_LEVEL, "read_committed_with_write");
}

public static WriteConfiguration getFoundationDBGraphConfiguration() {
return getFoundationDBConfiguration().getConfiguration();
}

public static DockerComposeRule startFoundationDBDocker() {
return DockerComposeRule.builder()
.file("src/test/resources/docker-compose.yml")
.waitingForService("db", HealthChecks.toHaveAllPortsOpen())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

package com.experoinc.janusgraph.blueprints.process;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphComputerProvider;
import org.janusgraph.core.JanusGraph;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
import org.janusgraph.core.JanusGraph;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphComputerProvider;

/**
* @author Ted Wilmes ([email protected])
Expand All @@ -31,5 +32,5 @@
public class FoundationDBJanusGraphComputerTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.experoinc.janusgraph.blueprints.process;

import com.palantir.docker.compose.DockerComposeRule;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.experoinc.janusgraph.blueprints.FoundationDBMultiQueryGraphProvider;
import org.janusgraph.core.JanusGraph;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.blueprints.FoundationDBMultiQueryGraphProvider;

/**
* @author Ted Wilmes ([email protected])
Expand All @@ -16,5 +17,5 @@
public class FoundationDBJanusGraphMultiQueryProcessTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

package com.experoinc.janusgraph.blueprints.process;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphProvider;
import org.janusgraph.core.JanusGraph;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.janusgraph.core.JanusGraph;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphProvider;

/**
* @author Ted Wilmes ([email protected])
Expand All @@ -30,5 +31,5 @@
public class FoundationDBJanusGraphProcessTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

package com.experoinc.janusgraph.blueprints.structure;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphProvider;
import org.janusgraph.core.JanusGraph;
import org.apache.tinkerpop.gremlin.GraphProviderClass;
import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
import org.janusgraph.core.JanusGraph;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.blueprints.FoundationDBGraphProvider;

/**
* @author Ted Wilmes ([email protected])
Expand All @@ -31,5 +32,5 @@
public class FoundationDBJanusGraphStructureTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@

package com.experoinc.janusgraph.diskstorage.foundationdb;

import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.google.common.collect.ImmutableMap;
import com.palantir.docker.compose.DockerComposeRule;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.KeyColumnValueStoreTest;
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager;
import org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import com.google.common.collect.ImmutableMap;

/**
* @author Ted Wilmes ([email protected])
*/
public class FoundationDBFixedLengthKCVSTest extends KeyColumnValueStoreTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();

public KeyColumnValueStoreManager openStorageManager() throws BackendException {
FoundationDBStoreManager sm = new FoundationDBStoreManager(FoundationDBStorageSetup.getFoundationDBConfiguration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

package com.experoinc.janusgraph.diskstorage.foundationdb;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.KeyValueStoreTest;
import org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManager;
import org.junit.ClassRule;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.FoundationDBStorageSetup;

/**
* @author Ted Wilmes ([email protected])
*/
public class FoundationDBKeyValueTest extends KeyValueStoreTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@

package com.experoinc.janusgraph.diskstorage.foundationdb;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager;
import org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter;
import org.janusgraph.diskstorage.log.KCVSLogTest;
import org.junit.ClassRule;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.FoundationDBStorageSetup;

/**
* @author Ted Wilmes ([email protected])
*/
public class FoundationDBLogTest extends KCVSLogTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();

public KeyColumnValueStoreManager openStorageManager() throws BackendException {
FoundationDBStoreManager sm = new FoundationDBStoreManager(FoundationDBStorageSetup.getFoundationDBConfiguration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@

package com.experoinc.janusgraph.diskstorage.foundationdb;

import com.palantir.docker.compose.DockerComposeRule;
import com.experoinc.janusgraph.FoundationDBStorageSetup;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.KeyColumnValueStoreTest;
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager;
import org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManagerAdapter;
import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;

import com.experoinc.janusgraph.FoundationDBContainer;
import com.experoinc.janusgraph.FoundationDBStorageSetup;

/**
* @author Ted Wilmes ([email protected])
*/
public class FoundationDBVariableLengthKCVSTest extends KeyColumnValueStoreTest {

@ClassRule
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker();
public static GenericContainer container = new FoundationDBContainer();

public KeyColumnValueStoreManager openStorageManager() throws BackendException {
FoundationDBStoreManager sm = new FoundationDBStoreManager(FoundationDBStorageSetup.getFoundationDBConfiguration());
Expand Down
Loading

0 comments on commit b26f5fc

Please sign in to comment.