Skip to content

chore: Replace Testcontainers generic container with DynamoDB module #294

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

Closed
wants to merge 1 commit into from
Closed

chore: Replace Testcontainers generic container with DynamoDB module #294

wants to merge 1 commit into from

Conversation

HofmeisterAn
Copy link

Issue number: -

Summary

Changes

The pull request replaces the Testcontainers' generic container with the official DynamoDB module configuration. This change contains a couple of best practices and leverages the async operations with xUnit.net's IAsyncLifetime interface for starting and stopping the container. Instead of using the synchronously blocking member Wait(), the pull request uses the await keyword, following the Task-based Asynchronous Pattern (TAP).

User experience

The tests work the same, but the code is much cleaner now. It follows the best practices and recommendations.

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@auto-assign auto-assign bot requested a review from hjgraca June 10, 2023 19:32
@github-actions github-actions bot added the internal Maintenance changes label Jun 10, 2023
@github-actions
Copy link

No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.

@github-actions github-actions bot added do-not-merge PRs that are blocked for varying reasons need-issue PR is missing a related issue for tracking change labels Jun 10, 2023
@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: -0.15 ⚠️

Comparison is base (dba5e90) 69.09% compared to head (a59281c) 68.94%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #294      +/-   ##
===========================================
- Coverage    69.09%   68.94%   -0.15%     
===========================================
  Files           79       79              
  Lines         3433     3433              
===========================================
- Hits          2372     2367       -5     
- Misses        1061     1066       +5     
Flag Coverage Δ
unittests 68.94% <ø> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hjgraca
Copy link
Contributor

hjgraca commented Jun 23, 2023

@HofmeisterAn thanks for opening the pull request. After some tests, this configuration fails to work properly on a non docker host environment (colima).

Docker.DotNet.DockerContainerNotFoundException: Docker API responded with status code=NotFound, response={"message":"No such container: d268d87c9a9908...

Docker.DotNet.DockerContainerNotFoundException
Docker API responded with status code=NotFound, response={"message":"No such container: d268d87c9a9908c9720ff33e5d79aef3a43ce2dcca3c5d6ec62080faee2d9769"}

   at Docker.DotNet.ContainerOperations.<>c.<.cctor>b__30_0(HttpStatusCode statusCode, String responseBody)
   at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers)
   at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token)
   at Docker.DotNet.ContainerOperations.InspectContainerAsync(String id, CancellationToken cancellationToken)
   at DotNet.Testcontainers.Containers.DockerContainer.<>c__DisplayClass57_0.<<UnsafeStartAsync>g__CheckPortBindingsAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at DotNet.Testcontainers.Configurations.WaitStrategy.<>c__DisplayClass1_0.<<WaitUntilAsync>g__UntilAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
   at DotNet.Testcontainers.Configurations.WaitStrategy.WaitUntilAsync(Func`1 wait, TimeSpan frequency, TimeSpan timeout, CancellationToken ct)
   at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStartAsync(CancellationToken ct)
   at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct)
   at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct)
   at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct)
   at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartDefaultAsync(IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, Boolean isWindowsEngineEnabled, CancellationToken ct)
   at DotNet.Testcontainers.Clients.TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct)
   at DotNet.Testcontainers.Containers.DockerContainer.UnsafeCreateAsync(CancellationToken ct)
   at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct)
   at AWS.Lambda.Powertools.Idempotency.Tests.Persistence.DynamoDbFixture.InitializeAsync() in /Users/henrigra/work/aws-lambda-powertools-dotnet/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/DynamoDBFixture.cs:line 41
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 96



-----

System.NullReferenceException
Object reference not set to an instance of an object.
   at AWS.Lambda.Powertools.Idempotency.Tests.Persistence.DynamoDbFixture.Dispose() in /Users/henrigra/work/aws-lambda-powertools-dotnet/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Persistence/DynamoDBFixture.cs:line 86
   at Xunit.Sdk.ExceptionAggregator.Run(Action code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 79

@hjgraca
Copy link
Contributor

hjgraca commented Jun 23, 2023

Closing this pull request. Something we can review on the future but for now the current approach is working fine for us and this new approach is not working as expected.

@hjgraca hjgraca closed this Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/idempotency do-not-merge PRs that are blocked for varying reasons internal Maintenance changes need-issue PR is missing a related issue for tracking change tests
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants