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

feat(mongodb): Wait for mongodb module with a replicaset to finish #2777

Merged
merged 5 commits into from
Sep 17, 2024

Conversation

smgt
Copy link
Contributor

@smgt smgt commented Sep 11, 2024

What does this PR do?

This will add a test for writing to the mongodb module replica set so we can catch the error (NotWritablePrimary) not primary. It also adds a new wait strategy when using mongodb.WithReplicaSet() that waits for replica set status to be available.

Why is it important?

We get flaky tests in our CI (seems to be present on slow hardware) and they fail sometimes since we try to write to a mongodb container which isn't ready.

How to test this PR

There are tests added to test for this error. Tests will randomly fail when the wait strategy in WithReplicaSet is removed.

@smgt smgt requested a review from a team as a code owner September 11, 2024 09:04
Copy link

netlify bot commented Sep 11, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 91b844c
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66e9a4be6f1e6c0008dfd5c5
😎 Deploy Preview https://deploy-preview-2777--testcontainers-go.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.

@smgt smgt changed the title Wait for mongodb module with a replicaset to finish [bug] Wait for mongodb module with a replicaset to finish Sep 11, 2024
@smgt smgt changed the title [bug] Wait for mongodb module with a replicaset to finish Wait for mongodb module with a replicaset to finish Sep 11, 2024
@mdelapenya
Copy link
Member

@smgt thanks for this PR, much appreciated! We merged yesterday a PR enforcing the usage of testify's require across modules. Could you please resolve conflicts? I'll be more than happy to review it once it's there.

Thanks in advance

modules/mongodb/mongodb.go Outdated Show resolved Hide resolved
@smgt smgt force-pushed the fix-mongodb-replicaset-wait branch from 6106a6c to ab6e670 Compare September 17, 2024 12:18
@smgt
Copy link
Contributor Author

smgt commented Sep 17, 2024

@mdelapenya

I've updated the PR now so it uses testify's require module.

Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Waiting for the CI to pass for merging it.

Great job!

@mdelapenya mdelapenya self-assigned this Sep 17, 2024
@mdelapenya mdelapenya changed the title Wait for mongodb module with a replicaset to finish feat(mongodb): Wait for mongodb module with a replicaset to finish Sep 17, 2024
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Sep 17, 2024
@mdelapenya mdelapenya merged commit e2bd70f into testcontainers:main Sep 17, 2024
112 checks passed
mdelapenya added a commit that referenced this pull request Sep 20, 2024
* main:
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 23, 2024
* main:
  chore: use a much smaller image for testing (testcontainers#2795)
  fix: parallel containers clean race (testcontainers#2790)
  fix(registry): wait for (testcontainers#2793)
  fix: container timeout test (testcontainers#2792)
  docs: document redpanda options (testcontainers#2789)
  feat: support databend module (testcontainers#2779)
  chore: golangci-lint 1.61.0 (testcontainers#2787)
  fix(mssql): bump Docker image version (testcontainers#2786)
  fix: handle 127 error code for podman compatibility (testcontainers#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (testcontainers#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (testcontainers#2777)
  fix(postgres): Apply default snapshot name if no name specified (testcontainers#2783)
  fix: resource clean up for tests and examples (testcontainers#2738)
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 23, 2024
* main:
  chore: use a much smaller image for testing (testcontainers#2795)
  fix: parallel containers clean race (testcontainers#2790)
  fix(registry): wait for (testcontainers#2793)
  fix: container timeout test (testcontainers#2792)
  docs: document redpanda options (testcontainers#2789)
  feat: support databend module (testcontainers#2779)
  chore: golangci-lint 1.61.0 (testcontainers#2787)
  fix(mssql): bump Docker image version (testcontainers#2786)
  fix: handle 127 error code for podman compatibility (testcontainers#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (testcontainers#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (testcontainers#2777)
  fix(postgres): Apply default snapshot name if no name specified (testcontainers#2783)
  fix: resource clean up for tests and examples (testcontainers#2738)
mdelapenya added a commit that referenced this pull request Sep 26, 2024
* main: (29 commits)
  fix: template for code generation (#2800)
  fix: update module path (#2797)
  fix: container logging deadlocks (#2791)
  chore: use a much smaller image for testing (#2795)
  fix: parallel containers clean race (#2790)
  fix(registry): wait for (#2793)
  fix: container timeout test (#2792)
  docs: document redpanda options (#2789)
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
  fix: resource clean up for tests and examples (#2738)
  ci: add generate for mocks (#2774)
  fix: docker config error handling when config file does not exist (#2772)
  docs: refine heading badges in README (#2770)
  feat(wait): for file (#2731)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants