Skip to content

aleris/testcontainers-foundationdb

Repository files navigation

Testcontainers FoundationDB Module

Build

Helps running FoundationDB using Testcontainers.

It's based on the docker images provided by FoundationDB Community.

Adding this module to your project dependencies

  1. Add Foundation DB java client dependency, for example:
implementation("org.foundationdb:fdb-java:7.1.61")
<dependency>
    <groupId>org.foundationdb</groupId>
    <artifactId>fdb-java</artifactId>
    <version>7.1.61</version>
</dependency>

Note that the FDB client requires the native client libraries to be installed:

  1. Add Testcontainers dependency, for example:
testImplementation "org.testcontainers:testcontainers:1.19.8"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
    <version>1.19.8</version>
    <scope>test</scope>
</dependency>
  1. Finally add the module dependency to your build.gradle / pom.xml file:
testImplementation "earth.adi:testcontainers-foundationdb:1.1.0"
<dependency>
    <groupId>earth.adi</groupId>
    <artifactId>testcontainers-foundationdb</artifactId>
    <version>1.1.0</version>
    <scope>test</scope>
</dependency>

Usage example

You can start a FoundationDB container instance from a Java application by using:

try (final FoundationDBContainer foundationDBContainer = new FoundationDBContainer()) {
    foundationDBContainer.start();

    final FDB fdb = FDB.selectAPIVersion(710);

    try (final Database db = fdb.open(foundationDBContainer.getClusterFilePath())) {
        db.run(tr -> {
            tr.set(Tuple.from("hello").pack(), Tuple.from("world").pack());
            return null;
        });
    }
}

To start with a specific version use:

final FoundationDBContainer foundationDBContainer = new FoundationDBContainer(
        DockerImageName.parse("foundationdb/foundationdb:7.1.61")
)

See also the tests for other examples.

Caveats

  • FDB requires the native client libraries be installed separately for the java dependency to work. Install the libraries before using the java FDB client.
  • On MacOS, try setting export DYLD_LIBRARY_PATH=/usr/local/lib in environment variables after installing FDB clients locally if you encounter issues.

Releasing

Details
~$ cd testcontainers-foundationdb
# Update version in build.gradle.kts
~/testcontainers-foundationdb ./gradlew updateReadmeVersion # updates the version in README.md from build.gradle.kts
~/testcontainers-foundationdb ./gradlew jreleaserConfig # just to double check the configuration
~/testcontainers-foundationdb ./gradlew clean
~/testcontainers-foundationdb ./gradlew publish
~/testcontainers-foundationdb ./gradlew jreleaserFullRelease