From 2e0de1f829adf6e54a83dd238f0050495b60339d Mon Sep 17 00:00:00 2001 From: Jonathan Padilla <44036128+jonathanpv@users.noreply.github.com> Date: Thu, 2 Mar 2023 00:00:15 -0500 Subject: [PATCH] chore(vdev): Regularize vdev integration test arguments to cargo (#16652) * set up test fields and yaml configuration changes * add fields to IntegrationTestConfig and append them to args * modify config files and implement PR feedback * add message to show test args is empty * use unwrap adapter * cargo vdev fmt * shorten comment documenting logic * fix clippy * change splunk and databend configs * add test args to show command, append test_filter to cargo * implement PR feedback, don't append empty string to args --- scripts/integration/amqp/test.yaml | 7 +++---- scripts/integration/aws/test.yaml | 7 +++---- scripts/integration/axiom/test.yaml | 7 +++---- scripts/integration/azure/test.yaml | 7 +++---- scripts/integration/chronicle/test.yaml | 7 +++---- scripts/integration/clickhouse/test.yaml | 7 +++---- scripts/integration/databend/test.yaml | 7 +++---- scripts/integration/datadog-agent/test.yaml | 7 +++---- scripts/integration/datadog-logs/test.yaml | 7 +++---- scripts/integration/datadog-metrics/test.yaml | 7 +++---- scripts/integration/datadog-traces/test.yaml | 7 +++---- scripts/integration/dnstap/test.yaml | 7 +++---- scripts/integration/docker-logs/test.yaml | 7 +++---- scripts/integration/elasticsearch/test.yaml | 7 +++---- scripts/integration/eventstoredb/test.yaml | 7 +++---- scripts/integration/fluent/test.yaml | 7 +++---- scripts/integration/gcp/test.yaml | 7 +++---- scripts/integration/http-client/test.yaml | 7 +++---- scripts/integration/humio/test.yaml | 7 +++---- scripts/integration/influxdb/test.yaml | 7 +++---- scripts/integration/kafka/test.yaml | 7 +++---- scripts/integration/logstash/test.yaml | 7 +++---- scripts/integration/loki/test.yaml | 7 +++---- scripts/integration/mongodb/test.yaml | 7 +++---- scripts/integration/nats/test.yaml | 7 +++---- scripts/integration/nginx/test.yaml | 7 +++---- scripts/integration/opentelemetry/test.yaml | 7 +++---- scripts/integration/postgres/test.yaml | 7 +++---- scripts/integration/prometheus/test.yaml | 7 +++---- scripts/integration/pulsar/test.yaml | 7 +++---- scripts/integration/redis/test.yaml | 7 +++---- scripts/integration/shutdown/test.yaml | 9 +++++---- scripts/integration/splunk/test.yaml | 7 +++---- vdev/src/commands/integration/show.rs | 14 ++++++++++++- vdev/src/testing/config.rs | 8 +++++++- vdev/src/testing/integration.rs | 20 ++++++++++++++++++- 36 files changed, 140 insertions(+), 135 deletions(-) diff --git a/scripts/integration/amqp/test.yaml b/scripts/integration/amqp/test.yaml index 895b71521332e..5f13537f896c0 100644 --- a/scripts/integration/amqp/test.yaml +++ b/scripts/integration/amqp/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - amqp-integration-tests -- --lib -- '::amqp::' + +test_filter: '::amqp::' matrix: version: ['3.8'] diff --git a/scripts/integration/aws/test.yaml b/scripts/integration/aws/test.yaml index cf4ca04e9a434..424e6d90c85e9 100644 --- a/scripts/integration/aws/test.yaml +++ b/scripts/integration/aws/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - aws-integration-tests -- --lib -- ::aws_ + +test_filter: ::aws_ env: AWS_ACCESS_KEY_ID: dummy diff --git a/scripts/integration/axiom/test.yaml b/scripts/integration/axiom/test.yaml index 8728af4a24497..59bd599e4a92e 100644 --- a/scripts/integration/axiom/test.yaml +++ b/scripts/integration/axiom/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - axiom-integration-tests -- --lib -- '::axiom::' + +test_filter: '::axiom::' runner: env: diff --git a/scripts/integration/azure/test.yaml b/scripts/integration/azure/test.yaml index 79be707103520..f871b052747ae 100644 --- a/scripts/integration/azure/test.yaml +++ b/scripts/integration/azure/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - azure-integration-tests -- --lib -- ::azure_ + +test_filter: ::azure_ env: AZURE_ADDRESS: local-azure-blob diff --git a/scripts/integration/chronicle/test.yaml b/scripts/integration/chronicle/test.yaml index 3a518bc4844bf..048e7adbc3aa9 100644 --- a/scripts/integration/chronicle/test.yaml +++ b/scripts/integration/chronicle/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - chronicle-integration-tests -- --lib -- '::chronicle_unstructured::' + +test_filter: '::chronicle_unstructured::' env: CHRONICLE_ADDRESS: http://chronicle-emulator:3000 diff --git a/scripts/integration/clickhouse/test.yaml b/scripts/integration/clickhouse/test.yaml index 695cec9581ef0..7f59a79e07196 100644 --- a/scripts/integration/clickhouse/test.yaml +++ b/scripts/integration/clickhouse/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - clickhouse-integration-tests -- --lib -- '::clickhouse::' + +test_filter: '::clickhouse::' env: CLICKHOUSE_ADDRESS: http://clickhouse:8123 diff --git a/scripts/integration/databend/test.yaml b/scripts/integration/databend/test.yaml index 542db07b7ab4c..9ce69f72ba690 100644 --- a/scripts/integration/databend/test.yaml +++ b/scripts/integration/databend/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - databend-integration-tests -- --lib -- '::databend::' + +test_filter: '::databend::' runner: env: diff --git a/scripts/integration/datadog-agent/test.yaml b/scripts/integration/datadog-agent/test.yaml index 14d7d2b61be8b..cbf55cd6ee8ca 100644 --- a/scripts/integration/datadog-agent/test.yaml +++ b/scripts/integration/datadog-agent/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - datadog-agent-integration-tests -- --lib -- 'sources::datadog_agent::integration_tests::' + +test_filter: 'sources::datadog_agent::integration_tests::' env: AGENT_ADDRESS: datadog-agent:8181 diff --git a/scripts/integration/datadog-logs/test.yaml b/scripts/integration/datadog-logs/test.yaml index 874bab35f6b14..87dbbecae66cf 100644 --- a/scripts/integration/datadog-logs/test.yaml +++ b/scripts/integration/datadog-logs/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - datadog-logs-integration-tests -- --lib -- '::datadog::logs::' + +test_filter: '::datadog::logs::' runner: env: diff --git a/scripts/integration/datadog-metrics/test.yaml b/scripts/integration/datadog-metrics/test.yaml index 68b5606d7e889..cfdf63fab0783 100644 --- a/scripts/integration/datadog-metrics/test.yaml +++ b/scripts/integration/datadog-metrics/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - datadog-metrics-integration-tests -- --lib -- '::datadog::metrics::' + +test_filter: '::datadog::metrics::' runner: env: diff --git a/scripts/integration/datadog-traces/test.yaml b/scripts/integration/datadog-traces/test.yaml index 293a93010e7a9..9a62b19cbf832 100644 --- a/scripts/integration/datadog-traces/test.yaml +++ b/scripts/integration/datadog-traces/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - datadog-traces-integration-tests -- --lib -- '::datadog::traces::' + +test_filter: '::datadog::traces::' env: AGENT_PORT: '8082' diff --git a/scripts/integration/dnstap/test.yaml b/scripts/integration/dnstap/test.yaml index 230e37d98882e..6475a242cf476 100644 --- a/scripts/integration/dnstap/test.yaml +++ b/scripts/integration/dnstap/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - dnstap-integration-tests -- --lib -- '::dnstap::' + +test_filter: '::dnstap::' runner: env: diff --git a/scripts/integration/docker-logs/test.yaml b/scripts/integration/docker-logs/test.yaml index 46d85865f9e77..5ad677b4b1259 100644 --- a/scripts/integration/docker-logs/test.yaml +++ b/scripts/integration/docker-logs/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - docker-logs-integration-tests -- --lib -- "::docker_logs::" + +test_filter: "::docker_logs::" runner: needs_docker_socket: true diff --git a/scripts/integration/elasticsearch/test.yaml b/scripts/integration/elasticsearch/test.yaml index a8bad8c50d139..98a8ee59e46fa 100644 --- a/scripts/integration/elasticsearch/test.yaml +++ b/scripts/integration/elasticsearch/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - es-integration-tests -- --lib -- '::elasticsearch::integration_tests::' + +test_filter: '::elasticsearch::integration_tests::' env: AWS_ACCESS_KEY_ID: dummy diff --git a/scripts/integration/eventstoredb/test.yaml b/scripts/integration/eventstoredb/test.yaml index e2eb8614f3ab6..f0dbb90b377e0 100644 --- a/scripts/integration/eventstoredb/test.yaml +++ b/scripts/integration/eventstoredb/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - eventstoredb_metrics-integration-tests -- --lib -- '::eventstoredb_metrics::' + +test_filter: '::eventstoredb_metrics::' matrix: version: [latest] diff --git a/scripts/integration/fluent/test.yaml b/scripts/integration/fluent/test.yaml index d0add51d563c1..8457454baf7d4 100644 --- a/scripts/integration/fluent/test.yaml +++ b/scripts/integration/fluent/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - fluent-integration-tests -- --lib -- "::fluent::" + +test_filter: "::fluent::" runner: needs_docker_socket: true diff --git a/scripts/integration/gcp/test.yaml b/scripts/integration/gcp/test.yaml index 692cebbb6f0b6..c63a4de29b613 100644 --- a/scripts/integration/gcp/test.yaml +++ b/scripts/integration/gcp/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - gcp-integration-tests -- --lib -- '::gcp::' + +test_filter: '::gcp::' env: EMULATOR_ADDRESS: http://gcloud-pubsub:8681 diff --git a/scripts/integration/http-client/test.yaml b/scripts/integration/http-client/test.yaml index 2d7d3cd08e919..aa867b5b23e39 100644 --- a/scripts/integration/http-client/test.yaml +++ b/scripts/integration/http-client/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - http-client-integration-tests -- --lib -- 'sources::http_client::' + +test_filter: 'sources::http_client::' env: DUFS_ADDRESS: http://dufs:5000 diff --git a/scripts/integration/humio/test.yaml b/scripts/integration/humio/test.yaml index 41fecba1987b3..95597eea7d8c3 100644 --- a/scripts/integration/humio/test.yaml +++ b/scripts/integration/humio/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - humio-integration-tests -- --lib -- '::humio::' + +test_filter: '::humio::' runner: env: diff --git a/scripts/integration/influxdb/test.yaml b/scripts/integration/influxdb/test.yaml index bd109c62cdafb..ef7bc7bcae349 100644 --- a/scripts/integration/influxdb/test.yaml +++ b/scripts/integration/influxdb/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - influxdb-integration-tests -- --lib -- '::influxdb::' + +test_filter: '::influxdb::' env: INFLUXDB_V1_HTTPS_ADDRESS: https://influxdb-v1-tls:8086 diff --git a/scripts/integration/kafka/test.yaml b/scripts/integration/kafka/test.yaml index 762a09e6f64df..39a2e2be58af1 100644 --- a/scripts/integration/kafka/test.yaml +++ b/scripts/integration/kafka/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - kafka-integration-tests -- --lib -- '::kafka::' + +test_filter: '::kafka::' env: KAFKA_HOST: kafka diff --git a/scripts/integration/logstash/test.yaml b/scripts/integration/logstash/test.yaml index 99dc569795610..550daed1f7ce1 100644 --- a/scripts/integration/logstash/test.yaml +++ b/scripts/integration/logstash/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - logstash-integration-tests -- --lib -- '::logstash::integration_tests::' + +test_filter: '::logstash::integration_tests::' env: HEARTBEAT_ADDRESS: 0.0.0.0:8080 diff --git a/scripts/integration/loki/test.yaml b/scripts/integration/loki/test.yaml index 7c9afe03d628a..156392182a509 100644 --- a/scripts/integration/loki/test.yaml +++ b/scripts/integration/loki/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - loki-integration-tests -- --lib -- '::loki::' + +test_filter: '::loki::' env: LOKI_ADDRESS: http://loki:3100 diff --git a/scripts/integration/mongodb/test.yaml b/scripts/integration/mongodb/test.yaml index 8319a526b17f8..3c2a40b264ecc 100644 --- a/scripts/integration/mongodb/test.yaml +++ b/scripts/integration/mongodb/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - mongodb_metrics-integration-tests -- --lib -- '::mongodb_metrics::' + +test_filter: '::mongodb_metrics::' env: PRIMARY_MONGODB_ADDRESS: mongodb://root:toor@mongodb-primary diff --git a/scripts/integration/nats/test.yaml b/scripts/integration/nats/test.yaml index 55312ce794fd5..9a11fabbf14de 100644 --- a/scripts/integration/nats/test.yaml +++ b/scripts/integration/nats/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - nats-integration-tests -- --lib -- '::nats::' + +test_filter: '::nats::' env: NATS_ADDRESS: nats://nats:4222 diff --git a/scripts/integration/nginx/test.yaml b/scripts/integration/nginx/test.yaml index 2126640c0ae76..61519b9f4fff4 100644 --- a/scripts/integration/nginx/test.yaml +++ b/scripts/integration/nginx/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - nginx-integration-tests -- --lib -- '::nginx_metrics::' + +test_filter: '::nginx_metrics::' runner: env: diff --git a/scripts/integration/opentelemetry/test.yaml b/scripts/integration/opentelemetry/test.yaml index c7642e4bf3314..140958c15a079 100644 --- a/scripts/integration/opentelemetry/test.yaml +++ b/scripts/integration/opentelemetry/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - opentelemetry-integration-tests -- --lib -- '::opentelemetry::' + +test_filter: '::opentelemetry::' runner: env: diff --git a/scripts/integration/postgres/test.yaml b/scripts/integration/postgres/test.yaml index 84a8be2354e4e..33df718d2ad56 100644 --- a/scripts/integration/postgres/test.yaml +++ b/scripts/integration/postgres/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - postgresql_metrics-integration-tests -- --lib -- ::postgres + +test_filter: ::postgres env: PG_HOST: postgres diff --git a/scripts/integration/prometheus/test.yaml b/scripts/integration/prometheus/test.yaml index 7c816c91c40dc..fb3a52d529a35 100644 --- a/scripts/integration/prometheus/test.yaml +++ b/scripts/integration/prometheus/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +test_filter: '::prometheus::remote_write::' + +features: - prometheus-integration-tests -- --lib -- '::prometheus::remote_write::' env: REMOTE_WRITE_SOURCE_RECEIVE_ADDRESS: runner:9102 diff --git a/scripts/integration/pulsar/test.yaml b/scripts/integration/pulsar/test.yaml index 20e5505dae72b..9115ec5620eee 100644 --- a/scripts/integration/pulsar/test.yaml +++ b/scripts/integration/pulsar/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - pulsar-integration-tests -- --lib -- '::pulsar::' + +test_filter: '::pulsar::' env: PULSAR_ADDRESS: pulsar://pulsar:6650 diff --git a/scripts/integration/redis/test.yaml b/scripts/integration/redis/test.yaml index dea997f7e3262..4456e4829082f 100644 --- a/scripts/integration/redis/test.yaml +++ b/scripts/integration/redis/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - redis-integration-tests -- --lib -- '::redis::' + +test_filter: "::redis::" env: REDIS_URL: redis://redis:6379/0 diff --git a/scripts/integration/shutdown/test.yaml b/scripts/integration/shutdown/test.yaml index 4348c87b56e4b..c32f2e010940a 100644 --- a/scripts/integration/shutdown/test.yaml +++ b/scripts/integration/shutdown/test.yaml @@ -1,11 +1,12 @@ args: -- --features -- shutdown-tests -- --test -- integration - --test-threads - '4' +features: +- shutdown-tests + +test: "integration" + env: KAFKA_HOST: kafka diff --git a/scripts/integration/splunk/test.yaml b/scripts/integration/splunk/test.yaml index c999e77d29c68..4d45c8364ae00 100644 --- a/scripts/integration/splunk/test.yaml +++ b/scripts/integration/splunk/test.yaml @@ -1,8 +1,7 @@ -args: -- --features +features: - splunk-integration-tests -- --lib -- '::splunk_hec::' + +test_filter: '::splunk_hec::' env: SPLUNK_API_ADDRESS: https://splunk-hec:8089 diff --git a/vdev/src/commands/integration/show.rs b/vdev/src/commands/integration/show.rs index 2d83a33c82a1e..c6394657534ec 100644 --- a/vdev/src/commands/integration/show.rs +++ b/vdev/src/commands/integration/show.rs @@ -38,7 +38,19 @@ impl Cli { let envs_dir = state::EnvsDir::new(&integration); let active_env = envs_dir.active()?; - println!("Test args: {}", config.args.join(" ")); + if let Some(args) = &config.args { + println!("Test args: {}", args.join(" ")); + } else { + println!("Test args: N/A"); + } + + if config.features.is_empty() { + println!("Features: N/A"); + } else { + println!("Features: {}", config.features.join(",")); + } + + println!("Test filter: {}", config.test_filter.as_deref().unwrap_or("N/A")); println!("Environment:"); print_env(" ", &config.env); diff --git a/vdev/src/testing/config.rs b/vdev/src/testing/config.rs index 1d89066d414e9..8a2d7e4e263fa 100644 --- a/vdev/src/testing/config.rs +++ b/vdev/src/testing/config.rs @@ -62,7 +62,7 @@ impl ComposeConfig { #[serde(deny_unknown_fields)] pub struct IntegrationTestConfig { /// The list of arguments to add to the command line for the test runner - pub args: Vec, + pub args: Option>, /// The set of environment variables to set in both the services and the runner. Variables with /// no value are treated as "passthrough" -- they must be set by the caller of `vdev` and are /// passed into the containers. @@ -73,6 +73,12 @@ pub struct IntegrationTestConfig { /// Configuration specific to the compose services. #[serde(default)] pub runner: IntegrationRunnerConfig, + + pub features: Vec, + + pub test: Option, + + pub test_filter: Option, } #[derive(Clone, Debug, Default, Deserialize)] diff --git a/vdev/src/testing/integration.rs b/vdev/src/testing/integration.rs index 600f80cac4c69..1b65bcc8bb05e 100644 --- a/vdev/src/testing/integration.rs +++ b/vdev/src/testing/integration.rs @@ -64,7 +64,25 @@ impl IntegrationTest { for (key, value) in config_env(&self.env_config) { env_vars.insert(key, Some(value)); } - let mut args = self.config.args.clone(); + + let mut args = self.config.args.clone().unwrap_or_default(); + + args.push("--features".to_string()); + args.push(self.config.features.join(",")); + + // If the test field is not present then use the --lib flag + match self.config.test { + Some(ref test_arg) => { + args.push("--test".to_string()); + args.push(test_arg.to_string()); + } + None => args.push("--lib".to_string()), + } + + // Ensure the test_filter args are passed as well + if let Some(ref filter) = self.config.test_filter { + args.push(filter.to_string()); + } args.extend(extra_args); self.runner .test(&env_vars, &self.config.runner.env, &args)?;