Skip to content
Draft
Show file tree
Hide file tree
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
48 changes: 11 additions & 37 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ services:
ports:
- "3306"

postgres_arm64:
image: postgres:10.5-alpine
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
ports:
- "5432"

rabbitmq_arm64:
image: rabbitmq:3-management
command: rabbitmq-server
Expand Down Expand Up @@ -183,16 +174,6 @@ services:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"

postgres:
image: postgres:10.5-alpine
profiles: ["group1"]
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
ports:
- "127.0.0.1:5432:5432"

mysql:
image: mysql/mysql-server:8.0
profiles: ["group1"]
Expand Down Expand Up @@ -477,7 +458,6 @@ services:
- ELASTICSEARCH6_HOST=elasticsearch6:9200
- ELASTICSEARCH5_HOST=elasticsearch5:9200
- SQLSERVER_CONNECTION_STRING=Server=sqlserver;User=sa;Password=Strong!Passw0rd;TrustServerCertificate=true
- POSTGRES_HOST=postgres
- MYSQL_HOST=mysql
- MYSQL_PORT=3306
- MYSQL57_HOST=mysql57
Expand Down Expand Up @@ -689,7 +669,6 @@ services:
- stackexchangeredis-replica
- stackexchangeredis-single
- sqlserver
- postgres
- mysql
- mysql57
- rabbitmq
Expand All @@ -699,7 +678,7 @@ services:
- test-agent
environment:
- TIMEOUT_LENGTH=120
command: servicestackredis:6379 stackexchangeredis:6379 stackexchangeredis-replica:6379 stackexchangeredis-single:6379 sqlserver:1433 postgres:5432 mysql:3306 mysql57:3306 rabbitmq:5672 kafka-broker:9092 kafka-zookeeper:2181 couchbase:11210 test-agent:8126
command: servicestackredis:6379 stackexchangeredis:6379 stackexchangeredis-replica:6379 stackexchangeredis-single:6379 sqlserver:1433 mysql:3306 mysql57:3306 rabbitmq:5672 kafka-broker:9092 kafka-zookeeper:2181 couchbase:11210 test-agent:8126

StartDependencies.Group2:
image: andrewlock/wait-for-dependencies
Expand Down Expand Up @@ -729,6 +708,7 @@ services:
command: dotnet /build/bin/Debug/_build.dll RunIntegrationTests
volumes:
- ./:/project
- /var/run/docker.sock:/var/run/docker.sock
cap_add:
- SYS_PTRACE
environment:
Expand All @@ -754,7 +734,6 @@ services:
- ELASTICSEARCH6_HOST=elasticsearch7_arm64:9200
- ELASTICSEARCH5_HOST=elasticsearch7_arm64:9200
- SQLSERVER_CONNECTION_STRING=Server=sqledge_arm64;User=sa;Password=Strong!Passw0rd;TrustServerCertificate=true
- POSTGRES_HOST=postgres_arm64
- MYSQL_HOST=mysql_arm64
- MYSQL_PORT=3306
- RABBITMQ_HOST=rabbitmq_arm64
Expand Down Expand Up @@ -795,7 +774,6 @@ services:
- elasticsearch7_arm64
- sqledge_arm64
- mongo_arm64
- postgres_arm64
- mysql_arm64
- rabbitmq_arm64
- localstack_arm64
Expand All @@ -811,14 +789,13 @@ services:
- elasticsearch7_arm64
- sqledge_arm64
- mongo_arm64
- postgres_arm64
- mysql_arm64
- rabbitmq_arm64
- localstack_arm64
- test-agent
environment:
- TIMEOUT_LENGTH=120
command: servicestackredis_arm64:6379 stackexchangeredis_arm64:6379 stackexchangeredis_arm64-replica:6379 stackexchangeredis_arm64-single:6379 elasticsearch7_arm64:9200 sqledge_arm64:1433 mongo_arm64:27017 postgres_arm64:5432 mysql_arm64:3306 rabbitmq_arm64:5672 localstack_arm64:4566 test-agent:8126
command: servicestackredis_arm64:6379 stackexchangeredis_arm64:6379 stackexchangeredis_arm64-replica:6379 stackexchangeredis_arm64-single:6379 elasticsearch7_arm64:9200 sqledge_arm64:1433 mongo_arm64:27017 mysql_arm64:3306 rabbitmq_arm64:5672 localstack_arm64:4566 test-agent:8126

