https://github.com/goodforgod/arangodb-testcontainers
⚙️ TestContainers ArangoDB module implementation.
https://github.com/goodforgod/arangodb-testcontainers
arangodb arangodb-container arangodb-testcontainer testcontainers testcontainers-arango testcontainers-arangodb
Last synced: about 1 year ago
JSON representation
⚙️ TestContainers ArangoDB module implementation.
- Host: GitHub
- URL: https://github.com/goodforgod/arangodb-testcontainers
- Owner: GoodforGod
- License: mit
- Created: 2020-03-02T20:00:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-13T08:35:49.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T19:22:30.900Z (over 1 year ago)
- Topics: arangodb, arangodb-container, arangodb-testcontainer, testcontainers, testcontainers-arango, testcontainers-arangodb
- Language: Java
- Homepage: https://testcontainers.com/modules/arangodb/
- Size: 217 KB
- Stars: 12
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ArangoDB TestContainers
[](https://openjdk.org/projects/jdk8/)
[](https://maven-badges.herokuapp.com/maven-central/com.github.goodforgod/arangodb-testcontainer)

[](https://sonarcloud.io/dashboard?id=GoodforGod_arangodb-testcontainers)
[](https://sonarcloud.io/dashboard?id=GoodforGod_arangodb-testcontainers)
[](https://sonarcloud.io/dashboard?id=GoodforGod_arangodb-testcontainers)
This is [ArangoDB TestContainers](https://testcontainers.com/modules/arangodb/) module for running database as Docker container.
Features:
- ArangoDB [container](#container).
- ArangoDB [cluster](#cluster).
## Dependency :rocket:
**Gradle**
```groovy
testImplementation "com.github.goodforgod:arangodb-testcontainer:3.0.1"
```
**Maven**
```xml
com.github.goodforgod
arangodb-testcontainer
3.0.1
test
```
## Usage
Check [this](https://www.testcontainers.org/test_framework_integration/junit_5/) TestContainers tutorials for **Jupiter / JUnit 5** examples.
Run ArangoDB container *without* authentication.
```java
@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.
```java
@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
### Up & Running
Container implements *startup strategy* and will be *available to TestContainer framework automatically* when database will be ready for accepting connections.
Check [here](https://www.testcontainers.org/features/startup_and_waits/) for more info about strategies.
### Auth
All authentication options are available as per [ArangoDB Docker description](https://hub.docker.com/_/arangodb).
*Without authentication or password or random password* configuration is **required** as per [docker image](https://hub.docker.com/_/arangodb).
#### Without Authentication
You can run ArangoDB without authentication by specifying with setter.
```java
@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.
```java
@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.
```java
@Testcontainers
class ArangoContainerTests {
@Container
private static final ArangoContainer> container = new ArangoContainer<>()
.withRandomPassword();
@Test
void checkContainerIsRunning() {
assertTrue(container.isRunning());
}
}
```
## Cluster
You can run [ArangoDB cluster](https://www.arangodb.com/community-server/cluster/) as TestContainers.
Default cluster with 3 Agent nodes, 2 DBServer nodes and 2 Coordinator nodes is preconfigured for easy usage.
```java
@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();
}
}
```
### Cluster Builder
You can build cluster with desired size via *ArangoClusterBuilder*.
You can check each container type via specified cluster container method.
```java
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();
```
## License
This project licensed under the MIT - see the [LICENSE](LICENSE) file for details.