diff --git a/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-kafka.yml b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-kafka.yml new file mode 100644 index 0000000000..0ac67afbe7 --- /dev/null +++ b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-kafka.yml @@ -0,0 +1,71 @@ +version: "3" + +# The following must be set either in environment variables or via a .env file in the same folder as this file: +# +# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container +# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container +# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 7.0-bullseye-slim, 7.0-alpine, 7.0-jammy +# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64 +# PORT external port for the smoketest API +# CONTAINER_NAME The name for the container +# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8 +# DOTNET_VERSION The dotnet version number to use (7.0, 8.0, etc) +# TEST_DOCKERFILE The path and dockerfile to use for the service. +# +# and the usual suspects: +# NEW_RELIC_LICENSE_KEY +# NEW_RELIC_HOST +# NEW_RELIC_APP_NAME +# +# +# To build and run, execute `docker compose -f up` +# Alternatively, set COMPOSE_FILE environment variable to the path and omit the -f parameter + +services: + UbuntuX64Kafka1TestApp: + extends: + file: docker-compose-smoketestapp.yml + service: smoketestapp + depends_on: + - kafka-broker + environment: + - NEW_RELIC_KAFKA_TOPIC=${NEW_RELIC_KAFKA_TOPIC} + - NEW_RELIC_KAFKA_CONTAINER_NAME=${NEW_RELIC_KAFKA_CONTAINER_NAME} + + UbuntuX64Kafka2TestApp: + extends: + file: docker-compose-smoketestapp.yml + service: smoketestapp + depends_on: + - kafka-broker + environment: + - NEW_RELIC_KAFKA_TOPIC=${NEW_RELIC_KAFKA_TOPIC} + - NEW_RELIC_KAFKA_CONTAINER_NAME=${NEW_RELIC_KAFKA_CONTAINER_NAME} + + kafka-broker: + image: confluentinc/cp-kafka:7.5.0 +# container_name: ${NEW_RELIC_KAFKA_CONTAINER_NAME} + environment: + KAFKA_BROKER_ID: 1 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29092,PLAINTEXT_HOST://${NEW_RELIC_KAFKA_CONTAINER_NAME}:9092 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 + KAFKA_PROCESS_ROLES: broker,controller + KAFKA_NODE_ID: 1 + KAFKA_CONTROLLER_QUORUM_VOTERS: 1@${NEW_RELIC_KAFKA_CONTAINER_NAME}:29093 + KAFKA_LISTENERS: PLAINTEXT://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29092,CONTROLLER://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29093,PLAINTEXT_HOST://:9092 + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_LOG_DIRS: /tmp/kraft-combined-logs + CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk + + +networks: + default: + name: kafka-test-network + driver: bridge + driver_opts: + com.docker.network.bridge.enable_icc: "true" diff --git a/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-smoketestapp.yml b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-smoketestapp.yml new file mode 100644 index 0000000000..c7c71029e0 --- /dev/null +++ b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose-smoketestapp.yml @@ -0,0 +1,45 @@ +version: "3" + +# The following must be set either in environment variables or via a .env file in the same folder as this file: +# +# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container +# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container +# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 7.0-bullseye-slim, 7.0-alpine, 7.0-jammy +# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64 +# PORT external port for the smoketest API +# CONTAINER_NAME The name for the container +# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8 +# DOTNET_VERSION The dotnet version number to use (7.0, 8.0, etc) +# NETWORK_NAME The network name to use for containers in this app. Should be unique among all running instances. +# TEST_DOCKERFILE The path and dockerfile to use for the service. +# +# and the usual suspects: +# NEW_RELIC_LICENSE_KEY +# NEW_RELIC_HOST +# NEW_RELIC_APP_NAME +# +# +# To build and run, execute `docker compose -f up` +# Alternatively, set COMPOSE_FILE environment variable to the path and omit the -f parameter + +services: + smoketestapp: + container_name: ${CONTAINER_NAME} + image: ${CONTAINER_NAME} + platform: ${PLATFORM} + build: + context: . + dockerfile: ${TEST_DOCKERFILE} + args: + DISTRO_TAG: ${DISTRO_TAG} + TARGET_ARCH: ${TARGET_ARCH} + NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY} + NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME} + NEW_RELIC_HOST: ${NEW_RELIC_HOST} + DOTNET_VERSION: ${DOTNET_VERSION} + APP_DOTNET_VERSION: ${APP_DOTNET_VERSION} + ports: + - "${PORT}:80" + volumes: + - ${AGENT_PATH}:/usr/local/newrelic-dotnet-agent # AGENT_PATH from .env, points to newrelichome_linux_x64 + - ${LOG_PATH}:/app/logs # LOG_PATH from .env, should be a folder unique to this run of the smoketest app diff --git a/tests/Agent/IntegrationTests/ContainerApplications/docker-compose.yml b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose.yml index 384212fa19..6be4259ebd 100644 --- a/tests/Agent/IntegrationTests/ContainerApplications/docker-compose.yml +++ b/tests/Agent/IntegrationTests/ContainerApplications/docker-compose.yml @@ -23,101 +23,51 @@ version: "3" # Alternatively, set COMPOSE_FILE environment variable to the path and omit the -f parameter services: - smoketestapp: - container_name: ${CONTAINER_NAME} - image: ${CONTAINER_NAME} - platform: ${PLATFORM} - build: - context: . - dockerfile: ${TEST_DOCKERFILE} - args: - DISTRO_TAG: ${DISTRO_TAG} - TARGET_ARCH: ${TARGET_ARCH} - NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY} - NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME} - NEW_RELIC_HOST: ${NEW_RELIC_HOST} - DOTNET_VERSION: ${DOTNET_VERSION} - APP_DOTNET_VERSION: ${APP_DOTNET_VERSION} - ports: - - "${PORT}:80" - volumes: - - ${AGENT_PATH}:/usr/local/newrelic-dotnet-agent # AGENT_PATH from .env, points to newrelichome_linux_x64 - - ${LOG_PATH}:/app/logs # LOG_PATH from .env, should be a folder unique to this run of the smoketest app DebianX64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp UbuntuX64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp AlpineX64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp DebianArm64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp UbuntuArm64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp CentosX64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp build: dockerfile: SmokeTestApp/Dockerfile.centos CentosArm64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp build: dockerfile: SmokeTestApp/Dockerfile.centos AmazonX64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp build: dockerfile: SmokeTestApp/Dockerfile.amazon AmazonArm64SmokeTestApp: extends: + file: docker-compose-smoketestapp.yml service: smoketestapp build: dockerfile: SmokeTestApp/Dockerfile.centos - - UbuntuX64Kafka1TestApp: - extends: - service: smoketestapp - depends_on: - - kafka-broker - environment: - - NEW_RELIC_KAFKA_TOPIC=${NEW_RELIC_KAFKA_TOPIC} - - NEW_RELIC_KAFKA_CONTAINER_NAME=${NEW_RELIC_KAFKA_CONTAINER_NAME} - - UbuntuX64Kafka2TestApp: - extends: - service: smoketestapp - depends_on: - - kafka-broker - environment: - - NEW_RELIC_KAFKA_TOPIC=${NEW_RELIC_KAFKA_TOPIC} - - NEW_RELIC_KAFKA_CONTAINER_NAME=${NEW_RELIC_KAFKA_CONTAINER_NAME} - - kafka-broker: - image: confluentinc/cp-kafka:7.5.0 - container_name: ${NEW_RELIC_KAFKA_CONTAINER_NAME} - environment: - KAFKA_BROKER_ID: 1 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29092,PLAINTEXT_HOST://${NEW_RELIC_KAFKA_CONTAINER_NAME}:9092 - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 - KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 - KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 - KAFKA_PROCESS_ROLES: broker,controller - KAFKA_NODE_ID: 1 - KAFKA_CONTROLLER_QUORUM_VOTERS: 1@${NEW_RELIC_KAFKA_CONTAINER_NAME}:29093 - KAFKA_LISTENERS: PLAINTEXT://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29092,CONTROLLER://${NEW_RELIC_KAFKA_CONTAINER_NAME}:29093,PLAINTEXT_HOST://:9092 - KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT - KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER - KAFKA_LOG_DIRS: /tmp/kraft-combined-logs - CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk - - + networks: default: name: ${NETWORK_NAME} diff --git a/tests/Agent/IntegrationTests/ContainerIntegrationTests.sln b/tests/Agent/IntegrationTests/ContainerIntegrationTests.sln index bd86b65855..5c5b8c7024 100644 --- a/tests/Agent/IntegrationTests/ContainerIntegrationTests.sln +++ b/tests/Agent/IntegrationTests/ContainerIntegrationTests.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewRelic.Api.Agent", "..\.. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_docker", "_docker", "{FB10922F-3CC6-4497-AF53-DF6808380258}" ProjectSection(SolutionItems) = preProject + ContainerApplications\docker-compose-kafka.yml = ContainerApplications\docker-compose-kafka.yml + ContainerApplications\docker-compose-smoketestapp.yml = ContainerApplications\docker-compose-smoketestapp.yml ContainerApplications\docker-compose.yml = ContainerApplications\docker-compose.yml EndProjectSection EndProject diff --git a/tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerFixtures/ContainerApplication.cs b/tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerFixtures/ContainerApplication.cs index 6eaf9a8363..a12b5dcfc8 100644 --- a/tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerFixtures/ContainerApplication.cs +++ b/tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerFixtures/ContainerApplication.cs @@ -16,6 +16,7 @@ namespace NewRelic.Agent.ContainerIntegrationTests.ContainerFixtures; public class ContainerApplication : RemoteApplication { private readonly string _dockerfile; + private readonly string _dockerComposeFile; private readonly string _dotnetVersion; private readonly string _distroTag; private readonly string _targetArch; @@ -36,13 +37,16 @@ protected override string SourceApplicationDirectoryPath } } - public ContainerApplication(string applicationDirectoryName, string distroTag, Architecture containerArchitecture, string dotnetVersion, string dockerfile) : base(applicationType: ApplicationType.Container, isCoreApp: true) + public ContainerApplication(string applicationDirectoryName, string distroTag, Architecture containerArchitecture, + string dotnetVersion, string dockerfile, string dockerComposeFile = "docker-compose.yml") : base(applicationType: ApplicationType.Container, isCoreApp: true) { ApplicationDirectoryName = applicationDirectoryName; _dockerComposeServiceName = applicationDirectoryName; _distroTag = distroTag; _dotnetVersion = dotnetVersion; _dockerfile = dockerfile; + _dockerComposeFile = dockerComposeFile; + DockerDependencies = new List(); switch (containerArchitecture) @@ -75,7 +79,7 @@ public override void Start(string commandLineArguments, Dictionary { @@ -113,7 +113,7 @@ internal static string GenerateTopic() } } -[Collection("Sequential")] +//[Collection("Sequential")] public class UbuntuX64Kafka1Test : LinuxKafkaTest { public UbuntuX64Kafka1Test(UbuntuX64Kafka1TestFixture fixture, ITestOutputHelper output) : base(fixture, output) @@ -121,7 +121,7 @@ public UbuntuX64Kafka1Test(UbuntuX64Kafka1TestFixture fixture, ITestOutputHelper } } -[Collection("Sequential")] +//[Collection("Sequential")] public class UbuntuX64Kafka2Test : LinuxKafkaTest { public UbuntuX64Kafka2Test(UbuntuX64Kafka2TestFixture fixture, ITestOutputHelper output) : base(fixture, output)