-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add InfluxDB v2 support #3669
Add InfluxDB v2 support #3669
Conversation
Thanks for the contribution @raminqaf I think one thing we need to be really careful about is the breaking-change nature of this. Is there no way at all to make the We need to avoid a situation where an upgrade of Testcontainers prevents people from being able to run their existing tests that rely on InfluxDB v1.x. |
@rnorth unfortunately not. Another way to add support for InfluxDB 2.x and keep the 1.x supported is to add a new and sperated module like |
What if we kept it in the same module, but have a |
@rnorth Sounds good to me! I will add your suggestions and push them to the PR. |
@rnorth any updates on this PR? |
I had a quick read and everything is ok at the first glance 👀 |
@vektory79 Thanks! |
hi,
there is 2.0.0 out. the example about v2 is a bit missleading i think cause the default for pure v2 s now token based . The user and password is only for the v1=>v2 upgraded instances. |
Thanks for the comment and your feedback on the PR. By the time I created this PR the version was |
…qaf/testcontainers-java into feature/influxdb-v2-test-container
Thanks for update. Any idea when we get the review done ? Would really like to have the update as release. |
Unfortunately not. In order to merge the PR, one of the three reviewers (@rnorth @bsideup @bsideup) should approved the PR first. |
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainerV2.java
Outdated
Show resolved
Hide resolved
@kiview Is this good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raminqaf thanks once again! I just noticed some important changes that we should address before merge.
try ( | ||
final InfluxDBContainer influxDBContainer = new InfluxDBContainer(InfluxDBTestUtils.INFLUXDB_V2_TEST_IMAGE) | ||
) { | ||
influxDBContainer | ||
.withUsername(USERNAME) | ||
.withPassword(PASSWORD) | ||
.withOrganization(ORG) | ||
.withBucket(BUCKET) | ||
.withRetention(RETENTION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try ( | |
final InfluxDBContainer influxDBContainer = new InfluxDBContainer(InfluxDBTestUtils.INFLUXDB_V2_TEST_IMAGE) | |
) { | |
influxDBContainer | |
.withUsername(USERNAME) | |
.withPassword(PASSWORD) | |
.withOrganization(ORG) | |
.withBucket(BUCKET) | |
.withRetention(RETENTION); | |
try ( | |
final InfluxDBContainer influxDBContainer = new InfluxDBContainer(InfluxDBTestUtils.INFLUXDB_V2_TEST_IMAGE) | |
.withUsername(USERNAME) | |
.withPassword(PASSWORD) | |
.withOrganization(ORG) | |
.withBucket(BUCKET) | |
.withRetention(RETENTION); | |
) { | |
docs/modules/databases/influxdb.md
Outdated
In the following example you will find a snippet to create an InfluxDB client using the official Java client: | ||
|
||
<!--codeinclude--> | ||
[InfluxDBTestUtils.getInfluxDBClient()](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestUtils.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about use the code that is required
docs/modules/databases/influxdb.md
Outdated
Running a `InfluxDBContainer` as a stand-in for InfluxDB in a test: | ||
|
||
<!--codeinclude--> | ||
[InfluxDBContainerV1Test](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerV1Test.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about use the code that is required
docs/modules/databases/influxdb.md
Outdated
In the following example you will find a snippet to create an InfluxDB client using the official Java client: | ||
|
||
<!--codeinclude--> | ||
[InfluxDBContainer.getNewInfluxDB()](../../../modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about use the code that is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the block here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
*/ | ||
public String getUrl() { | ||
return "http://" + getHost() + ":" + getLivenessCheckPort(); | ||
return "http://" + this.getHost() + ":" + this.getMappedPort(INFLUXDB_PORT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "http://" + this.getHost() + ":" + this.getMappedPort(INFLUXDB_PORT); | |
return "http://" + getHost() + ":" + getMappedPort(INFLUXDB_PORT); |
public InfluxDB getNewInfluxDB() { | ||
InfluxDB influxDB = InfluxDBFactory.connect(getUrl(), username, password); | ||
influxDB.setDatabase(database); | ||
final InfluxDB influxDB = InfluxDBFactory.connect(this.getUrl(), this.username, this.password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final InfluxDB influxDB = InfluxDBFactory.connect(this.getUrl(), this.username, this.password); | |
final InfluxDB influxDB = InfluxDBFactory.connect(getUrl(), this.username, this.password); |
*/ | ||
public class InfluxDBContainer<SELF extends InfluxDBContainer<SELF>> extends GenericContainer<SELF> { | ||
public class InfluxDBContainer extends GenericContainer<InfluxDBContainer> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for compatibility, we need to rollback this change. We can apply it again in version 2.x
this.isAtLeastMajorVersion2 = | ||
new ComparableVersion(dockerImageName.getVersionPart()).isGreaterThanOrEqualTo("2.0.0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddumelendez I think I would prefer your suggested approach. It is still not a super strong indicator for custom images, but I believe more explicit than the tag version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave it as is for now. I think we need to think about how to address them for custom images.
docs/modules/databases/influxdb.md
Outdated
Running a `InfluxDBContainer` as a stand-in for InfluxDB in a test: | ||
|
||
<!--codeinclude--> | ||
[InfluxDBContainerTest](../../../modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the whole test class is included in the docs. Use blocks in order to use only what is required. See https://github.com/testcontainers/testcontainers-java/blob/main/docs/modules/pulsar.md?plain=1#L11-L13 and https://github.com/testcontainers/testcontainers-java/blob/main/modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java#L32-L34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddumelendez Done!
…qaf/testcontainers-java into feature/influxdb-v2-test-container
@eddumelendez Thanks for the review! I added all of them! |
It's failing because of
You can reproduce it locally by running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for your patience @raminqaf ! I think we are just polishing the docs now and from my side LGTM.
modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java
Outdated
Show resolved
Hide resolved
modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBContainerTest.java
Outdated
Show resolved
Hide resolved
@eddumelendez I added all the reviews and the checkstyle checks! |
this.isAtLeastMajorVersion2 = | ||
new ComparableVersion(dockerImageName.getVersionPart()).isGreaterThanOrEqualTo("2.0.0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddumelendez I think I would prefer your suggested approach. It is still not a super strong indicator for custom images, but I believe more explicit than the tag version.
thank you so much for your contribution and all work you've done, @raminqaf ! This is now in |
This PR fixes #3670
Every item on this list will require judgement by the Testcontainers core maintainers. Exceptions will sometimes be possible; items with
should
are more likely to be negotiable than those items withmust
.Default docker image
latest
tags, and we do not use tags that may be mutated in the futureModule dependencies
compileOnly
if they are likely to already be on the classpath for users' tests (e.g. client libraries or drivers)implementation
(and thus transitive dependencies) if they are very unlikely to conflict with users' dependencies.API (e.g.
MyModuleContainer
class)compileOnly
dependencies. This is to reduce the risk of compatibility problems with future versions of third party libraries.Documentation