From 269f6246ecba6b34567dbddd75fbcf8e851d1a6f Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Mon, 24 Jul 2023 23:01:57 -0300 Subject: [PATCH 01/10] chore(tests): allow partial runs on trace-based test scripts --- test/tracetesting/Dockerfile | 2 +- test/tracetesting/run.bash | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/test/tracetesting/Dockerfile b/test/tracetesting/Dockerfile index 0cec0abd95..f04359b59e 100644 --- a/test/tracetesting/Dockerfile +++ b/test/tracetesting/Dockerfile @@ -14,4 +14,4 @@ COPY ./pb ./pb WORKDIR /app/test/tracetesting -CMD ["/bin/sh", "/app/test/tracetesting/run.bash"] +CMD ["/bin/bash", "/app/test/tracetesting/run.bash"] diff --git a/test/tracetesting/run.bash b/test/tracetesting/run.bash index 75ee37083a..02c0100223 100755 --- a/test/tracetesting/run.bash +++ b/test/tracetesting/run.bash @@ -47,12 +47,26 @@ EOF run_tracetest() { service_name=$1 - test_file=./$service_name/all.yaml + transaction_file=./$service_name/all.yaml - tracetest --config ./cli-config.yml test run --definition $test_file --environment ./tracetesting-env.yaml --wait-for-result + tracetest --config ./cli-config.yml run transaction --file $transaction_file --environment ./tracetesting-env.yaml return $? } +ALL_SERVICES=("ad-service" "cart-service" "currency-service" "checkout-service" "frontend-service" "email-service" "payment-service" "product-catalog-service" "recommendation-service" "shipping-service") +CHOSEN_SERVICES=() + +while [[ $# -gt 0 ]]; do + CHOSEN_SERVICES+=("$1") + shift +done + +if [ ${#CHOSEN_SERVICES[@]} -eq 0 ]; then + for service in "${ALL_SERVICES[@]}"; do + CHOSEN_SERVICES+=("$service") + done +fi + check_if_tracetest_is_installed create_env_file @@ -62,17 +76,11 @@ EXIT_STATUS=0 echo "" echo "Running trace-based tests..." +echo "" -run_tracetest ad-service || EXIT_STATUS=$? -run_tracetest cart-service || EXIT_STATUS=$? -run_tracetest currency-service || EXIT_STATUS=$? -run_tracetest checkout-service || EXIT_STATUS=$? -run_tracetest frontend-service || EXIT_STATUS=$? -run_tracetest email-service || EXIT_STATUS=$? -run_tracetest payment-service || EXIT_STATUS=$? -run_tracetest product-catalog-service || EXIT_STATUS=$? -run_tracetest recommendation-service || EXIT_STATUS=$? -run_tracetest shipping-service || EXIT_STATUS=$? +for service in "${CHOSEN_SERVICES[@]}"; do + run_tracetest $service || EXIT_STATUS=$? +done echo "" echo "Tests done! Exit code: $EXIT_STATUS" From 7755176800b10214fff0940f59eba3aafd81a947 Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Mon, 24 Jul 2023 23:54:25 -0300 Subject: [PATCH 02/10] Adding option to run trace-based tests for selected services --- Makefile | 2 +- test/tracetesting/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ff657bffb0..099992dcd3 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ run-tests: docker compose run traceBasedTests run-tracetesting: - docker compose run traceBasedTests + docker compose run traceBasedTests ${SERVICES_TO_TEST} .PHONY: generate-protobuf generate-protobuf: diff --git a/test/tracetesting/Dockerfile b/test/tracetesting/Dockerfile index f04359b59e..2d5471742a 100644 --- a/test/tracetesting/Dockerfile +++ b/test/tracetesting/Dockerfile @@ -14,4 +14,4 @@ COPY ./pb ./pb WORKDIR /app/test/tracetesting -CMD ["/bin/bash", "/app/test/tracetesting/run.bash"] +ENTRYPOINT ["/bin/bash", "/app/test/tracetesting/run.bash"] From e697fd86998edf2bddd80192bd3ea8725ae42ea5 Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Tue, 25 Jul 2023 13:34:17 -0300 Subject: [PATCH 03/10] Updating testing README --- test/README.md | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/test/README.md b/test/README.md index 3dc7d25658..34a35a8e80 100644 --- a/test/README.md +++ b/test/README.md @@ -1,7 +1,38 @@ # Service Testing -Testing gRPC services as black boxes. +There are two ways to test the service APIs on this demo: +1. Using AVA to do black box testing, calling the gRPC services and validating its direct response +2. Using Trace-based tests that call each service and validate the emitted traces and the direct response +## Testing gRPC services as black boxes. + +To run the entire test suite as a blackbox you need just to run the command: +```sh +docker compose run integrationTests +``` + +Now if you want the tests for a specific service: 1. Start the services you want to test with `docker compose up --build ` -1. Run `npm install` -1. Run `npm test` or `npx ava --match=''` to match test names +2. Run `npm install` +3. Run `npm test` or `npx ava --match=''` to match test names + +## Testing services with Trace-based tests + +To run the entire test suite of trace-based tests you can run the command: +```sh +make run-tracetesting +#or +docker compose run traceBasedTests +``` + +To run tests for specific services, you can pass the name of the service as a parameter (using the folder names located [here](./tracetesting/)): +```sh +make run-tracetesting SERVICES_TO_TEST="service-1 service-2 ..." +#or +docker compose run traceBasedTests "service-1 service-2 ..." +``` + +For instance, if you need to run the tests for `ad-service` and `payment-service`, you can run it with: +```sh +make run-tracetesting SERVICES_TO_TEST="ad-service payment-service" +``` \ No newline at end of file From cf7b957c605bbbc68072c8bf90499af0dacf05a4 Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Tue, 25 Jul 2023 13:41:36 -0300 Subject: [PATCH 04/10] Fixing sanity checks --- test/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/README.md b/test/README.md index 34a35a8e80..0ec32f5f2e 100644 --- a/test/README.md +++ b/test/README.md @@ -2,7 +2,7 @@ There are two ways to test the service APIs on this demo: 1. Using AVA to do black box testing, calling the gRPC services and validating its direct response -2. Using Trace-based tests that call each service and validate the emitted traces and the direct response +2. Using Trace-based tests that call each service and validate the emitted traces and the direct response ## Testing gRPC services as black boxes. @@ -27,12 +27,12 @@ docker compose run traceBasedTests To run tests for specific services, you can pass the name of the service as a parameter (using the folder names located [here](./tracetesting/)): ```sh -make run-tracetesting SERVICES_TO_TEST="service-1 service-2 ..." +make run-tracetesting SERVICES_TO_TEST="service-1 service-2 ..." #or -docker compose run traceBasedTests "service-1 service-2 ..." +docker compose run traceBasedTests "service-1 service-2 ..." ``` For instance, if you need to run the tests for `ad-service` and `payment-service`, you can run it with: ```sh -make run-tracetesting SERVICES_TO_TEST="ad-service payment-service" +make run-tracetesting SERVICES_TO_TEST="ad-service payment-service" ``` \ No newline at end of file From 4a70fed77c586ad46a039460954de2727592023d Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Tue, 25 Jul 2023 13:58:07 -0300 Subject: [PATCH 05/10] Fixing lint issues --- test/README.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/README.md b/test/README.md index 0ec32f5f2e..dea2e0724f 100644 --- a/test/README.md +++ b/test/README.md @@ -1,17 +1,22 @@ # Service Testing There are two ways to test the service APIs on this demo: -1. Using AVA to do black box testing, calling the gRPC services and validating its direct response -2. Using Trace-based tests that call each service and validate the emitted traces and the direct response -## Testing gRPC services as black boxes. +1. Using black box testing, calling gRPC services +and validating its direct response +2. Using Trace-based tests, calling services +and validating its direct response and traces + +## Testing gRPC services as black boxes To run the entire test suite as a blackbox you need just to run the command: + ```sh docker compose run integrationTests ``` Now if you want the tests for a specific service: + 1. Start the services you want to test with `docker compose up --build ` 2. Run `npm install` 3. Run `npm test` or `npx ava --match=''` to match test names @@ -19,20 +24,25 @@ Now if you want the tests for a specific service: ## Testing services with Trace-based tests To run the entire test suite of trace-based tests you can run the command: + ```sh make run-tracetesting #or docker compose run traceBasedTests ``` -To run tests for specific services, you can pass the name of the service as a parameter (using the folder names located [here](./tracetesting/)): +To run tests for specific services, you can pass the name of the service as a +parameter (using the folder names located [here](./tracetesting/)): + ```sh make run-tracetesting SERVICES_TO_TEST="service-1 service-2 ..." #or docker compose run traceBasedTests "service-1 service-2 ..." ``` -For instance, if you need to run the tests for `ad-service` and `payment-service`, you can run it with: +For instance, if you need to run the tests for `ad-service` and +`payment-service`, you can run them with: + ```sh make run-tracetesting SERVICES_TO_TEST="ad-service payment-service" -``` \ No newline at end of file +``` From f182a83d4e84f8d18cdfd438996aa860bd8f1aaf Mon Sep 17 00:00:00 2001 From: Daniel Baptista Dias Date: Wed, 26 Jul 2023 10:13:37 -0300 Subject: [PATCH 06/10] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adnan Rahić --- test/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/README.md b/test/README.md index dea2e0724f..65c1c9d3ae 100644 --- a/test/README.md +++ b/test/README.md @@ -1,21 +1,21 @@ # Service Testing -There are two ways to test the service APIs on this demo: +There are two ways to test the service APIs in the OpenTelemetry Demo: -1. Using black box testing, calling gRPC services -and validating its direct response +1. Using black box-testing, calling gRPC services +and validating their direct response 2. Using Trace-based tests, calling services -and validating its direct response and traces +and validating their direct response as well as the distributed traces they generate ## Testing gRPC services as black boxes -To run the entire test suite as a blackbox you need just to run the command: +To run the entire test suite as a black box, run the command: ```sh docker compose run integrationTests ``` -Now if you want the tests for a specific service: +If you want to run tests for a specific service, run: 1. Start the services you want to test with `docker compose up --build ` 2. Run `npm install` @@ -23,7 +23,7 @@ Now if you want the tests for a specific service: ## Testing services with Trace-based tests -To run the entire test suite of trace-based tests you can run the command: +To run the entire test suite of trace-based tests, run the command: ```sh make run-tracetesting @@ -31,7 +31,7 @@ make run-tracetesting docker compose run traceBasedTests ``` -To run tests for specific services, you can pass the name of the service as a +To run tests for specific services, pass the name of the service as a parameter (using the folder names located [here](./tracetesting/)): ```sh From 0f84918936bc463bc769e14cbd656037fff77e62 Mon Sep 17 00:00:00 2001 From: Daniel Baptista Dias Date: Fri, 28 Jul 2023 14:55:27 -0300 Subject: [PATCH 07/10] Update README.md with suggestions --- test/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/README.md b/test/README.md index 65c1c9d3ae..6278a379f5 100644 --- a/test/README.md +++ b/test/README.md @@ -4,8 +4,9 @@ There are two ways to test the service APIs in the OpenTelemetry Demo: 1. Using black box-testing, calling gRPC services and validating their direct response -2. Using Trace-based tests, calling services -and validating their direct response as well as the distributed traces they generate +2. Using Trace-based tests, calling both HTTP and +gRPC services and validating their direct response as well as +the distributed traces they generate ## Testing gRPC services as black boxes From d2e42b476943a580c9735edd48c6713c1333fdf2 Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Sun, 6 Aug 2023 21:31:35 -0300 Subject: [PATCH 08/10] Updating Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2260c69b..c045bcadc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ release. ## Unreleased +* Update trace-based tests run script + ([#1018])(https://github.com/open-telemetry/opentelemetry-demo/pull/1018) * Add cartServiceFailure feature flag triggering Cart Service errors ([#824](https://github.com/open-telemetry/opentelemetry-demo/pull/824)) * [paymentservice] update JS SDKs to 1.12.0/0.38.0 @@ -45,6 +47,8 @@ release. ([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/935)) * [cartservice] update service to .NET 7 ([#942](https://github.com/open-telemetry/opentelemetry-demo/pull/942)) +* Add trace-based testing examples + ([#877])(https://github.com/open-telemetry/opentelemetry-demo/pull/877) * Introduce minimal mode to run demo ([#872](https://github.com/open-telemetry/opentelemetry-demo/pull/872)) * [frontendproxy]Envoy expose a route for the collector to route frontend spans From b719c56a1108ebd7bf160c59f4465876cecd86ce Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Sun, 6 Aug 2023 21:34:27 -0300 Subject: [PATCH 09/10] Fixing linter issue --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c045bcadc9..a16f406da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ release. ## Unreleased -* Update trace-based tests run script +* Update trace-based tests run script ([#1018])(https://github.com/open-telemetry/opentelemetry-demo/pull/1018) * Add cartServiceFailure feature flag triggering Cart Service errors ([#824](https://github.com/open-telemetry/opentelemetry-demo/pull/824)) @@ -47,7 +47,7 @@ release. ([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/935)) * [cartservice] update service to .NET 7 ([#942](https://github.com/open-telemetry/opentelemetry-demo/pull/942)) -* Add trace-based testing examples +* Add trace-based testing examples ([#877])(https://github.com/open-telemetry/opentelemetry-demo/pull/877) * Introduce minimal mode to run demo ([#872](https://github.com/open-telemetry/opentelemetry-demo/pull/872)) From c65b70022ef115f0cd940d690fb99933bfd05867 Mon Sep 17 00:00:00 2001 From: Daniel Dias Date: Mon, 7 Aug 2023 08:34:20 -0300 Subject: [PATCH 10/10] Fixed changelog --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a16f406da6..21b1fe1571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ release. ## Unreleased -* Update trace-based tests run script - ([#1018])(https://github.com/open-telemetry/opentelemetry-demo/pull/1018) +* [tests] Update trace-based tests run script + ([#1018](https://github.com/open-telemetry/opentelemetry-demo/pull/1018)) * Add cartServiceFailure feature flag triggering Cart Service errors ([#824](https://github.com/open-telemetry/opentelemetry-demo/pull/824)) * [paymentservice] update JS SDKs to 1.12.0/0.38.0 @@ -47,8 +47,8 @@ release. ([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/935)) * [cartservice] update service to .NET 7 ([#942](https://github.com/open-telemetry/opentelemetry-demo/pull/942)) -* Add trace-based testing examples - ([#877])(https://github.com/open-telemetry/opentelemetry-demo/pull/877) +* [tests] Add trace-based testing examples + ([#877](https://github.com/open-telemetry/opentelemetry-demo/pull/877)) * Introduce minimal mode to run demo ([#872](https://github.com/open-telemetry/opentelemetry-demo/pull/872)) * [frontendproxy]Envoy expose a route for the collector to route frontend spans