IntegrationTests.ARM64.Debugger:
build:
Expand All @@ -830,6 +807,7 @@ services:
command: dotnet /build/bin/Debug/_build.dll RunDebuggerIntegrationTests
volumes:
- ./:/project
- /var/run/docker.sock:/var/run/docker.sock
cap_add:
- SYS_PTRACE
environment:
Expand Down Expand Up @@ -1154,13 +1132,12 @@ services:
- elasticsearch7_osx_arm64
- sqledge_osx_arm64
- mongo_osx_arm64
- postgres_osx_arm64
- mysql_osx_arm64
- rabbitmq_osx_arm64
- localstack_osx_arm64
environment:
- TIMEOUT_LENGTH=120
command: servicestackredis_osx_arm64:6379 stackexchangeredis_osx_arm64:6379 stackexchangeredis_osx_arm64-replica:6379 stackexchangeredis_osx_arm64-single:6379 elasticsearch7_osx_arm64:9200 sqledge_osx_arm64:1433 mongo_osx_arm64:27017 postgres_osx_arm64:5432 mysql_osx_arm64:3306 rabbitmq_osx_arm64:5672 localstack_osx_arm64:4566
command: servicestackredis_osx_arm64:6379 stackexchangeredis_osx_arm64:6379 stackexchangeredis_osx_arm64-replica:6379 stackexchangeredis_osx_arm64-single:6379 elasticsearch7_osx_arm64:9200 sqledge_osx_arm64:1433 mongo_osx_arm64:27017 mysql_osx_arm64:3306 rabbitmq_osx_arm64:5672 localstack_osx_arm64:4566

# OSX ARM64 dependencies

Expand Down Expand Up @@ -1201,15 +1178,6 @@ services:
ports:
- "3306:3306"

postgres_osx_arm64:
image: postgres:10.5-alpine
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
ports:
- "5432:5432"

rabbitmq_osx_arm64:
image: rabbitmq:3-management
command: rabbitmq-server
Expand Down Expand Up @@ -1252,6 +1220,12 @@ services:
- ACCEPT_EULA=Y
- SA_PASSWORD=Strong!Passw0rd

### PRE PULL TEST CONTAINER IMAGES BELOW HERE TO GET THEM INTO THE VM TO MAKE IT GO FASTER ###

# keep syncronized image version with tracer\test\Datadog.Trace.TestHelpers.AutoInstrumentation\Containers\AerospikeFixture.cs
aerospike:
image: aerospike/aerospike-server:6.2.0.6

# keep syncronized image version with tracer\test\Datadog.Trace.TestHelpers.AutoInstrumentation\Containers\PostgresFixture.cs
postgres:
image: postgres:10.5-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@

using System.Threading.Tasks;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using Xunit;
using Xunit.Abstractions;

