Skip to content

Commit

Permalink
chore(ci): Modify aws integration tests to run in vdev (vectordotdev#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
bruceg and spencergilbert authored Feb 3, 2023
1 parent 7166280 commit 0171719
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 110 deletions.
20 changes: 0 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*

Expand Down
2 changes: 1 addition & 1 deletion scripts/integration/aws/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/integration/aws/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 0 additions & 72 deletions scripts/integration/docker-compose.aws.yml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/integration/docker-logs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ args:
- "::docker_logs::"

runner:
needs_docker_sock: true
needs_docker_socket: true

matrix:
default: ["default"]
2 changes: 1 addition & 1 deletion scripts/integration/fluent/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ args:
- "::fluent::"

runner:
needs_docker_sock: true
needs_docker_socket: true
volumes:
/tmp: /tmp

Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/integration/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/testing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub struct IntegrationRunnerConfig {
pub volumes: BTreeMap<String, String>,
/// 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 {
Expand Down
3 changes: 2 additions & 1 deletion vdev/src/testing/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _};
Expand Down Expand Up @@ -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);
}
Expand Down
22 changes: 11 additions & 11 deletions vdev/src/testing/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const UPSTREAM_IMAGE: &str =
pub static CONTAINER_TOOL: Lazy<OsString> =
Lazy::new(|| env::var_os("CONTAINER_TOOL").unwrap_or_else(detect_container_tool));

pub static DOCKER_SOCK: Lazy<PathBuf> = Lazy::new(detect_docker_sock);
pub(super) static DOCKER_SOCKET: Lazy<PathBuf> = Lazy::new(detect_docker_socket);

fn detect_container_tool() -> OsString {
for tool in ["docker", "podman"] {
Expand Down Expand Up @@ -85,7 +85,7 @@ pub trait ContainerTestRunner: TestRunner {

fn network_name(&self) -> Option<String>;

fn needs_docker_sock(&self) -> bool;
fn needs_docker_socket(&self) -> bool;

fn volumes(&self) -> Vec<String>;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -298,7 +298,7 @@ where

pub struct IntegrationTestRunner {
integration: String,
needs_docker_sock: bool,
needs_docker_socket: bool,
needs_network: bool,
volumes: Vec<String>,
}
Expand All @@ -311,7 +311,7 @@ impl IntegrationTestRunner {
) -> Result<Self> {
Ok(Self {
integration,
needs_docker_sock: config.needs_docker_sock,
needs_docker_socket: config.needs_docker_socket,
needs_network,
volumes: config
.volumes
Expand Down Expand Up @@ -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<String> {
Expand All @@ -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
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0171719

Please sign in to comment.