-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12. Use testcontainers instead of compose. Use org.foundationdb arti…
…facts and latest fdb image Signed-off-by: Christopher Jackson <[email protected]>
- Loading branch information
1 parent
000c6b8
commit f3a1478
Showing
21 changed files
with
179 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/test/java/com/experoinc/janusgraph/FoundationDBContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]) | ||
|
@@ -31,5 +32,5 @@ | |
public class FoundationDBJanusGraphComputerTest { | ||
|
||
@ClassRule | ||
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker(); | ||
public static GenericContainer container = new FoundationDBContainer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
@@ -16,5 +17,5 @@ | |
public class FoundationDBJanusGraphMultiQueryProcessTest { | ||
|
||
@ClassRule | ||
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker(); | ||
public static GenericContainer container = new FoundationDBContainer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]) | ||
|
@@ -30,5 +31,5 @@ | |
public class FoundationDBJanusGraphProcessTest { | ||
|
||
@ClassRule | ||
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker(); | ||
public static GenericContainer container = new FoundationDBContainer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]) | ||
|
@@ -31,5 +32,5 @@ | |
public class FoundationDBJanusGraphStructureTest { | ||
|
||
@ClassRule | ||
public static DockerComposeRule docker = FoundationDBStorageSetup.startFoundationDBDocker(); | ||
public static GenericContainer container = new FoundationDBContainer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
|
Oops, something went wrong.