public LoadDriver(IDockerNetwork network, NamingConvention namingConvention, TestConfig testConfig)
    {
        _network = network ?? throw new ArgumentNullException(nameof(network));
        if (namingConvention == null)
        {
            throw new ArgumentNullException(nameof(namingConvention));
        }
        if (testConfig == null)
        {
            throw new ArgumentNullException(nameof(testConfig));
        }

        _logStream    = File.Create(Path.Combine(namingConvention.ContainerLogs, "k6.txt"));
        _resultStream = File.Create(Path.Combine(namingConvention.AgentResults, K6ResultsFile));

        _hostScriptPath = Path.Combine(Directory.GetCurrentDirectory(), "K6", "basic.js");
        _container      = new TestcontainersBuilder <TestcontainersContainer>()
                          .WithImage(LoadDriveImageName)
                          .WithName($"{OverheadTest.Prefix}-k6-load")
                          .WithNetwork(_network)
                          .WithCommand("run",
                                       "-u", testConfig.ConcurrentConnections.ToString(),
                                       "-e", $"ESHOP_HOSTNAME={EshopApp.ContainerName}",
                                       "-i", testConfig.Iterations.ToString(),
                                       "--rps", testConfig.MaxRequestRate.ToString(),
                                       ContainerScriptPath,
                                       "--summary-export", ContainerResultsPath)
                          .WithBindMount(_hostScriptPath, ContainerScriptPath)
                          .WithOutputConsumer(Consume.RedirectStdoutAndStderrToStream(_logStream, _logStream))
                          .Build();
    }
Beispiel #2
0
    public LocalCollector(IDockerNetwork network, DirectoryInfo iterationResults) : base(iterationResults)
    {
        var hostCollectorConfigPath = Path.Combine(Directory.GetCurrentDirectory(), CollectorConfigPath);

        Container = new TestcontainersBuilder <TestcontainersContainer>()
                    .WithImage(ImageName)
                    .WithName(Address)
                    .WithNetwork(network)
                    .WithBindMount(hostCollectorConfigPath, ContainerCollectorConfigPath)
                    .WithOutputConsumer(Consume.RedirectStdoutAndStderrToStream(Stream, Stream))
                    .Build();
    }
 public LocalSqlServer(IDockerNetwork network, NamingConvention namingConvention) : base(
         namingConvention)
 {
     Container = new TestcontainersBuilder <TestcontainersContainer>()
                 .WithImage(ImageName)
                 .WithName(Address)
                 .WithNetwork(network ?? throw new ArgumentNullException(nameof(network)))
                 .WithEnvironment("ACCEPT_EULA", "Y")
                 .WithEnvironment("SA_PASSWORD", TestPassword)
                 .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(Port))
                 .WithOutputConsumer(Consume.RedirectStdoutAndStderrToStream(Stream, Stream))
                 .Build();
 }
    public OverheadTest(ITestOutputHelper testOutputHelper)
    {
        TestcontainersSettings.ResourceReaperEnabled = false;
        _testOutputHelper = testOutputHelper;

        var iterationResults = Path.Combine(Directory.GetCurrentDirectory(), "results",
                                            DateTime.UtcNow.ToString("yyyyMMddHHmmss"));

        // Creates directory for results specific to this run
        _iterationResults = Directory.CreateDirectory(iterationResults);

        _network   = BuildDefaultNetwork();
        _collector = CreateCollector(_iterationResults);
    }
Beispiel #5
0
    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();
    }
        /// <inheritdoc cref="ITestcontainersBuilder{TDockerContainer}" />
        public ITestcontainersBuilder <TDockerContainer> WithNetwork(IDockerNetwork dockerNetwork)
        {
            var networks = new[] { dockerNetwork };

            return(this.MergeNewConfiguration(new TestcontainersConfiguration(networks: networks)));
        }