From ab90a2d17f662e39b938308d0bae808ef0325f33 Mon Sep 17 00:00:00 2001 From: Kevin Gosse Date: Wed, 15 Jan 2025 17:09:13 +0100 Subject: [PATCH] Add wait strategy for aerospike (#6551) ## Summary of changes In `AerospikeFixture`, wait until the port 3000 is bound. ## Reason for change The fixture was initializing too quickly, before the aerospike instance was ready to receive requests. This caused random failures. --- .../Containers/AerospikeFixture.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/Containers/AerospikeFixture.cs b/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/Containers/AerospikeFixture.cs index d81373005019..7678a32f9c15 100644 --- a/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/Containers/AerospikeFixture.cs +++ b/tracer/test/Datadog.Trace.TestHelpers.AutoInstrumentation/Containers/AerospikeFixture.cs @@ -15,11 +15,13 @@ namespace Datadog.Trace.TestHelpers.AutoInstrumentation.Containers; public class AerospikeFixture : ContainerFixture { + private const int AerospikePort = 3000; + protected IContainer Container => GetResource("container"); public override IEnumerable> GetEnvironmentVariables() { - yield return new("AEROSPIKE_HOST", $"{Container.Hostname}:{Container.GetMappedPublicPort(3000)}"); + yield return new("AEROSPIKE_HOST", $"{Container.Hostname}:{Container.GetMappedPublicPort(AerospikePort)}"); } protected override async Task InitializeResources(Action registerResource) @@ -28,7 +30,8 @@ protected override async Task InitializeResources(Action registe // (6.3.0.5 at time of issue) causes 'Server memory error' and flake var container = new ContainerBuilder() .WithImage("aerospike/aerospike-server:6.2.0.6") - .WithPortBinding(3000, true) + .WithPortBinding(AerospikePort, true) + .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(AerospikePort)) .Build(); await container.StartAsync();