Skip to content

Comments

Migrates Consul tests to use Testcontainers#9707

Merged
ReubenBond merged 2 commits intodotnet:mainfrom
Meir017:tests/consul-test-containers
Feb 15, 2026
Merged

Migrates Consul tests to use Testcontainers#9707
ReubenBond merged 2 commits intodotnet:mainfrom
Meir017:tests/consul-test-containers

Conversation

@Meir017
Copy link
Contributor

@Meir017 Meir017 commented Oct 5, 2025

just saw #9701 and realized we can further simplify the tests by using testcontainers

Replaces manual Docker container management in CI workflows with Testcontainers library for better test isolation and reliability.

Removes hardcoded Consul setup from GitHub Actions workflow and updates test utilities to programmatically manage container lifecycle.

Updates Testcontainers dependency to latest version for improved compatibility.

no setup on my machine, tests just work -
image

Microsoft Reviewers: Open in CodeFlow

@Meir017
Copy link
Contributor Author

Meir017 commented Oct 26, 2025

@ReubenBond I think the two github-actions that failed are unstable, all actions passed

@ReubenBond
Copy link
Member

@Meir017 they look like Consul failures, based on the output:

Error: System.TypeInitializationException : The type initializer for 'Consul.Tests.ConsulTestUtils' threw an exception.
---- DotNet.Testcontainers.Builders.DockerUnavailableException : Docker is either not running or misconfigured. Please ensure that Docker is running and that the endpoint is properly configured.
You can customize your configuration using either the environment variables or the ~/.testcontainers.properties file.
For more information, visit: [https://dotnet.testcontainers.org/custom_configuration/.](https://dotnet.testcontainers.org/custom_configuration/)
  Details: 
    Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.
    Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.
-------- System.AggregateException : One or more errors occurred. (Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.) (Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.)
------------ DotNet.Testcontainers.Builders.DockerUnavailableException : Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.
---------------- System.Net.Http.HttpRequestException : Connection failed.
-------------------- System.Net.Sockets.SocketException : Can't assign requested address
------------ DotNet.Testcontainers.Builders.DockerUnavailableException : Failed to connect to Docker endpoint at 'unix:///var/run/docker.sock'.
---------------- System.Net.Http.HttpRequestException : Connection failed.
--------  Skipped ------------ System.Net.Sockets.SocketException : Can't assign requested address

@Meir017
Copy link
Contributor Author

Meir017 commented Oct 26, 2025

hmm, wer'e getting the error

Error: System.AggregateException : One or more errors occurred. (Docker API responded with status code=BadRequest, response={"message":"invalid CapAdd: unknown capability: \"CAP_IPC_LOCK\""}

seems to be related to this https://github.com/testcontainers/testcontainers-dotnet/blob/4a72cb31f51206eb9f5d710fc6621650fdab89ee/src/Testcontainers.Consul/ConsulBuilder.cs#L50C27-L50C28

I'll check this out

Copilot AI review requested due to automatic review settings February 15, 2026 05:35
@ReubenBond ReubenBond force-pushed the tests/consul-test-containers branch from be841ae to c45c6b3 Compare February 15, 2026 05:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the Consul provider test setup from CI-managed Docker containers to an in-test Testcontainers-managed Consul instance, aiming to improve isolation and make Consul tests run without manual local setup.

Changes:

  • Introduces a Testcontainers-based Consul lifecycle in ConsulTestUtils and derives the connection string from the running container.
  • Adds Testcontainers.Consul as a test dependency via central package management.
  • Removes the explicit Consul docker run/cleanup steps and related env var wiring from the CI workflow.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/Extensions/Consul.Tests/ConsulTestUtils.cs Starts a Consul Testcontainer and exposes its base address to tests.
test/Extensions/Consul.Tests/Consul.Tests.csproj Adds the Testcontainers.Consul package reference to the Consul test project.
Directory.Packages.props Centralizes the Testcontainers.Consul package version.
.github/workflows/ci.yml Removes manual Consul container management from the Consul CI job.

@ReubenBond ReubenBond force-pushed the tests/consul-test-containers branch from c39c8c8 to a7e9b09 Compare February 15, 2026 17:19
@ReubenBond ReubenBond enabled auto-merge February 15, 2026 17:20
Meir017 and others added 2 commits February 15, 2026 13:49
Replaces manual Docker container management in CI workflows with Testcontainers library for better test isolation and reliability.

Removes hardcoded Consul setup from GitHub Actions workflow and updates test utilities to programmatically manage container lifecycle.

Updates Testcontainers dependency to latest version for improved compatibility.
Normalize Consul testcontainer capability override to IPC_LOCK and exclude Consul from the core Functional suite so it runs only in the dedicated Consul provider job.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond force-pushed the tests/consul-test-containers branch from a7e9b09 to 82aff6c Compare February 15, 2026 21:49
@ReubenBond ReubenBond added this pull request to the merge queue Feb 15, 2026
Merged via the queue into dotnet:main with commit 969fae1 Feb 15, 2026
59 checks passed
@Meir017 Meir017 deleted the tests/consul-test-containers branch February 16, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants