Skip to content

Commit

Permalink
Add wait strategy for aerospike (#6551)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
kevingosse authored Jan 15, 2025
1 parent a700b56 commit ab90a2d
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ namespace Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;

public class AerospikeFixture : ContainerFixture
{
private const int AerospikePort = 3000;

protected IContainer Container => GetResource<IContainer>("container");

public override IEnumerable<KeyValuePair<string, string>> 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<string, object> registerResource)
Expand All @@ -28,7 +30,8 @@ protected override async Task InitializeResources(Action<string, object> 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();
Expand Down

0 comments on commit ab90a2d

Please sign in to comment.