Skip to content

Conversation

mdelapenya
Copy link
Member

@mdelapenya mdelapenya commented May 26, 2025

  • chore: deprecate GenericContainer
  • chore: migrate tests to Run
  • docs: update quickstart
  • chore: update more tests
  • chore: update more tests
  • chore(aerospike): use Run function
  • chore(socat): use Run function
  • chore: update more tests
  • chore: update tests in the wait package
  • chore: use Run in the network package
  • chore: move test to the network package
  • chore: use Run in the core
  • chore(nginx): use Run in nginx example
  • chore(modulegen): use testcontainers.Run
  • chore(azurite): use testcontainers.Run
  • break(artemis): use testcontainers.Run
  • break(eventhubs): use testcontainers.Run
  • break(arangodb): use testcontainers.Run
  • break(servicebus): use testcontainers.Run
  • chore(cassandra): use testcontainers.Run
  • chore(chroma): use testcontainers.Run
  • break(clickhouse): use testcontainers.Run
  • chore(consul): use testcontainers.Run
  • chore(couchbase): use testcontainers.Run
  • break(databend): use testcontainers.Run
  • chore(dind): use testcontainers.Run
  • break(dolt): use testcontainers.Run
  • break(dynamodb): use testcontainers.Run
  • chore(etcd): use testcontainers.Run
  • break(etcd): make options return errors
  • chore(gcloud): use testcontainers.Run in deprecated constructors
  • chore(bigquery): use testcontainers.Run
  • chore(bigtable): use testcontainers.Run
  • chore(datastore): use testcontainers.Run
  • chore(firestore): use testcontainers.Run
  • chore(pubsub): use testcontainers.Run
  • chore(spanner): use testcontainers.Run
  • chore(graafanalgtm): use testcontainers.Run
  • chore(inbucket): use testcontainers.Run
  • chore(influxdb): use testcontainers.Run
  • chore(k3s): use testcontainers.Run
  • chore(k6): use testcontainers.Run
  • break(kafka): use testcontainers.Run
  • chore(localstack): use testcontainers.Run
  • break(mariadb): use testcontainers.Run
  • break(meilisearch): use testcontainers.Run
  • chore(memcached): use testcontainers.Run
  • chore(milvus): use testcontainers.Run
  • break(minio): use testcontainers.Run
  • chore(mockserver): use testcontainers.Run
  • break(mongodb): use testcontainers.Run
  • docs(dockermodelrunner): fix comment
  • break(mssql): use testcontainers.Run
  • docs(mssql): describe MSSQL issue with negative certificates
  • chore(mssql): bump images to address the negative serial number of the certificate
  • break(mysql): use testcontainers.Run
  • break(nats): use testcontainers.Run
  • chore(neo4j): use testcontainers.Run
  • chore(openfga): use testcontainers.Run
  • break(openldap): use testcontainers.Run
  • chore(pinecone): use testcontainers.Run
  • break(postgres): use testcontainers.Run
  • chore(pulsar): use testcontainers.Run
  • chore(qdrant): use testcontainers.Run
  • break(rabbitmq): use testcontainers.Run
  • chore(rabbitmq): consistency in credentials as env vars
  • chore(redis): use testcontainers.Run
  • break(redpanda): use testcontainers.Run
  • chore(registry): use testcontainers.Run
  • chore(scylladb): use testcontainers.Run
  • fixup socat
  • chore(surrealdb): use testcontainers.Run
  • fixup socat
  • chore(toxiproxy): use testcontainers.Run
  • chore(valkey): use testcontainers.Run
  • chore(vault): use testcontainers.Run
  • chore(vearch): use testcontainers.Run
  • chore(weaviate): use testcontainers.Run
  • break(yugabyte): use testcontainers.Run
  • chore(opensearch): use testcontainers.Run

What does this PR do?

It applies the recently added testcontainers.Run function in the core and in all the modules, deprecating the usage of the GenericContainer exposed function.

For that, we needed to review all the modules, and:

  1. define an slice of moduleOptions representing the values in the original container request
  2. append all the passed-in options from the module's Run function to the moduleOpts slice
  3. check if the module consumed values from the container request to fill any state in the container: e.g. reading env vars from the container request's Env field.
  • if yes: look for an options.go file in the module with all the options, verifying there is not options struct, and a custom Option type representing the module's own customisation types. If that struct and the Option type existed, we added a map[string]string for the env vars, changing all the existing options that could set env vars into the container request, into an Option type writing the passed-in values to the new env field in the options. Why? Because with this new approach, the module has no access to the container request within the scope of the Run method, so we need to change the functional opts and read those env vars from the options instead. The module's Run function now has to loop through the passed-in options and apply its own options.
  • if no, proceed
  1. remove the code to process the core options (e.g. testcontainers.WithEnv), as they are processed internally in the testcontainers.Run function.
  2. if the module needed a change to read from the internal options, append a new option to the moduleOptions.

The result is that the testcontainers.Run function receives a slice of core options.

