Skip to content
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

fix: Do not run reusable resource tests in parallel #1267

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

HofmeisterAn
Copy link
Collaborator

@HofmeisterAn HofmeisterAn commented Sep 20, 2024

What does this PR do?

This PR addresses a flaky unit test I noticed some time ago. The reusable resource tests (reuse feature) have been flaky, and today I discovered that they interfere with the port forwarding tests. When the port forwarding container is running, Testcontainers automatically injects the necessary extra hosts into the builder configuration using WithPortForwarding() internally. Depending on when the test framework starts the port forwarding container, these extra hosts can cause flakiness. This happens because the reuse hash may change during iterating and creating the container resource(s), resulting in two containers with the same label running instead of one.

I noticed the issue by looking into the actual container configurations and their hashes (see the JSON node ExtraHosts):

// ReuseHash=SwYoG2DcNHf2MEnMvH7tWLmN0Yw=
"RealObject": {
    "Image": {
        "Repository": "alpine",
        "Registry": null,
        "Tag": "3.17",
        "Digest": null,
        "FullName": "alpine:3.17",
        "Name": "alpine"
    },
    "Name": null,
    "Entrypoint": [
        "/bin/sh",
        "-c",
        "trap : TERM INT; sleep infinity \u0026 wait"
    ],
    "Command": [],
    "Environments": {},
    "ExposedPorts": {},
    "PortBindings": {},
    "NetworkAliases": [],
    "ExtraHosts": [],
    "Labels": {
        "71dd3cf7-1df3-4c53-8b9d-8890c93dca85": "7f90fea5-afc3-4e06-8a6a-77638d6640a8",
        "org.testcontainers": "true",
        "org.testcontainers.lang": "dotnet"
    }
}

// ReuseHash=yb7MflZnn0sD0kWz/eiVR/rC9Ao=
"RealObject": {
    "Image": {
        "Repository": "alpine",
        "Registry": null,
        "Tag": "3.17",
        "Digest": null,
        "FullName": "alpine:3.17",
        "Name": "alpine"
    },
    "Name": null,
    "Entrypoint": [
        "/bin/sh",
        "-c",
        "trap : TERM INT; sleep infinity \u0026 wait"
    ],
    "Command": [],
    "Environments": {},
    "ExposedPorts": {},
    "PortBindings": {},
    "NetworkAliases": [],
    "ExtraHosts": [
        "host.testcontainers.internal:172.17.0.14"
    ],
    "Labels": {
        "71dd3cf7-1df3-4c53-8b9d-8890c93dca85": "7f90fea5-afc3-4e06-8a6a-77638d6640a8",
        "org.testcontainers": "true",
        "org.testcontainers.lang": "dotnet"
    }
}

In addition to fixing this issue, the PR aligns two similar tests, now includes the stack trace of an exception in the log message and bumps the test dependencies to their latest version.

Why is it important?

This PR improves the stability and resilience of the CI pipeline and tests.

Related issues

-

@HofmeisterAn HofmeisterAn added chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups test flakiness A flaky test labels Sep 20, 2024
Copy link

netlify bot commented Sep 20, 2024

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 932c8e8
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/66ed97c190ea380008207ffa
😎 Deploy Preview https://deploy-preview-1267--testcontainers-dotnet.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 site configuration.

@HofmeisterAn HofmeisterAn merged commit 340a93a into develop Sep 20, 2024
14 checks passed
@HofmeisterAn HofmeisterAn deleted the bugfix/address-flaky-reuse-test branch September 20, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups test flakiness A flaky test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant