Skip to content

Conversation

@mdodsworth
Copy link
Contributor

Tried to follow the java implementation on features and version support.

@netlify
Copy link

netlify bot commented Sep 9, 2025

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit 592a948
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-node/deploys/68bfae8c9f28710008b1c593
😎 Deploy Preview https://deploy-preview-1130--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mdodsworth mdodsworth mentioned this pull request Sep 9, 2025
@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Sep 17, 2025
@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Sep 17, 2025

},
"devDependencies": {
"@influxdata/influxdb-client": "^1.35.0",
"axios": "^1.7.9"
Copy link
Collaborator

@cristianrgreco cristianrgreco Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now use node's built-in HTTP client in the core and other modules, let's do the same here so we don't add a lot of unnecessary dependencies

Comment on lines +11 to +15
afterEach(async () => {
if (container) {
await container.stop();
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use Typescript's await using syntax so the container is automatically stopped after each test

constructor(image: string) {
super(image);
// Determine version from image tag (default to v2 if unknown)
this.isVersion2 = this.isInfluxDB2(this.imageName.tag ?? "latest");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?? "latest" is not needed, the ImageName constructor will automatically set the tag to latest if one is not provided


public override async start(): Promise<StartedInfluxDBContainer> {
// Re-evaluate version based on the final image tag
this.isVersion2 = this.isInfluxDB2(this.imageName.tag ?? "latest");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need to be re-evaluated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. Will remove


private isInfluxDB2(tag: string): boolean {
if (tag === "latest") {
return true; // Assume latest is v2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this module work for InfluxDB v3? If so I'd change the naming of this logic to be either v1 or > v1, instead of v1 or v2 or ...

Comment on lines +152 to +157
// Parse version number
const versionMatch = tag.match(/^(\d+)(?:\.(\d+))?/);
if (versionMatch) {
const majorVersion = parseInt(versionMatch[1], 10);
return majorVersion >= 2;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the compare-versions library which we use in other modules for this, e.g.

if (satisfies(this.imageName.tag, "<7.4.0")) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a quick check and it looks like compare-versions doesn't handle non-semver tags like 1.8-alpine (it throws).


describe("compare-versions non-semver handling", () => {
  it("should throw when provided a non-semver InfluxDB 1.x tag", () => {
    expect(() => satisfies("1.8-alpine", ">=2.0.0")).toThrow(/Invalid argument/);
  });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristianrgreco giving this a bump.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mdodsworth I didn't realise this was blocking the other changes.

Good catch! Then yes please the implementation as it is


return `${this.getUrl()}?${params.toString()}`;
} else {
// InfluxDB 1.x connection string format
Copy link
Collaborator

@cristianrgreco cristianrgreco Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it would be better to have an InfluxDBContainer interface, and have v1 and vX implementations instead of almost every method having an if/else. Perhaps for the future, maybe if v3 also has incompatibilities

@cristianrgreco cristianrgreco added the changes requested PR author must respond to review feedback label Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested PR author must respond to review feedback enhancement New feature or request minor Backward compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants