public LocalStackFixture(IOptions <LocalStackOptions> options, Amazon.Extensions.NETCore.Setup.AWSOptions awsOptions) { var localStackBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage("localstack/localstack") .WithCleanUp(true) .WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole()) .WithEnvironment("DEFAULT_REGION", "eu-central-1") .WithEnvironment("SERVICES", "s3") .WithEnvironment("DOCKER_HOST", "unix:///var/run/docker.sock") .WithEnvironment("DEBUG", "1") .WithPortBinding(4566, 4566); if (awsOptions != null) { if (awsOptions.Credentials != null) { var awsCreds = awsOptions.Credentials.GetCredentials(); localStackBuilder.WithEnvironment("AWS_ACCESS_KEY_ID", awsCreds.AccessKey) .WithEnvironment("AWS_SECRET_ACCESS_KEY", awsCreds.SecretKey); } } _localStackContainer = localStackBuilder.Build(); this.options = options; }
public EshopApp(IDockerNetwork network, CollectorBase collector, SqlServerBase sqlServer, NamingConvention namingConvention, AgentConfig config) { if (network == null) { throw new ArgumentNullException(nameof(network)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (sqlServer == null) { throw new ArgumentNullException(nameof(sqlServer)); } if (namingConvention == null) { throw new ArgumentNullException(nameof(namingConvention)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } _logStream = File.Create(Path.Combine(namingConvention.ContainerLogs, "eshop-app.txt")); _resultStream = File.Create(Path.Combine(namingConvention.AgentResults, CounterResultsFile)); var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage(config.DockerImageName) .WithName(ContainerName) .WithNetwork(network) .WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development") .WithEnvironment("SIGNALFX_ENDPOINT_URL", collector.TraceReceiverUrl) .WithEnvironment("SIGNALFX_PROFILER_LOGS_ENDPOINT", collector.LogsReceiverUrl) .WithEnvironment("ConnectionStrings__CatalogConnection", sqlServer.CatalogConnection) .WithEnvironment("ConnectionStrings__IdentityConnection", sqlServer.IdentityConnection) .WithEnvironment("Logging__LogLevel__Microsoft", "Warning") .WithEnvironment("Logging__LogLevel__Default", "Warning") .WithEnvironment("Logging__LogLevel__System", "Warning") .WithEnvironment("Logging__LogLevel__Microsoft.Hosting.Lifetime", "Information") .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(AppPort)) .WithOutputConsumer(Consume.RedirectStdoutAndStderrToStream(_logStream, _logStream)); foreach (var envVar in config.AdditionalEnvVars) { testcontainersBuilder = testcontainersBuilder.WithEnvironment(envVar.Name, envVar.Value); } _container = testcontainersBuilder.Build(); }