-
Notifications
You must be signed in to change notification settings - Fork 166
Update Testcontainers to v4 and migrate to ICollectionFixture #8350
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // <copyright file="ContainersCollection.cs" company="Datadog"> | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
| // </copyright> | ||
| #pragma warning disable SA1649 // File name should match first type name (this will just store all the classes) | ||
| #pragma warning disable SA1402 // File may only contain a single type (this will just store all the classes) | ||
| using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers; | ||
| using Xunit; | ||
|
|
||
| namespace Datadog.Trace.ClrProfiler.IntegrationTests.Helpers | ||
| { | ||
| [CollectionDefinition(Name)] | ||
|
|
||
| public class AerospikeCollection : ICollectionFixture<AerospikeFixture> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels... weird 😅 I hate the loosey-goosey ness of this wiring up. But that's just xunit for you 🤷♂️ |
||
| { | ||
| public const string Name = "Aerospike"; | ||
| } | ||
| } | ||
|
|
||
| #pragma warning restore SA1649 // File name should match first type name | ||
| #pragma warning restore SA1402 // File may only contain a single type | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,28 @@ public abstract class ContainerFixture : IAsyncLifetime | |
|
|
||
| public async Task InitializeAsync() | ||
| { | ||
| _resources = await ContainersRegistry.GetOrAdd(GetType(), InitializeResources); | ||
| _resources = await InitializeResources().ConfigureAwait(false); | ||
| } | ||
|
|
||
| // Do not implement, the ContainersRegistry is responsible for disposing the containers | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, as per the original PR:
that seems like it would still be an issue? 🤔 Should we just make sure to call Dispose on the registry from the custom test helper before it shuts down? 🤔 FWIW, leaving the containers running may have been intentional, for faster inner-loop dev 😄
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realised that the original was using
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks I'll look into this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay from what I can tell running it locally with this and with my other PRs #8353 and #8430 it seems to be the case that they are all singletons I think leaving the containers running was intentional I guess that is something that we could come back to if it proves to be beneficial in the future, I guess it matches our current behavior in CI and local dev where the containers are spun up and left running |
||
| public Task DisposeAsync() => Task.CompletedTask; | ||
| public async Task DisposeAsync() | ||
| { | ||
| if (_resources is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| foreach (var resource in _resources.Values) | ||
| { | ||
| if (resource is IAsyncDisposable asyncDisposable) | ||
| { | ||
| await asyncDisposable.DisposeAsync().ConfigureAwait(false); | ||
| } | ||
| else if (resource is IDisposable disposable) | ||
| { | ||
| disposable.Dispose(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public virtual IEnumerable<KeyValuePair<string, string>> GetEnvironmentVariables() => Enumerable.Empty<KeyValuePair<string, string>>(); | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any breaking changes we actually care about out of interest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest one that I noticed was that they appeared to go from
Docker.Dotnetto their ownDocker.Dotnet.Enhancedwhich required theNewtonsoft.JsondependencyThe other changes seemed quite small from what I found