Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
using Datadog.Trace.Configuration;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
Expand All @@ -21,7 +22,8 @@ namespace Datadog.Trace.ClrProfiler.IntegrationTests
[Trait("RequiresDockerDependency", "true")]
[Trait("DockerGroup", "2")]
[UsesVerify]
public class AerospikeTests : TracingIntegrationTest, IClassFixture<AerospikeFixture>
[Collection(AerospikeCollection.Name)]
public class AerospikeTests : TracingIntegrationTest
{
public AerospikeTests(ITestOutputHelper output, AerospikeFixture aerospikeFixture)
: base("Aerospike", output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Datadog.Trace.ClrProfiler.IntegrationTests
{
public class CustomTestFramework : TestHelpers.AutoInstrumentation.DockerTestFramework
public class CustomTestFramework : TestHelpers.CustomTestFramework
{
public CustomTestFramework(IMessageSink messageSink)
: base(messageSink, typeof(Instrumentation))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />

<PackageReference Include="Testcontainers" Version="3.6.0" />
<PackageReference Include="Testcontainers" Version="4.11.0" />

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Collaborator Author

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.Dotnet to their own Docker.Dotnet.Enhanced which required the Newtonsoft.Json dependency

The other changes seemed quite small from what I found

<PackageReference Include="StrongNamer" Version="0.2.5" />
</ItemGroup>

Expand Down
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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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
Expand Up @@ -30,20 +30,19 @@ protected override async Task InitializeResources(Action<string, object> registe
// pinning to a known good version because the latest version
// (6.3.0.5 at time of issue) causes 'Server memory error' and flake
// Keep syncronized image version with docker-compose.yml
var container = new ContainerBuilder()
.WithImage("aerospike/aerospike-server:6.2.0.6")
var container = new ContainerBuilder("aerospike/aerospike-server:6.2.0.6")
.WithPortBinding(AerospikePort, true)
.WithCreateParameterModifier(p =>
{
p.HostConfig ??= new HostConfig();
p.HostConfig.Ulimits = new List<Ulimit>
{
p.HostConfig ??= new HostConfig();
p.HostConfig.Ulimits = new List<Ulimit>
{
// Aerospike requires a minimum of 15000 file descriptors, otherwise it'll fail to start
// Some versions of dockerengine set a lower limit (1024)
new Ulimit { Name = "nofile", Soft = 15000, Hard = 15000 }
};
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(AerospikePort))
})
.WithWaitStrategy(Wait.ForUnixContainer().UntilInternalTcpPortIsAvailable(AerospikePort))
.Build();

await container.StartAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmmm, as per the original PR:

Because fixtures are not singleton, the ContainersRegistry is used to store the objects across multiple fixtures.

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 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Realised that the original was using IClassFixture not IContainerFixture but still, we should prob check that they Are singletons in this case...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks I'll look into this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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>>();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="SharpPdb" Version="1.0.4" />
<PackageReference Include="Testcontainers" Version="3.6.0" />
<PackageReference Include="Testcontainers" Version="4.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down

This file was deleted.

Loading