namespace Datadog.Trace.ClrProfiler.IntegrationTests.AdoNet
{
[Trait("RequiresDockerDependency", "true")]
[Trait("DockerGroup", "1")]
[Collection(PostgresCollection.Name)]
public class DapperTests : TracingIntegrationTest
{
public DapperTests(ITestOutputHelper output)
public DapperTests(ITestOutputHelper output, PostgresFixture postgresFixture)
: base("Dapper", output)
{
SetServiceVersion("1.0.0");
ConfigureContainers(postgresFixture);
}

// Assert Npgsql because the Dapper application uses Postgres for the actual client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
using Datadog.Trace.Configuration;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using FluentAssertions;
using VerifyXunit;
using Xunit;
Expand All @@ -20,13 +21,15 @@ namespace Datadog.Trace.ClrProfiler.IntegrationTests.AdoNet
{
[Trait("RequiresDockerDependency", "true")]
[Trait("DockerGroup", "1")]
[Collection(PostgresCollection.Name)]
[UsesVerify]
public class NpgsqlCommandTests : TracingIntegrationTest
{
public NpgsqlCommandTests(ITestOutputHelper output)
public NpgsqlCommandTests(ITestOutputHelper output, PostgresFixture postgresFixture)
: base("Npgsql", output)
{
SetServiceVersion("1.0.0");
ConfigureContainers(postgresFixture);
}

public override Result ValidateIntegrationSpan(MockSpan span, string metadataSchemaVersion) => span.IsNpgsql(metadataSchemaVersion);
Expand Down Expand Up @@ -78,7 +81,10 @@ public async Task SubmitsTraces(
var settings = VerifyHelper.GetSpanVerifierSettings();
settings.AddRegexScrubber(new Regex("Npgsql-Test-[a-zA-Z0-9]{32}"), "Npgsql-Test-GUID");
settings.AddSimpleScrubber("out.host: localhost", "out.host: postgres");
settings.AddSimpleScrubber("out.host: 127.0.0.1", "out.host: postgres");
settings.AddSimpleScrubber("out.host: postgres_arm64", "out.host: postgres");
// TestContainers uses Docker bridge IP (e.g., 172.17.0.1)
settings.AddRegexScrubber(new Regex(@"out\.host: \d+\.\d+\.\d+\.\d+"), "out.host: postgres");

var fileName = nameof(NpgsqlCommandTests);
#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ namespace Datadog.Trace.ClrProfiler.IntegrationTests
{
[Trait("RequiresDockerDependency", "true")]
[Trait("DockerGroup", "2")]
[Collection(AerospikeCollection.Name)]
[UsesVerify]
public class AerospikeTests : TracingIntegrationTest, IClassFixture<AerospikeFixture>
public class AerospikeTests : TracingIntegrationTest
{
public AerospikeTests(ITestOutputHelper output, AerospikeFixture aerospikeFixture)
: base("Aerospike", output)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// <copyright file="ContainersCollection.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using Xunit;

namespace Datadog.Trace.ClrProfiler.IntegrationTests;

/// <summary>
/// Collection definition for Postgres tests.
/// Using ICollectionFixture ensures that ONE PostgresFixture instance is shared across all test classes
/// in this collection. The container starts when the first test runs and stops when the last test finishes.
/// </summary>
[CollectionDefinition(Name)]
public class PostgresCollection : ICollectionFixture<PostgresFixture>
{
public const string Name = "Postgres";
}

/// <summary>
/// Collection definition for Aerospike tests.
/// Using ICollectionFixture ensures that ONE AerospikeFixture instance is shared across all test classes
/// in this collection. The container starts when the first test runs and stops when the last test finishes.
/// </summary>
#pragma warning disable SA1402 // File may only contain a single type
[CollectionDefinition(Name)]
public class AerospikeCollection : ICollectionFixture<AerospikeFixture>
{
public const string Name = "Aerospike";
}
#pragma warning restore SA1402 // File may only contain a single type
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// <copyright file="ContainersCollection.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using Xunit;

namespace Datadog.Trace.Security.IntegrationTests;

/// <summary>
/// Collection definition for Postgres tests.
/// Using ICollectionFixture ensures that ONE PostgresFixture instance is shared across all test classes
/// in this collection. The container starts when the first test runs and stops when the last test finishes.
/// </summary>
[CollectionDefinition(Name)]
public class PostgresCollection : ICollectionFixture<PostgresFixture>
{
public const string Name = "Postgres";
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Datadog.Trace.ClrProfiler.IntegrationTests;
using Datadog.Trace.Configuration;
using Datadog.Trace.Iast.Telemetry;
using Datadog.Trace.Security.IntegrationTests.IAST;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -653,6 +655,11 @@ protected override async Task TryStartApp()
public abstract class AspNetCore2IastTests : AspNetBase, IClassFixture<AspNetCoreTestFixture>
{
public AspNetCore2IastTests(AspNetCoreTestFixture fixture, ITestOutputHelper outputHelper, bool enableIast, string testName, bool? isIastDeduplicationEnabled = null, int? samplingRate = null, int? vulnerabilitiesPerRequest = null, bool? redactionEnabled = false, int iastTelemetryLevel = (int)IastMetricsVerbosityLevel.Off)
: this(fixture, null, outputHelper, enableIast, testName, isIastDeduplicationEnabled, samplingRate, vulnerabilitiesPerRequest, redactionEnabled, iastTelemetryLevel)
{
}

public AspNetCore2IastTests(AspNetCoreTestFixture fixture, PostgresFixture postgresFixture, ITestOutputHelper outputHelper, bool enableIast, string testName, bool? isIastDeduplicationEnabled = null, int? samplingRate = null, int? vulnerabilitiesPerRequest = null, bool? redactionEnabled = false, int iastTelemetryLevel = (int)IastMetricsVerbosityLevel.Off)
: base("AspNetCore2", outputHelper, "/shutdown", testName: testName)
{
Fixture = fixture;
Expand All @@ -664,6 +671,11 @@ public AspNetCore2IastTests(AspNetCoreTestFixture fixture, ITestOutputHelper out
SamplingRate = samplingRate;
IastTelemetryLevel = iastTelemetryLevel;
SetEnvironmentVariable(ConfigurationKeys.AppSec.StackTraceEnabled, "false");

if (postgresFixture != null)
{
ConfigureContainers(postgresFixture);
}
}

protected AspNetCoreTestFixture Fixture { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
using System.Threading.Tasks;
using Datadog.Trace.Security.IntegrationTests.Iast;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using Xunit;
using Xunit.Abstractions;

namespace Datadog.Trace.Security.IntegrationTests.IAST;

[Trait("RequiresDockerDependency", "true")]
[Collection(PostgresCollection.Name)]
public class AspNetCore5IastDbTests : AspNetCore5IastTests
{
public AspNetCore5IastDbTests(AspNetCoreTestFixture fixture, ITestOutputHelper outputHelper)
public AspNetCore5IastDbTests(AspNetCoreTestFixture fixture, PostgresFixture postgresFixture, ITestOutputHelper outputHelper)
: base(fixture, outputHelper, enableIast: true, testName: "AspNetCore5IastDbTestsIastEnabled", samplingRate: 100, vulnerabilitiesPerRequest: 200, isIastDeduplicationEnabled: false, sampleName: "AspNetCore5")
{
ConfigureContainers(postgresFixture);
}

[SkippableTheory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Datadog.Trace.Iast.Telemetry;
using Datadog.Trace.Security.IntegrationTests.IAST;
using Datadog.Trace.TestHelpers;
using Datadog.Trace.TestHelpers.AutoInstrumentation.Containers;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
Expand Down
Loading
Loading