From 0171719a6c1e4eee1866d8007f281c5364f35ccb Mon Sep 17 00:00:00 2001 From: Bruce Guenter Date: Fri, 3 Feb 2023 15:02:53 -0600 Subject: [PATCH] chore(ci): Modify aws integration tests to run in vdev (#16277) * fix ec2 and ecs tests * Pass in $DOCKER_SOCKET to compose runner * Remove AWS integration sub-tests, we can't selectively run tests yet Co-authored-by: Spencer Gilbert --- Makefile | 20 ------ scripts/integration/aws/compose.yaml | 2 +- scripts/integration/aws/test.yaml | 2 +- scripts/integration/docker-compose.aws.yml | 72 ---------------------- scripts/integration/docker-logs/test.yaml | 2 +- scripts/integration/fluent/test.yaml | 2 +- vdev/src/commands/integration/show.rs | 2 +- vdev/src/testing/config.rs | 2 +- vdev/src/testing/integration.rs | 3 +- vdev/src/testing/runner.rs | 22 +++---- 10 files changed, 19 insertions(+), 110 deletions(-) delete mode 100644 scripts/integration/docker-compose.aws.yml diff --git a/Makefile b/Makefile index db39d8cb2ac4b..abbabf0dc8094 100644 --- a/Makefile +++ b/Makefile @@ -338,26 +338,6 @@ test-integration: test-integration-nginx test-integration-opentelemetry test-int test-integration: test-integration-redis test-integration-splunk test-integration-dnstap test-integration-datadog-agent test-integration-datadog-logs test-integration: test-integration-datadog-traces test-integration-shutdown -.PHONY: test-integration-aws-s3 -test-integration-aws-s3: ## Runs AWS S3 integration tests - FILTER=::aws_s3 make test-integration-aws - -.PHONY: test-integration-aws-sqs -test-integration-aws-sqs: ## Runs AWS SQS integration tests - FILTER=::aws_sqs make test-integration-aws - -.PHONY: test-integration-aws-cloudwatch-logs -test-integration-aws-cloudwatch-logs: ## Runs AWS Cloudwatch Logs integration tests - FILTER=::aws_cloudwatch_logs make test-integration-aws - -.PHONY: test-integration-aws-cloudwatch-metrics -test-integration-aws-cloudwatch-metrics: ## Runs AWS Cloudwatch Metrics integration tests - FILTER=::aws_cloudwatch_metrics make test-integration-aws - -.PHONY: test-integration-aws-kinesis -test-integration-aws-kinesis: ## Runs AWS Kinesis integration tests - FILTER=::aws_kinesis make test-integration-aws - test-integration-%-cleanup: cargo vdev --verbose integration stop $* diff --git a/scripts/integration/aws/compose.yaml b/scripts/integration/aws/compose.yaml index b3d5bc5f70e27..41f72695c4a01 100644 --- a/scripts/integration/aws/compose.yaml +++ b/scripts/integration/aws/compose.yaml @@ -12,7 +12,7 @@ services: mock-ecs: image: docker.io/amazon/amazon-ecs-local-container-endpoints:latest volumes: - - /var/run/docker.sock:/var/run/docker.sock + - $DOCKER_SOCKET:/var/run/docker.sock - $HOME/.aws/:/home/.aws/ networks: diff --git a/scripts/integration/aws/test.yaml b/scripts/integration/aws/test.yaml index ea1e9e785b2f1..cf4ca04e9a434 100644 --- a/scripts/integration/aws/test.yaml +++ b/scripts/integration/aws/test.yaml @@ -8,7 +8,7 @@ env: AWS_ACCESS_KEY_ID: dummy AWS_SECRET_ACCESS_KEY: dummy CLOUDWATCH_ADDRESS: http://mock-localstack:4566 - EC2_METADATA_ADDRESS: http://mock-ec2-metadata:8111 + EC2_METADATA_ADDRESS: http://mock-ec2-metadata:1338 ECS_ADDRESS: http://mock-ecs ELASTICSEARCH_ADDRESS: http://mock-localstack:4571 KINESIS_ADDRESS: http://mock-localstack:4566 diff --git a/scripts/integration/docker-compose.aws.yml b/scripts/integration/docker-compose.aws.yml deleted file mode 100644 index 674aa73a1fd2c..0000000000000 --- a/scripts/integration/docker-compose.aws.yml +++ /dev/null @@ -1,72 +0,0 @@ -version: "3" - -services: - mock-ec2-metadata: - image: public.ecr.aws/aws-ec2/amazon-ec2-metadata-mock:v1.11.2 - networks: - - backend - mock-localstack: - image: docker.io/localstack/localstack-full:0.11.6 - environment: - - SERVICES=kinesis,s3,cloudwatch,elasticsearch,es,firehose,sqs - networks: - - backend - mock-watchlogs: - image: docker.io/luciofranco/mockwatchlogs:latest - networks: - - backend - mock-ecs: - image: docker.io/amazon/amazon-ecs-local-container-endpoints:latest - networks: - - backend - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - $HOME/.aws/:/home/.aws/ - runner: - build: - context: ${PWD} - dockerfile: scripts/integration/Dockerfile - args: - - RUST_VERSION=${RUST_VERSION} - working_dir: /code - command: - - "cargo" - - "nextest" - - "run" - - "--no-fail-fast" - - "--no-default-features" - - "--features" - - "aws-integration-tests" - - "--lib" - - "${FILTER:-::aws_}" - depends_on: - - mock-ec2-metadata - - mock-localstack - - mock-watchlogs - - mock-ecs - environment: - - AWS_ACCESS_KEY_ID=dummy - - AWS_SECRET_ACCESS_KEY=dummy - - CLOUDWATCH_ADDRESS=http://mock-localstack:4566 - - EC2_METADATA_ADDRESS=http://mock-ec2-metadata:1338 - - ECS_ADDRESS=http://mock-ecs - - KINESIS_ADDRESS=http://mock-localstack:4566 - - ELASTICSEARCH_ADDRESS=http://mock-localstack:4571 - - S3_ADDRESS=http://mock-localstack:4566 - - SQS_ADDRESS=http://mock-localstack:4566 - - WATCHLOGS_ADDRESS=http://mock-watchlogs:6000 - networks: - - backend - volumes: - - ${PWD}:/code - - target:/code/target - - cargogit:/usr/local/cargo/git - - cargoregistry:/usr/local/cargo/registry - -networks: - backend: {} - -volumes: - target: {} - cargogit: {} - cargoregistry: {} diff --git a/scripts/integration/docker-logs/test.yaml b/scripts/integration/docker-logs/test.yaml index aa47354554159..46d85865f9e77 100644 --- a/scripts/integration/docker-logs/test.yaml +++ b/scripts/integration/docker-logs/test.yaml @@ -5,7 +5,7 @@ args: - "::docker_logs::" runner: - needs_docker_sock: true + needs_docker_socket: true matrix: default: ["default"] diff --git a/scripts/integration/fluent/test.yaml b/scripts/integration/fluent/test.yaml index 291b49def0373..d0add51d563c1 100644 --- a/scripts/integration/fluent/test.yaml +++ b/scripts/integration/fluent/test.yaml @@ -5,7 +5,7 @@ args: - "::fluent::" runner: - needs_docker_sock: true + needs_docker_socket: true volumes: /tmp: /tmp diff --git a/vdev/src/commands/integration/show.rs b/vdev/src/commands/integration/show.rs index 4f9bac8374124..2d83a33c82a1e 100644 --- a/vdev/src/commands/integration/show.rs +++ b/vdev/src/commands/integration/show.rs @@ -53,7 +53,7 @@ impl Cli { println!(" {target} => {mount}"); } } - println!(" Needs docker socket: {}", config.runner.needs_docker_sock); + println!(" Needs docker socket: {}", config.runner.needs_docker_socket); println!("Environments:"); for environment in config.environments().keys() { diff --git a/vdev/src/testing/config.rs b/vdev/src/testing/config.rs index cedb630b85e9d..fdff9fd0ff547 100644 --- a/vdev/src/testing/config.rs +++ b/vdev/src/testing/config.rs @@ -85,7 +85,7 @@ pub struct IntegrationRunnerConfig { pub volumes: BTreeMap, /// Does the test runner need access to the host's docker socket? #[serde(default)] - pub needs_docker_sock: bool, + pub needs_docker_socket: bool, } impl IntegrationTestConfig { diff --git a/vdev/src/testing/integration.rs b/vdev/src/testing/integration.rs index a80d68548313d..4cfd4be6be352 100644 --- a/vdev/src/testing/integration.rs +++ b/vdev/src/testing/integration.rs @@ -4,7 +4,7 @@ use anyhow::{bail, Context, Result}; use super::config::{Environment, IntegrationTestConfig, RustToolchainConfig}; use super::runner::{ - ContainerTestRunner as _, IntegrationTestRunner, TestRunner as _, CONTAINER_TOOL, + ContainerTestRunner as _, IntegrationTestRunner, TestRunner as _, CONTAINER_TOOL, DOCKER_SOCKET, }; use super::state::EnvsDir; use crate::app::{self, CommandExt as _}; @@ -188,6 +188,7 @@ impl IntegrationTest { command.current_dir(&self.test_dir); + command.env("DOCKER_SOCKET", &*DOCKER_SOCKET); if let Some(network_name) = self.runner.network_name() { command.env(NETWORK_ENV_VAR, network_name); } diff --git a/vdev/src/testing/runner.rs b/vdev/src/testing/runner.rs index 3ad708a472a77..c2b5d6e691c78 100644 --- a/vdev/src/testing/runner.rs +++ b/vdev/src/testing/runner.rs @@ -30,7 +30,7 @@ const UPSTREAM_IMAGE: &str = pub static CONTAINER_TOOL: Lazy = Lazy::new(|| env::var_os("CONTAINER_TOOL").unwrap_or_else(detect_container_tool)); -pub static DOCKER_SOCK: Lazy = Lazy::new(detect_docker_sock); +pub(super) static DOCKER_SOCKET: Lazy = Lazy::new(detect_docker_socket); fn detect_container_tool() -> OsString { for tool in ["docker", "podman"] { @@ -85,7 +85,7 @@ pub trait ContainerTestRunner: TestRunner { fn network_name(&self) -> Option; - fn needs_docker_sock(&self) -> bool; + fn needs_docker_socket(&self) -> bool; fn volumes(&self) -> Vec; @@ -216,10 +216,10 @@ pub trait ContainerTestRunner: TestRunner { let network_name = self.network_name(); let network_name = network_name.as_deref().unwrap_or("host"); - let docker_sock = format!("{}:/var/run/docker.sock", DOCKER_SOCK.display()); + let docker_socket = format!("{}:/var/run/docker.sock", DOCKER_SOCKET.display()); let docker_args = self - .needs_docker_sock() - .then(|| vec!["--volume", &docker_sock]) + .needs_docker_socket() + .then(|| vec!["--volume", &docker_socket]) .unwrap_or_default(); let volumes = self.volumes(); @@ -298,7 +298,7 @@ where pub struct IntegrationTestRunner { integration: String, - needs_docker_sock: bool, + needs_docker_socket: bool, needs_network: bool, volumes: Vec, } @@ -311,7 +311,7 @@ impl IntegrationTestRunner { ) -> Result { Ok(Self { integration, - needs_docker_sock: config.needs_docker_sock, + needs_docker_socket: config.needs_docker_socket, needs_network, volumes: config .volumes @@ -358,8 +358,8 @@ impl ContainerTestRunner for IntegrationTestRunner { format!("{}:latest", self.container_name()) } - fn needs_docker_sock(&self) -> bool { - self.needs_docker_sock + fn needs_docker_socket(&self) -> bool { + self.needs_docker_socket } fn volumes(&self) -> Vec { @@ -382,7 +382,7 @@ impl ContainerTestRunner for DockerTestRunner { env::var("ENVIRONMENT_UPSTREAM").unwrap_or_else(|_| UPSTREAM_IMAGE.to_string()) } - fn needs_docker_sock(&self) -> bool { + fn needs_docker_socket(&self) -> bool { false } @@ -419,7 +419,7 @@ impl TestRunner for LocalTestRunner { } } -fn detect_docker_sock() -> PathBuf { +fn detect_docker_socket() -> PathBuf { match env::var_os("DOCKER_HOST") { Some(host) => host .into_string()