Skip to content

GoodforGod/arangodb-testcontainers

Repository files navigation

ArangoDB TestContainers

Minimum required Java version Maven Central GitHub Action Quality Gate Status Coverage Maintainability Rating

This is ArangoDB TestContainers module for running database as Docker container.

Features:

Dependency 🚀

Gradle

testImplementation "com.github.goodforgod:arangodb-testcontainer:4.0.0"

Maven

<dependency> <groupId>com.github.goodforgod</groupId> <artifactId>arangodb-testcontainer</artifactId> <version>4.0.0</version> <scope>test</scope> </dependency>

Testcontainers

  • Version 4+ - build on top of Testcontainers 1.21.3
  • Version 3+ - build on top of Testcontainers 1.17.6
  • Version 2+ - build on top of Testcontainers 1.17.3

Usage

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.12.4") .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.12.4") .withoutAuth() .build(); @Test void checkContainerIsRunning() { assertTrue(CLUSTER.getAgentLeader().isRunning()); } }

Container

Up & Running

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.

Auth

All authentication options are available as per ArangoDB Docker description.

Without authentication or password or random password configuration is required as per docker image.

Without Authentication

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()); } }

With Password

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()); } }

With Random Password

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()); } }

Cluster

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.12.4") .withPassword("mypass") .build(); @Test void checkContainerIsRunning() { CLUSTER.getHost(); CLUSTER.getPort(); CLUSTER.getUser(); CLUSTER.getPassword(); } }

Cluster Builder

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.12.4") .withAgentNodes(3) // 3 agent nodes by default .withDatabaseNodes(2) // 2 dbserver nodes by default .withCoordinatorNodes(2) // 2 coordinator nodes by default .build();

License

This project licensed under the MIT - see the LICENSE file for details.

Packages

 
 
 

Languages