Skip to content
Merged
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
@@ -1,5 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.

using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;
using DotNet.Testcontainers.Containers;
using Microsoft.SemanticKernel.Connectors.MongoDB;
using MongoDB.Bson;
using MongoDB.Driver;
Expand Down Expand Up @@ -44,6 +47,7 @@ private async Task<MongoClientSettings> StartMongoDbContainerAsync()
{
this._container = new MongoDbBuilder()
.WithImage("mongodb/mongodb-atlas-local:7.0.6")
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new MongoDbWaitUntil()))
.Build();

using CancellationTokenSource cts = new();
Expand Down Expand Up @@ -79,4 +83,16 @@ protected override async Task StopAsync()
this._container = null;
}
}

private sealed class MongoDbWaitUntil : IWaitUntil
{
/// <inheritdoc />
public async Task<bool> UntilAsync(IContainer container)
{
var (stdout, _) = await container.GetLogsAsync(timestampsEnabled: false)
.ConfigureAwait(false);

return stdout.Contains("\"msg\":\"Waiting for connections\"");
}
}
}
Loading