-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Richard North <[email protected]> Co-authored-by: Sergei Egorov <[email protected]> Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
- Loading branch information
1 parent
3280fda
commit e3ec7d4
Showing
8 changed files
with
532 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,109 @@ | ||
# InfluxDB Module | ||
|
||
Testcontainers module for InfluxData [InfluxDB](https://github.com/influxdata/influxdb). | ||
Testcontainers module for InfluxData [InfluxDB](https://www.influxdata.com/products/influxdb/). | ||
|
||
## Usage example | ||
## Important note | ||
|
||
Running influxDbContainer as a stand-in for InfluxDB in a test: | ||
There are breaking changes in InfluxDB 2.x. | ||
For more information refer to the main [documentation](https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/). | ||
You can find more information about the official InfluxDB image on [Docker Hub](https://hub.docker.com/_/influxdb). | ||
|
||
```java | ||
public class SomeTest { | ||
## InfluxDB 2.x usage example | ||
|
||
@Rule | ||
public InfluxDBContainer influxDbContainer = new InfluxDBContainer(); | ||
|
||
@Test | ||
public void someTestMethod() { | ||
InfluxDB influxDB = influxDbContainer.getNewInfluxDB(); | ||
... | ||
``` | ||
Running a `InfluxDBContainer` as a stand-in for InfluxDB in a test: | ||
|
||
<!--codeinclude--> | ||
[Create an InfluxDB container](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java) inside_block:constructorWithDefaultVariables | ||
<!--/codeinclude--> | ||
|
||
|
||
The InfluxDB instance will be setup with the following data:<br/> | ||
|
||
| Property | Default Value | | ||
|--------------|:-------------:| | ||
| username | test-user | | ||
| password | test-password | | ||
| organization | test-org | | ||
| bucket | test-bucket | | ||
| retention | 0 (infinite) | | ||
| adminToken | - | | ||
|
||
For more details about the InfluxDB setup, please visit the official [InfluxDB documentation](https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/docker/#influxdb-2x-initialization-credentials). | ||
|
||
It is possible to overwrite the default property values. Create a container with InfluxDB admin token: | ||
<!--codeinclude--> | ||
[Create an InfluxDB container with admin token](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java) inside_block:constructorWithAdminToken | ||
<!--/codeinclude--> | ||
|
||
Or create a container with custom username, password, bucket, organization, and retention time: | ||
<!--codeinclude--> | ||
[Create an InfluxDB container with custom settings](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java) inside_block:constructorWithCustomVariables | ||
<!--/codeinclude--> | ||
|
||
The following code snippet shows how you can create an InfluxDB Java client: | ||
|
||
<!--codeinclude--> | ||
[Create an InfluxDB Java client](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java) inside_block:createInfluxDBClient | ||
<!--/codeinclude--> | ||
|
||
!!! hint | ||
You can find the latest documentation about the InfluxDB 2.x Java client [here](https://github.com/influxdata/influxdb-client-java). | ||
|
||
## InfluxDB 1.x usage example | ||
|
||
Running a `InfluxDBContainer` as a stand-in for InfluxDB in a test with default env variables: | ||
|
||
<!--codeinclude--> | ||
[Create an InfluxDB container](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerV1Test.java) inside_block:constructorWithDefaultVariables | ||
<!--/codeinclude--> | ||
|
||
The InfluxDB instance will be setup with the following data:<br/> | ||
|
||
| Property | Default Value | | ||
|---------------|:-------------:| | ||
| username | test-user | | ||
| password | test-password | | ||
| authEnabled | true | | ||
| admin | admin | | ||
| adminPassword | password | | ||
| database | - | | ||
|
||
It is possible to overwrite the default values. | ||
For instance, creating an InfluxDB container with a custom username, password, and database name: | ||
<!--codeinclude--> | ||
[Create an InfluxDB container with custom settings](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerV1Test.java) inside_block:constructorWithUserPassword | ||
<!--/codeinclude--> | ||
|
||
In the following example you will find a snippet to create an InfluxDB client using the official Java client: | ||
|
||
<!--codeinclude--> | ||
[Create an InfluxDB Java client](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerV1Test.java) inside_block:createInfluxDBClient | ||
<!--/codeinclude--> | ||
|
||
!!! hint | ||
You can find the latest documentation about the InfluxDB 1.x Java client [here](https://github.com/influxdata/influxdb-java). | ||
|
||
## Adding this module to your project dependencies | ||
|
||
Add the following dependency to your `pom.xml`/`build.gradle` file: | ||
|
||
=== "Gradle" | ||
```groovy | ||
testImplementation "org.testcontainers:influxdb:{{latest_version}}" | ||
``` | ||
|
||
```groovy | ||
testImplementation "org.testcontainers:influxdb:{{latest_version}}" | ||
``` | ||
|
||
=== "Maven" | ||
```xml | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>influxdb</artifactId> | ||
<version>{{latest_version}}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
|
||
```xml | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>influxdb</artifactId> | ||
<version>{{latest_version}}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
|
||
!!! hint | ||
Adding this Testcontainers library JAR will not automatically add a database driver JAR to your project. You should ensure that your project also has a suitable database driver as a dependency. |
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
Oops, something went wrong.