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

Added HTTP Wait Strategry #700

Closed
wants to merge 3 commits into from
Closed

Conversation

alfkonee
Copy link

@alfkonee alfkonee commented Dec 2, 2022

What does this PR do?

Add an HttpWait Strategy to help wait and Validate HTTP Requests

Why is it important?

Helping to Bring Feature Parity with testcontainers-java

How to test this PR

to Test I'd recommend a simple nginx container setup with the wait strategy setup like so

var nginx =new TestcontainersBuilder<TestcontainersContainer>()
                .WithImage("nginx:latest")
                .WithExposedPort(80)
                .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpSucceed())
                .Build();
await nginx.StartAsync();
await nginx.StopAsync();

@netlify
Copy link

netlify bot commented Dec 2, 2022

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 4758d4e
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/63898031a102490009a483f2
😎 Deploy Preview https://deploy-preview-700--testcontainers-dotnet.netlify.app/api/wait_strategies
📱 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 settings.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution to OSS and Testcontainers for .NET. We recommend to discuss changes in advance in our main contributing guidelines.

Having an HTTP wait strategy in Testcontainers for .NET would be great. Considering the implementation in Java, I would like to advocate an implementation that follows the Java design. I suggest to split the PR into smaller chunks:

  1. Adding a simple builder (MVP) that constructs the HTTP request (using .NET types; probably most can be done with HttpRequestMessage, Uri and UriBuilder).
  2. Adding a HTTP wait strategy that sends (invokes) the HTTP request and checks the HTTP status code.
  3. Following by a design that checks different HTTP responses.

I would like to avoid any timeout or retry logics in the first implementation. By design we use a CancellationToken to cancel the start up. Timeout and retry logics should be something we support for all wait strategies in the future.

@HofmeisterAn
Copy link
Collaborator

I will close this in favor of #717. I've added you as a co-author. Thanks for your contribution.

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