This is ArangoDB TestContainers module for running database as Docker container.
Features:
Gradle
testImplementation "com.github.goodforgod:arangodb-testcontainer:3.0.1"
Maven
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>arangodb-testcontainer</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
Check this TestContainers tutorials for Jupiter / JUnit 5 examples.
Run ArangoDB container without authentication.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoContainer<?> container = new ArangoContainer<>("arangodb:3.11.2")
.withoutAuth();
@Test
void checkContainerIsRunning() {
assertTrue(container.isRunning());
}
}
Run ArangoDB Cluster without authentication.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoCluster CLUSTER = ArangoCluster.builder("arangodb:3.11.2")
.withoutAuth()
.build();
@Test
void checkContainerIsRunning() {
assertTrue(CLUSTER.getAgentLeader().isRunning());
}
}
Container implements startup strategy and will be available to TestContainer framework automatically when database will be ready for accepting connections.
Check here for more info about strategies.
All authentication options are available as per ArangoDB Docker description.
Without authentication or password or random password configuration is required as per docker image.
You can run ArangoDB without authentication by specifying with setter.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoContainer<?> container = new ArangoContainer<>()
.withoutAuth();
@Test
void checkContainerIsRunning() {
assertTrue(container.isRunning());
}
}
Database default user is root. You can specify desired password that will be assigned to root user.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoContainer<?> container = new ArangoContainer<>()
.withPassword("mypass");
@Test
void checkContainerIsRunning() {
assertTrue(container.isRunning());
}
}
You can run container with random password for root user, but is such case, there is no methods to retrieve that password. You will have to retrieve it somehow by your own.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoContainer<?> container = new ArangoContainer<>()
.withRandomPassword();
@Test
void checkContainerIsRunning() {
assertTrue(container.isRunning());
}
}
You can run ArangoDB cluster as TestContainers.
Default cluster with 3 Agent nodes, 2 DBServer nodes and 2 Coordinator nodes is preconfigured for easy usage.
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoCluster CLUSTER = ArangoCluster.builder("arangodb:3.11.2")
.withPassword("mypass")
.build();
@Test
void checkContainerIsRunning() {
CLUSTER.getHost();
CLUSTER.getPort();
CLUSTER.getUser();
CLUSTER.getPassword();
}
}
You can build cluster with desired size via ArangoClusterBuilder.
You can check each container type via specified cluster container method.
final ArangoCluster cluster = ArangoCluster.builder("arangodb:3.11.2")
.withAgentNodes(3) // 3 agent nodes by default
.withDatabaseNodes(2) // 2 dbserver nodes by default
.withCoordinatorNodes(2) // 2 coordinator nodes by default
.build();
This project licensed under the MIT - see the LICENSE file for details.