This is considered a breaking change, as for those modules where we changed the existing options to the new custom type, the function signature changed. In practice, users that simply passed the options to the Run function has nothing to change, but we acknowledge that there could be users that are assigning these options to a variable, and here they will receive the breaking change. This could happen mostly in tests and test tables.

Apart from this, we noticed that several modules had their internal Option type not returning errors, which was not consistent for our pattern to validate the options. Given this PR is already a BC for many modules, we took the chance to update those modules' options to return error, causing another breaking change.

The first commit in this PR is deprecating the GenericContainer function, so consumer would need to update to the Run function whenever possible. Their lint process should warn them at build/CI time.

Modules that receive a Breaking Change

  • ArangoDB
  • Artemis
  • Azure: eventhubs, servicebus
  • Clickhouse
  • Databend
  • Dolt
  • DynamoDB
  • Etcd
  • Kafka
  • MariaDB
  • Meilisearch
  • Minio
  • MongoDB
  • MSSQL
  • MySQL
  • NATS
  • OpenLDAP
  • Postgres
  • RabbitMQ
  • Redpanda
  • Yugabyte

Why is it important?

testcontainers.GenericContainer has been an important function in the library since the beginning, but we consider that having testcontainers.Run is much more idiomatic to the operations we want to do, which is no other than running a container. Also, it pairs with the docker run command.

With the addition of functional options for all the container request fields, we consider it's now possible to even deprecate the struct, move it to an internal package in the library, and always customise containers through the functional options APIs.

mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 9, 2025
This commit migrates the valkey module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Use entrypoint for valkey-server process and WithCmd/WithCmdArgs for arguments
- Simplify WithConfigFile to prepend config file as first argument
- Simplify WithLogLevel and WithSnapshotting to use WithCmdArgs directly
- Process custom options before building module options for TLS support
- Update option tests to reflect entrypoint-based approach

Ref: testcontainers#3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 9, 2025
This commit migrates the vearch module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithExposedPorts, WithCmd, WithHostConfigModifier, WithFiles, WithWaitStrategy

Ref: testcontainers#3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 9, 2025
This commit migrates the weaviate module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithCmd, WithExposedPorts, WithEnv, WithWaitStrategy
- Multiple wait strategies for HTTP and gRPC ports

Tests: 7 tests, 78.6% coverage

Ref: testcontainers#3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mdelapenya added a commit that referenced this pull request Oct 9, 2025
This commit migrates the vearch module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithExposedPorts, WithCmd, WithHostConfigModifier, WithFiles, WithWaitStrategy

Ref: #3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 9, 2025
This commit migrates the vault module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithExposedPorts, WithHostConfigModifier, WithWaitStrategy, WithEnv
- WithToken uses WithEnv for setting root token env vars
- WithInitCommand uses WithAdditionalWaitStrategy to append exec wait

Tests: 10 tests, 89.5% coverage

Ref: testcontainers#3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 9, 2025
This commit migrates the yugabytedb module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithCmd, WithWaitStrategy, WithExposedPorts, WithEnv
- Use Inspect after Run to retrieve actual env var values after user customizations
- Multiple wait strategies for logs and listening ports

Tests: 9 tests, 93.0% coverage

Ref: testcontainers#3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mdelapenya added a commit that referenced this pull request Oct 9, 2025
This commit migrates the weaviate module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithCmd, WithExposedPorts, WithEnv, WithWaitStrategy
- Multiple wait strategies for HTTP and gRPC ports

Tests: 7 tests, 78.6% coverage

Ref: #3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
mdelapenya added a commit that referenced this pull request Oct 9, 2025
This commit migrates the yugabytedb module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithCmd, WithWaitStrategy, WithExposedPorts, WithEnv
- Use Inspect after Run to retrieve actual env var values after user customizations
- Multiple wait strategies for logs and listening ports

Tests: 9 tests, 93.0% coverage

Ref: #3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
mdelapenya added a commit that referenced this pull request Oct 9, 2025
* chore(valkey): use Run function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore(valkey): use Run function

This commit migrates the valkey module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Use entrypoint for valkey-server process and WithCmd/WithCmdArgs for arguments
- Simplify WithConfigFile to prepend config file as first argument
- Simplify WithLogLevel and WithSnapshotting to use WithCmdArgs directly
- Process custom options before building module options for TLS support
- Update option tests to reflect entrypoint-based approach

Ref: #3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: reduce file permissions

---------

Co-authored-by: Claude <noreply@anthropic.com>
mdelapenya added a commit that referenced this pull request Oct 9, 2025
This commit migrates the vault module to use the new testcontainers.Run() API.

The main changes are:
- Use testcontainers.Run() instead of testcontainers.GenericContainer()
- Convert to moduleOpts pattern with functional options
- Use WithExposedPorts, WithHostConfigModifier, WithWaitStrategy, WithEnv
- WithToken uses WithEnv for setting root token env vars
- WithInitCommand uses WithAdditionalWaitStrategy to append exec wait

Tests: 10 tests, 89.5% coverage

Ref: #3174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Causing compatibility issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants