summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
committerSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
commit82e03978b89938219958032efb1448cc76baa181 (patch)
tree626f3e54d52ecd49be0ed3bee30abacc0453d081 /test
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'test')
-rw-r--r--test/README.md33
-rw-r--r--test/tracetesting/Dockerfile17
-rw-r--r--test/tracetesting/ad/all.yaml10
-rw-r--r--test/tracetesting/ad/get.yaml28
-rw-r--r--test/tracetesting/cart/add-item-to-cart.yaml35
-rw-r--r--test/tracetesting/cart/all.yaml14
-rw-r--r--test/tracetesting/cart/check-if-cart-is-empty.yaml27
-rw-r--r--test/tracetesting/cart/check-if-cart-is-populated.yaml28
-rw-r--r--test/tracetesting/cart/empty-cart.yaml27
-rw-r--r--test/tracetesting/checkout/all.yaml10
-rw-r--r--test/tracetesting/checkout/place-order.yaml50
-rwxr-xr-xtest/tracetesting/cli-config.yml6
-rw-r--r--test/tracetesting/currency/all.yaml11
-rw-r--r--test/tracetesting/currency/convert.yaml34
-rw-r--r--test/tracetesting/currency/supported.yaml25
-rw-r--r--test/tracetesting/email/all.yaml10
-rw-r--r--test/tracetesting/email/confirmation.yaml62
-rw-r--r--test/tracetesting/frontend/01-see-ads.yaml35
-rw-r--r--test/tracetesting/frontend/02-get-product-recommendation.yaml36
-rw-r--r--test/tracetesting/frontend/03-browse-product.yaml31
-rw-r--r--test/tracetesting/frontend/04-add-product-to-cart.yaml38
-rw-r--r--test/tracetesting/frontend/05-view-cart.yaml25
-rw-r--r--test/tracetesting/frontend/06-checking-out-cart.yaml64
-rw-r--r--test/tracetesting/frontend/all.yaml15
-rw-r--r--test/tracetesting/otelcol-config-tracetest.yml14
-rw-r--r--test/tracetesting/payment/all.yaml13
-rw-r--r--test/tracetesting/payment/amex-credit-card-not-allowed.yaml37
-rw-r--r--test/tracetesting/payment/expired-credit-card.yaml37
-rw-r--r--test/tracetesting/payment/invalid-credit-card.yaml37
-rw-r--r--test/tracetesting/payment/valid-credit-card.yaml39
-rw-r--r--test/tracetesting/product-catalog/all.yaml12
-rw-r--r--test/tracetesting/product-catalog/get.yaml32
-rw-r--r--test/tracetesting/product-catalog/list.yaml26
-rw-r--r--test/tracetesting/product-catalog/search.yaml28
-rw-r--r--test/tracetesting/recommendation/all.yaml10
-rw-r--r--test/tracetesting/recommendation/list.yaml25
-rwxr-xr-xtest/tracetesting/run.bash110
-rw-r--r--test/tracetesting/shipping/all.yaml12
-rw-r--r--test/tracetesting/shipping/empty-quote.yaml36
-rw-r--r--test/tracetesting/shipping/order.yaml39
-rw-r--r--test/tracetesting/shipping/quote.yaml40
-rw-r--r--test/tracetesting/tracetest-config.yaml24
-rw-r--r--test/tracetesting/tracetest-provision.yaml37
43 files changed, 1279 insertions, 0 deletions
diff --git a/test/README.md b/test/README.md
new file mode 100644
index 0000000..207c40d
--- /dev/null
+++ b/test/README.md
@@ -0,0 +1,33 @@
+# Service Testing
+
+The OpenTelemetry Demo uses traced-based testing to validate the
+functionality of the services and the traces they generate.
+
+The trace-based tests will each service and validate the traces they
+generate and stored in Jaeger, to a known working trace for the same operation.
+
+## Testing services with Trace-based tests
+
+To run the entire test suite of trace-based tests, run the command:
+
+```sh
+make run-tracetesting
+#or
+docker compose run traceBasedTests
+```
+
+To run tests for specific services, pass the name of the service as a
+parameter (using the folder names located [in the tracetesting directory](./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` and `payment`, you can run
+them with:
+
+```sh
+make run-tracetesting SERVICES_TO_TEST="ad payment"
+```
diff --git a/test/tracetesting/Dockerfile b/test/tracetesting/Dockerfile
new file mode 100644
index 0000000..a76dea5
--- /dev/null
+++ b/test/tracetesting/Dockerfile
@@ -0,0 +1,17 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+
+FROM alpine
+
+WORKDIR /app
+
+# The build-images workflow action does not set a build-arg so we need to specify a default value here
+ARG TRACETEST_IMAGE_VERSION
+
+RUN apk --update add bash jq curl
+RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION
+
+WORKDIR /app/test/tracetesting
+
+ENTRYPOINT ["/bin/bash", "/app/test/tracetesting/run.bash"]
diff --git a/test/tracetesting/ad/all.yaml b/test/tracetesting/ad/all.yaml
new file mode 100644
index 0000000..e57c232
--- /dev/null
+++ b/test/tracetesting/ad/all.yaml
@@ -0,0 +1,10 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: ad-all
+ name: 'Ad Service'
+ description: Run all Ad Service tests enabled in sequence
+ steps:
+ - ./get.yaml
diff --git a/test/tracetesting/ad/get.yaml b/test/tracetesting/ad/get.yaml
new file mode 100644
index 0000000..65b0f07
--- /dev/null
+++ b/test/tracetesting/ad/get.yaml
@@ -0,0 +1,28 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: ad-get-ads
+ name: 'Ad: get'
+ description: Get Ads from API
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:AD_ADDR}
+ method: oteldemo.AdService.GetAds
+ request: |-
+ {
+ "contextKeys": [ "galaxy", "telescope" ]
+ }
+ specs:
+ - name: It returns two ads
+ selector: span[tracetest.span.type="rpc" name="oteldemo.AdService/GetAds" rpc.system="grpc" rpc.method="GetAds" rpc.service="oteldemo.AdService"]
+ assertions:
+ - attr:app.ads.count = 2
+ - name: It returns a valid redirectUrl for each ads
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.ads[0].redirectUrl' contains "/product/"
+ - attr:tracetest.response.body | json_path '$.ads[1].redirectUrl' contains "/product/"
diff --git a/test/tracetesting/cart/add-item-to-cart.yaml b/test/tracetesting/cart/add-item-to-cart.yaml
new file mode 100644
index 0000000..c42b1f2
--- /dev/null
+++ b/test/tracetesting/cart/add-item-to-cart.yaml
@@ -0,0 +1,35 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: cart-add-item-to-cart
+ name: 'Cart: add item to cart'
+ description: Add one item to the shopping cart
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CART_ADDR}
+ method: oteldemo.CartService.AddItem
+ request: |-
+ {
+ "userId": "1234",
+ "item": {
+ "productId": "OLJCESPC7Z",
+ "quantity": 1
+ }
+ }
+ specs:
+ - name: It added an item correctly into the shopping cart
+ selector: span[name="POST /oteldemo.CartService/AddItem"]
+ assertions:
+ - attr:grpc.status_code = 0
+ - name: It set the cart item correctly on the database
+ selector: span[tracetest.span.type="database" name="HMSET" db.system="redis" db.redis.database_index="0"]
+ assertions:
+ - attr:db.statement = "HMSET 1234"
+ - name: It returned an empty cart
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - "attr:tracetest.response.body = '{\n \n}'"
diff --git a/test/tracetesting/cart/all.yaml b/test/tracetesting/cart/all.yaml
new file mode 100644
index 0000000..03ee4e5
--- /dev/null
+++ b/test/tracetesting/cart/all.yaml
@@ -0,0 +1,14 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: cart-all
+ name: 'Cart Service'
+ description: Run all Cart tests enabled in sequence
+ steps:
+ - ./empty-cart.yaml
+ - ./add-item-to-cart.yaml
+ - ./check-if-cart-is-populated.yaml
+ - ./empty-cart.yaml
+ - ./check-if-cart-is-empty.yaml
diff --git a/test/tracetesting/cart/check-if-cart-is-empty.yaml b/test/tracetesting/cart/check-if-cart-is-empty.yaml
new file mode 100644
index 0000000..de9f409
--- /dev/null
+++ b/test/tracetesting/cart/check-if-cart-is-empty.yaml
@@ -0,0 +1,27 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: cart-check-if-cart-is-empty
+ name: 'Cart: check if cart is empty'
+ description: Check if the shopping cart has no items
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CART_ADDR}
+ method: oteldemo.CartService.GetCart
+ request: |-
+ {
+ "userId": "1234"
+ }
+ specs:
+ - name: It retrieved the cart items correctly
+ selector: span[name="POST /oteldemo.CartService/GetCart"]
+ assertions:
+ - attr:grpc.status_code = 0
+ - name: It returned no items
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.items' = "[]"
diff --git a/test/tracetesting/cart/check-if-cart-is-populated.yaml b/test/tracetesting/cart/check-if-cart-is-populated.yaml
new file mode 100644
index 0000000..db753c1
--- /dev/null
+++ b/test/tracetesting/cart/check-if-cart-is-populated.yaml
@@ -0,0 +1,28 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: cart-check-if-cart-is-populated
+ name: 'Cart: check if cart is populated'
+ description: Check if the shopping cart has one item
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CART_ADDR}
+ method: oteldemo.CartService.GetCart
+ request: |-
+ {
+ "userId": "1234"
+ }
+ specs:
+ - name: It retrieved the cart items correctly
+ selector: span[name="POST /oteldemo.CartService/GetCart"]
+ assertions:
+ - attr:grpc.status_code = 0
+ - name: It returned the first item with correct attributes
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.items[0].quantity' = 1
+ - attr:tracetest.response.body | json_path '$.items[0].productId' = "OLJCESPC7Z"
diff --git a/test/tracetesting/cart/empty-cart.yaml b/test/tracetesting/cart/empty-cart.yaml
new file mode 100644
index 0000000..bc97074
--- /dev/null
+++ b/test/tracetesting/cart/empty-cart.yaml
@@ -0,0 +1,27 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: cart-empty-cart
+ name: 'Cart: empty cart'
+ description: Clean shopping cart
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CART_ADDR}
+ method: oteldemo.CartService.EmptyCart
+ request: |-
+ {
+ "userId": "1234"
+ }
+ specs:
+ - name: It emptied the shopping cart with success
+ selector: span[name="POST /oteldemo.CartService/EmptyCart"]
+ assertions:
+ - attr:grpc.status_code = 0
+ - name: It sent cleaning message to the database
+ selector: span[tracetest.span.type="database" name="EXPIRE" db.system="redis" db.redis.database_index="0"]
+ assertions:
+ - attr:db.statement = "EXPIRE 1234"
diff --git a/test/tracetesting/checkout/all.yaml b/test/tracetesting/checkout/all.yaml
new file mode 100644
index 0000000..39e4391
--- /dev/null
+++ b/test/tracetesting/checkout/all.yaml
@@ -0,0 +1,10 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: checkout-all
+ name: 'Checkout Service'
+ description: Run all Checkout Service tests enabled in sequence
+ steps:
+ - ./place-order.yaml
diff --git a/test/tracetesting/checkout/place-order.yaml b/test/tracetesting/checkout/place-order.yaml
new file mode 100644
index 0000000..2b7eb29
--- /dev/null
+++ b/test/tracetesting/checkout/place-order.yaml
@@ -0,0 +1,50 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: checkout-place-order
+ name: 'Checkout: place order'
+ description: Place one order on the system
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CHECKOUT_ADDR}
+ method: oteldemo.CheckoutService.PlaceOrder
+ request: |-
+ {
+ "userId": "1997",
+ "userCurrency": "USD",
+ "address": {
+ "streetAddress": "410 Terry Ave. North",
+ "city": "Seattle",
+ "state": "Washington",
+ "country": "United States",
+ "zipCode": "98109"
+ },
+ "email": "amazon@example.com",
+ "creditCard": {
+ "creditCardNumber": "4117-7059-6121-5486",
+ "creditCardCvv": 346,
+ "creditCardExpirationYear": 2025,
+ "creditCardExpirationMonth": 3
+ }
+ }
+ specs:
+ - name: It returns a valid order
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.order.orderId' != ""
+ - attr:tracetest.response.body | json_path '$.order.shippingTrackingId' != ""
+ - attr:tracetest.response.body | json_path '$.order.shippingAddress' != "{}"
+ - attr:tracetest.response.body | json_path '$.order.shippingCost.currencyCode' = "USD"
+ - name: It calls the PlaceOrder method successfuly
+ selector: span[tracetest.span.type="rpc" name="oteldemo.CheckoutService/PlaceOrder"
+ rpc.system="grpc" rpc.method="PlaceOrder" rpc.service="oteldemo.CheckoutService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - name: It sends an order to be processed asyncronously
+ selector: span[tracetest.span.type="messaging" name="orders publish" kind="producer" messaging.system="kafka" messaging.destination.name="orders" messaging.operation="publish"]
+ assertions:
+ - attr:messaging.destination.name = "orders"
diff --git a/test/tracetesting/cli-config.yml b/test/tracetesting/cli-config.yml
new file mode 100755
index 0000000..9cd2673
--- /dev/null
+++ b/test/tracetesting/cli-config.yml
@@ -0,0 +1,6 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+scheme: http
+endpoint: tracetest-server:11633
+analyticsEnabled: false
diff --git a/test/tracetesting/currency/all.yaml b/test/tracetesting/currency/all.yaml
new file mode 100644
index 0000000..2f30f4f
--- /dev/null
+++ b/test/tracetesting/currency/all.yaml
@@ -0,0 +1,11 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: currency-all
+ name: 'Currency Service'
+ description: Run all Currency Service tests enabled in sequence
+ steps:
+ - ./convert.yaml
+ - ./supported.yaml
diff --git a/test/tracetesting/currency/convert.yaml b/test/tracetesting/currency/convert.yaml
new file mode 100644
index 0000000..ddae749
--- /dev/null
+++ b/test/tracetesting/currency/convert.yaml
@@ -0,0 +1,34 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: currency-convert
+ name: 'Currency: Convert'
+ description: Convert a currency
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CURRENCY_ADDR}
+ method: oteldemo.CurrencyService.Convert
+ request: |-
+ {
+ "from": {
+ "currencyCode": "USD",
+ "units": 330,
+ "nanos": 750000000
+ },
+ "toCode": "CAD"
+ }
+ specs:
+ - name: It converts from USD to CAD
+ selector: span[tracetest.span.type="rpc" name="Currency/Convert" rpc.system="grpc"
+ rpc.method="Convert" rpc.service="oteldemo.CurrencyService"]
+ assertions:
+ - attr:app.currency.conversion.from = "USD"
+ - attr:app.currency.conversion.to = "CAD"
+ - name: It has more nanos than expected
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body| json_path '$.nanos' >= 599380800
diff --git a/test/tracetesting/currency/supported.yaml b/test/tracetesting/currency/supported.yaml
new file mode 100644
index 0000000..9959e49
--- /dev/null
+++ b/test/tracetesting/currency/supported.yaml
@@ -0,0 +1,25 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: currency-supported
+ name: 'Currency: Supported'
+ description: Get all supported currencies
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:CURRENCY_ADDR}
+ method: oteldemo.CurrencyService.GetSupportedCurrencies
+ specs:
+ - name: It has a span called "Currency/GetSupportedCurrencies"
+ selector: span[tracetest.span.type="rpc" name="Currency/GetSupportedCurrencies"
+ rpc.system="grpc" rpc.method="GetSupportedCurrencies" rpc.service="oteldemo.CurrencyService"]
+ assertions:
+ - attr:name = "Currency/GetSupportedCurrencies"
+ - name: It returns the expected currency codes
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.currencyCodes[0]' = "ZAR"
+ - attr:tracetest.response.body | json_path '$.currencyCodes[32]' = "MYR"
diff --git a/test/tracetesting/email/all.yaml b/test/tracetesting/email/all.yaml
new file mode 100644
index 0000000..517ca65
--- /dev/null
+++ b/test/tracetesting/email/all.yaml
@@ -0,0 +1,10 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: email-all
+ name: 'Email'
+ description: Run all Email tests enabled in sequence
+ steps:
+ - ./confirmation.yaml
diff --git a/test/tracetesting/email/confirmation.yaml b/test/tracetesting/email/confirmation.yaml
new file mode 100644
index 0000000..96c561e
--- /dev/null
+++ b/test/tracetesting/email/confirmation.yaml
@@ -0,0 +1,62 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: email-confirmation
+ name: 'Email: Confirmation'
+ description: Send an order confirmation email
+ trigger:
+ type: http
+ httpRequest:
+ url: ${var:EMAIL_ADDR}/send_order_confirmation
+ method: POST
+ headers:
+ - key: Content-Type
+ value: application/json
+ body: |
+ {
+ "email": "google@example.com",
+ "order": {
+ "order_id": "505",
+ "shipping_tracking_id": "dead-beef",
+ "shipping_cost": {
+ "currency_code": "USD",
+ "units": 17,
+ "nanos": 980000000
+ },
+ "shipping_address": {
+ "street_address_1": "1600 Amphitheatre Parkway",
+ "city": "Mountain View",
+ "state": "California",
+ "country": "United States",
+ "zip_code": "94043"
+ },
+ "items": [
+ {
+ "item": {
+ "product_id": "1YMWWN1N4O",
+ "quantity": 5
+ },
+ "cost": {
+ "currency_code": "USD",
+ "units": 100,
+ "nanos": 0
+ }
+ }
+ ]
+ }
+ }
+ specs:
+ - name: It should be called successfully
+ selector: span[tracetest.span.type="http" name="POST /send_order_confirmation" http.method="POST"]
+ assertions:
+ - attr:http.status_code = 200
+ - name: It should render a email to send
+ selector: span[tracetest.span.type="general" name="sinatra.render_template"]
+ assertions:
+ - attr:name = "sinatra.render_template"
+ - name: It should send an email
+ selector: span[tracetest.span.type="general" name="send_email"]
+ assertions:
+ - attr:name = "send_email"
diff --git a/test/tracetesting/frontend/01-see-ads.yaml b/test/tracetesting/frontend/01-see-ads.yaml
new file mode 100644
index 0000000..698a6df
--- /dev/null
+++ b/test/tracetesting/frontend/01-see-ads.yaml
@@ -0,0 +1,35 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-see-adds
+ name: 'Frontend: See Ads'
+ description: Simulate the user seeing a ads on Astronomy Shop
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/data
+ method: GET
+ headers:
+ - key: Content-Type
+ value: application/json
+ body: |
+ {
+ "contextKeys": [
+ "binoculars",
+ "telescopes",
+ "accessories"
+ ]
+ }
+ specs:
+ - name: It called the frontend with success and got a valid redirectUrl for each ads
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - attr:tracetest.response.body | json_path '$[0].redirectUrl' contains "/product/"
+ - attr:tracetest.response.body | json_path '$[1].redirectUrl' contains "/product/"
+ - name: It returns two ads
+ selector: span[tracetest.span.type="rpc" name="oteldemo.AdService/GetAds" rpc.system="grpc" rpc.method="GetAds" rpc.service="oteldemo.AdService"]
+ assertions:
+ - attr:app.ads.count = 2
diff --git a/test/tracetesting/frontend/02-get-product-recommendation.yaml b/test/tracetesting/frontend/02-get-product-recommendation.yaml
new file mode 100644
index 0000000..78569c3
--- /dev/null
+++ b/test/tracetesting/frontend/02-get-product-recommendation.yaml
@@ -0,0 +1,36 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-get-recommendation
+ name: 'Frontend: Get recommendations'
+ description: Simulate the user seeing recomendations on Astronomy Shop
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/recommendations
+ method: GET
+ headers:
+ - key: Content-Type
+ value: application/json
+ body: |
+ {
+ "productIds":[
+ "0PUK6V6EV0",
+ "1YMWWN1N4O",
+ "2ZYFJ3GM2N",
+ "66VCHSJNUP",
+ "6E92ZMYYFZ"
+ ]
+ }
+ specs:
+ - name: It called the frontend with success
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - name: It called ListRecommendations correctly and got 5 products
+ selector: span[tracetest.span.type="rpc" name="/oteldemo.RecommendationService/ListRecommendations" rpc.system="grpc" rpc.method="ListRecommendations" rpc.service="oteldemo.RecommendationService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:app.products_recommended.count = 5
diff --git a/test/tracetesting/frontend/03-browse-product.yaml b/test/tracetesting/frontend/03-browse-product.yaml
new file mode 100644
index 0000000..2d13fdf
--- /dev/null
+++ b/test/tracetesting/frontend/03-browse-product.yaml
@@ -0,0 +1,31 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-browse-product
+ name: 'Frontend: Browse products'
+ description: Simulate the user browsing products on Astronomy Shop
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/products/0PUK6V6EV0
+ method: GET
+ headers:
+ - key: Content-Type
+ value: application/json
+ specs:
+ - name: It called the frontend with success and got a product with valid attributes
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - attr:tracetest.response.body | json_path '$.id' = "0PUK6V6EV0"
+ - attr:tracetest.response.body | json_path '$.description' != ""
+ - attr:tracetest.response.body | json_path '$.picture' != ""
+ - attr:tracetest.response.body | json_path '$.priceUsd' != "{}"
+ - attr:tracetest.response.body | json_path '$.categories' != "[]"
+ - name: It queried the product catalog correctly for a specific product
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ProductCatalogService/GetProduct" rpc.system="grpc" rpc.method="GetProduct" rpc.service="oteldemo.ProductCatalogService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:app.product.id = "0PUK6V6EV0"
diff --git a/test/tracetesting/frontend/04-add-product-to-cart.yaml b/test/tracetesting/frontend/04-add-product-to-cart.yaml
new file mode 100644
index 0000000..3f70cc6
--- /dev/null
+++ b/test/tracetesting/frontend/04-add-product-to-cart.yaml
@@ -0,0 +1,38 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-add-product
+ name: 'Frontend: Add product to the cart'
+ description: Simulate a user adding a selected product to the shopping cart
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/cart
+ method: POST
+ headers:
+ - key: Content-Type
+ value: application/json
+ body: |
+ {
+ "item": {
+ "productId": "0PUK6V6EV0",
+ "quantity": 2
+ },
+ "userId": "2491f868-88f1-4345-8836-d5d8511a9f83"
+ }
+ specs:
+ - name: It called the frontend with success
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - name: It added an item correctly into the shopping cart
+ selector: span[name="POST /oteldemo.CartService/AddItem"]
+ assertions:
+ - attr:grpc.status_code = 0
+ - attr:app.product.id = "0PUK6V6EV0"
+ - name: It set the cart item correctly on the database
+ selector: span[tracetest.span.type="database" name="HMSET" db.system="redis" db.redis.database_index="0"]
+ assertions:
+ - attr:db.statement = "HMSET 2491f868-88f1-4345-8836-d5d8511a9f83"
diff --git a/test/tracetesting/frontend/05-view-cart.yaml b/test/tracetesting/frontend/05-view-cart.yaml
new file mode 100644
index 0000000..68f8f06
--- /dev/null
+++ b/test/tracetesting/frontend/05-view-cart.yaml
@@ -0,0 +1,25 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-view-cart
+ name: 'Frontend: View cart'
+ description: Simulate a user viewing the shopping cart
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/cart?userId=2491f868-88f1-4345-8836-d5d8511a9f83
+ method: GET
+ headers:
+ - key: Content-Type
+ value: application/json
+ specs:
+ - name: It called the frontend with success
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - name: It retrieved the cart items correctly
+ selector: span[name="POST /oteldemo.CartService/GetCart"]
+ assertions:
+ - attr:grpc.status_code = 0
diff --git a/test/tracetesting/frontend/06-checking-out-cart.yaml b/test/tracetesting/frontend/06-checking-out-cart.yaml
new file mode 100644
index 0000000..d8d4748
--- /dev/null
+++ b/test/tracetesting/frontend/06-checking-out-cart.yaml
@@ -0,0 +1,64 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: frontend-checkout-shopping-cart
+ name: 'Frontend: Checking out shopping cart'
+ description: Simulate user checking out shopping cart
+ trigger:
+ type: http
+ httpRequest:
+ url: http://${var:FRONTEND_ADDR}/api/checkout
+ method: POST
+ headers:
+ - key: Content-Type
+ value: application/json
+ body: |
+ {
+ "userId": "2491f868-88f1-4345-8836-d5d8511a9f83",
+ "email": "someone@example.com",
+ "address": {
+ "streetAddress": "1600 Amphitheatre Parkway",
+ "state": "CA",
+ "country": "United States",
+ "city": "Mountain View",
+ "zipCode": "94043"
+ },
+ "userCurrency": "USD",
+ "creditCard": {
+ "creditCardCvv": 672,
+ "creditCardExpirationMonth": 1,
+ "creditCardExpirationYear": 2030,
+ "creditCardNumber": "4432-8015-6152-0454"
+ }
+ }
+ specs:
+ - name: It called the frontend with success
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 200
+ - name: "The order was placed"
+ selector: span[tracetest.span.type="rpc" name="oteldemo.CheckoutService/PlaceOrder" rpc.system="grpc" rpc.method="PlaceOrder" rpc.service="oteldemo.CheckoutService"]
+ assertions:
+ - attr:app.user.id = "2491f868-88f1-4345-8836-d5d8511a9f83"
+ - attr:app.order.items.count = 1
+ - name: "The user was charged"
+ selector: span[tracetest.span.type="rpc" name="oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:tracetest.selected_spans.count >= 1
+ - name: "The product was shipped"
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ShippingService/ShipOrder" rpc.system="grpc" rpc.method="ShipOrder" rpc.service="oteldemo.ShippingService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:tracetest.selected_spans.count >= 1
+ - name: "The cart was emptied"
+ selector: span[tracetest.span.type="rpc" name="oteldemo.CartService/EmptyCart" rpc.system="grpc" rpc.method="EmptyCart" rpc.service="oteldemo.CartService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:tracetest.selected_spans.count >= 1
+ - name: The order was sent to be processed asyncronously
+ selector: span[tracetest.span.type="messaging" name="orders publish" messaging.system="kafka" messaging.destination.name="orders" messaging.operation="publish"]
+ assertions:
+ - attr:messaging.destination.name = "orders"
diff --git a/test/tracetesting/frontend/all.yaml b/test/tracetesting/frontend/all.yaml
new file mode 100644
index 0000000..d7f1960
--- /dev/null
+++ b/test/tracetesting/frontend/all.yaml
@@ -0,0 +1,15 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: frontend-all
+ name: 'Frontend Service'
+ description: Run all Frontend tests enabled in sequence, simulating a process of a user purchasing products on Astronomy store
+ steps:
+ - ./01-see-ads.yaml
+ - ./02-get-product-recommendation.yaml
+ - ./03-browse-product.yaml
+ - ./04-add-product-to-cart.yaml
+ - ./05-view-cart.yaml
+ - ./06-checking-out-cart.yaml
diff --git a/test/tracetesting/otelcol-config-tracetest.yml b/test/tracetesting/otelcol-config-tracetest.yml
new file mode 100644
index 0000000..5ce06ce
--- /dev/null
+++ b/test/tracetesting/otelcol-config-tracetest.yml
@@ -0,0 +1,14 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+exporters:
+ otlp/tracetest:
+ endpoint: http://tracetest-server:4317
+ tls:
+ insecure: true
+
+service:
+ pipelines:
+ traces:
+ processors: []
+ exporters: [debug, spanmetrics, otlp/tracetest]
diff --git a/test/tracetesting/payment/all.yaml b/test/tracetesting/payment/all.yaml
new file mode 100644
index 0000000..c7d08d8
--- /dev/null
+++ b/test/tracetesting/payment/all.yaml
@@ -0,0 +1,13 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: payment-all
+ name: 'Payment'
+ description: Run all Payment tests enabled in sequence
+ steps:
+ - ./valid-credit-card.yaml
+ - ./invalid-credit-card.yaml
+ - ./amex-credit-card-not-allowed.yaml
+ - ./expired-credit-card.yaml
diff --git a/test/tracetesting/payment/amex-credit-card-not-allowed.yaml b/test/tracetesting/payment/amex-credit-card-not-allowed.yaml
new file mode 100644
index 0000000..6ad88e7
--- /dev/null
+++ b/test/tracetesting/payment/amex-credit-card-not-allowed.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-amex-credit-card-not-allowed
+ name: 'Payment: Amex credit card not allowed'
+ description: Charge customer with an Amex credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "3714 496353 98431",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "Sorry, we cannot process amex credit cards. Only VISA or MasterCard is accepted."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/expired-credit-card.yaml b/test/tracetesting/payment/expired-credit-card.yaml
new file mode 100644
index 0000000..c2f9d5d
--- /dev/null
+++ b/test/tracetesting/payment/expired-credit-card.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-expired-credit-card
+ name: 'Payment: expired credit card'
+ description: Charge customer with an expired credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "4432-8015-6152-0454",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2021,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "The credit card (ending 0454) expired on 1/2021."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/invalid-credit-card.yaml b/test/tracetesting/payment/invalid-credit-card.yaml
new file mode 100644
index 0000000..6ab64de
--- /dev/null
+++ b/test/tracetesting/payment/invalid-credit-card.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-invalid-credit-card
+ name: 'Payment: invalid credit card'
+ description: Charge customer with an invalid credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "0000-0000-0000-0000",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method and receive a gRPC error
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ assertions:
+ - attr:grpc.error_message = "Credit card info is invalid."
+ - name: It should return a return an gRPC error code to the caller
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.status = 2
diff --git a/test/tracetesting/payment/valid-credit-card.yaml b/test/tracetesting/payment/valid-credit-card.yaml
new file mode 100644
index 0000000..3bc7a65
--- /dev/null
+++ b/test/tracetesting/payment/valid-credit-card.yaml
@@ -0,0 +1,39 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: payment-valid-credit-card
+ name: "Payment: valid credit card"
+ description: Charge customer with a valid credit card
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PAYMENT_ADDR}
+ method: oteldemo.PaymentService.Charge
+ request: |-
+ {
+ "amount": {
+ "currencyCode": "USD",
+ "units": 43,
+ "nanos": 130000000
+ },
+ "creditCard": {
+ "creditCardNumber": "4432-8015-6152-0454",
+ "creditCardCvv": 672,
+ "creditCardExpirationYear": 2039,
+ "creditCardExpirationMonth": 1
+ }
+ }
+ specs:
+ - name: It should call Charge method successfully
+ selector: span[tracetest.span.type="rpc" name="grpc.oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"]
+ # instead of returning status_code 0, this service can return 1 depending on timing, but it works as intended
+ assertions:
+ # updating assertion to match 0 and 1
+ - attr:rpc.grpc.status_code <= 1
+ - name: It should return a transaction ID
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.transactionId' != ""
diff --git a/test/tracetesting/product-catalog/all.yaml b/test/tracetesting/product-catalog/all.yaml
new file mode 100644
index 0000000..21f7a12
--- /dev/null
+++ b/test/tracetesting/product-catalog/all.yaml
@@ -0,0 +1,12 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: product-catalog-all
+ name: 'Product Catalog'
+ description: Run all Product Catalog tests enabled in sequence
+ steps:
+ - ./list.yaml
+ - ./get.yaml
+ - ./search.yaml
diff --git a/test/tracetesting/product-catalog/get.yaml b/test/tracetesting/product-catalog/get.yaml
new file mode 100644
index 0000000..a1e26c4
--- /dev/null
+++ b/test/tracetesting/product-catalog/get.yaml
@@ -0,0 +1,32 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: product-get
+ name: 'Product: Get'
+ description: Get a single product available on product catalog
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PRODUCT_CATALOG_ADDR}
+ method: oteldemo.ProductCatalogService.GetProduct
+ request: |-
+ {
+ "id": "OLJCESPC7Z"
+ }
+ specs:
+ - name: It queried the product catalog correctly for a specific product
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ProductCatalogService/GetProduct" rpc.system="grpc" rpc.method="GetProduct" rpc.service="oteldemo.ProductCatalogService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:app.product.id = "OLJCESPC7Z"
+ - name: It returned a product with valid attributes
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.id' = "OLJCESPC7Z"
+ - attr:tracetest.response.body | json_path '$.description' != ""
+ - attr:tracetest.response.body | json_path '$.picture' != ""
+ - attr:tracetest.response.body | json_path '$.priceUsd' != "{}"
+ - attr:tracetest.response.body | json_path '$.categories' != "[]"
diff --git a/test/tracetesting/product-catalog/list.yaml b/test/tracetesting/product-catalog/list.yaml
new file mode 100644
index 0000000..92adadb
--- /dev/null
+++ b/test/tracetesting/product-catalog/list.yaml
@@ -0,0 +1,26 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: product-list
+ name: 'Product: List'
+ description: List all products available on product catalog
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PRODUCT_CATALOG_ADDR}
+ method: oteldemo.ProductCatalogService.ListProducts
+ request: ""
+ specs:
+ - name: It queried the product catalog correctly
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ProductCatalogService/ListProducts"
+ rpc.system="grpc" rpc.method="ListProducts" rpc.service="oteldemo.ProductCatalogService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:app.products.count = 10
+ - name: It returned products with IDs
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.products[*].id' != ""
diff --git a/test/tracetesting/product-catalog/search.yaml b/test/tracetesting/product-catalog/search.yaml
new file mode 100644
index 0000000..fe211b8
--- /dev/null
+++ b/test/tracetesting/product-catalog/search.yaml
@@ -0,0 +1,28 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: product-search
+ name: 'Product: Search'
+ description: Search for products querying for their names
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:PRODUCT_CATALOG_ADDR}
+ method: oteldemo.ProductCatalogService.SearchProducts
+ request: |-
+ {
+ "query": "Roof Binoculars"
+ }
+ specs:
+ - name: It called SearchProducts correctly and it returned 1 item
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ProductCatalogService/SearchProducts" rpc.system="grpc" rpc.method="SearchProducts" rpc.service="oteldemo.ProductCatalogService"]
+ assertions:
+ - attr:app.products_search.count = 1
+ - attr:rpc.grpc.status_code = 0
+ - name: It returned the desired product
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.results[0].name' = "Roof Binoculars"
diff --git a/test/tracetesting/recommendation/all.yaml b/test/tracetesting/recommendation/all.yaml
new file mode 100644
index 0000000..bfc4311
--- /dev/null
+++ b/test/tracetesting/recommendation/all.yaml
@@ -0,0 +1,10 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: recommendation-all
+ name: 'Recommendation Service'
+ description: Run all Recommendation Service tests enabled in sequence
+ steps:
+ - ./list.yaml
diff --git a/test/tracetesting/recommendation/list.yaml b/test/tracetesting/recommendation/list.yaml
new file mode 100644
index 0000000..177628e
--- /dev/null
+++ b/test/tracetesting/recommendation/list.yaml
@@ -0,0 +1,25 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: recommendation-list
+ name: 'Recommendation: List products'
+ description: List all products recommended to an user
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:RECOMMENDATION_ADDR}
+ method: oteldemo.RecommendationService.ListRecommendations
+ request: |-
+ {
+ "userId": "1234",
+ "productIds": [ "OLJCESPC7Z", "66VCHSJNUP", "1YMWWN1N4O", "L9ECAV7KIM", "2ZYFJ3GM2N" ]
+ }
+ specs:
+ - name: It called ListRecommendations correctly and got 5 products
+ selector: span[tracetest.span.type="rpc" name="/oteldemo.RecommendationService/ListRecommendations" rpc.system="grpc" rpc.method="ListRecommendations" rpc.service="oteldemo.RecommendationService"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - attr:app.products_recommended.count = 5
diff --git a/test/tracetesting/run.bash b/test/tracetesting/run.bash
new file mode 100755
index 0000000..3842c08
--- /dev/null
+++ b/test/tracetesting/run.bash
@@ -0,0 +1,110 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+#/bin/bash
+
+# This script set up how to run Tracetest and which test files
+# be executed
+
+set -e
+
+# Availalble services to test
+ALL_SERVICES=("ad" "cart" "currency" "checkout" "frontend" "email" "payment" "product-catalog" "recommendation" "shipping")
+
+## Script variables
+# Will contain the list of services to test
+chosen_services=()
+# Array to hold process IDs
+pids=()
+# Array to hold exit codes
+exit_codes=()
+
+## Script functions
+check_if_tracetest_is_installed() {
+ if ! command -v tracetest &> /dev/null
+ then
+ echo "tracetest CLI could not be found"
+ exit -1
+ fi
+}
+
+create_env_file() {
+ cat << EOF > tracetesting-vars.yaml
+type: VariableSet
+spec:
+ id: tracetesting-vars
+ name: tracetesting-vars
+ values:
+ - key: AD_ADDR
+ value: $AD_ADDR
+ - key: CART_ADDR
+ value: $CART_ADDR
+ - key: CHECKOUT_ADDR
+ value: $CHECKOUT_ADDR
+ - key: CURRENCY_ADDR
+ value: $CURRENCY_ADDR
+ - key: EMAIL_ADDR
+ value: $EMAIL_ADDR
+ - key: FRONTEND_ADDR
+ value: $FRONTEND_ADDR
+ - key: PAYMENT_ADDR
+ value: $PAYMENT_ADDR
+ - key: PRODUCT_CATALOG_ADDR
+ value: $PRODUCT_CATALOG_ADDR
+ - key: RECOMMENDATION_ADDR
+ value: $RECOMMENDATION_ADDR
+ - key: SHIPPING_ADDR
+ value: $SHIPPING_ADDR
+ - key: KAFKA_ADDR
+ value: $KAFKA_ADDR
+EOF
+}
+
+run_tracetest() {
+ service_name=$1
+ testsuite_file=./$service_name/all.yaml
+
+ tracetest --config ./cli-config.yml run testsuite --file $testsuite_file --vars ./tracetesting-vars.yaml &
+ pids+=($!)
+}
+
+## Script execution
+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
+
+echo "Starting tests..."
+echo "Running trace-based tests for: ${chosen_services[*]} ..."
+echo ""
+
+for service in "${chosen_services[@]}"; do
+ run_tracetest $service
+done
+
+# Wait for processes to finish and capture their exit codes
+for pid in "${pids[@]}"; do
+ wait $pid
+ exit_codes+=($?)
+done
+
+# Find the maximum exit code
+max_exit_code=0
+for code in "${exit_codes[@]}"; do
+ if [[ $code -gt $max_exit_code ]]; then
+ max_exit_code=$code
+ fi
+done
+
+echo ""
+echo "Tests done! Exit code: $max_exit_code"
+
+exit $max_exit_code
diff --git a/test/tracetesting/shipping/all.yaml b/test/tracetesting/shipping/all.yaml
new file mode 100644
index 0000000..b41610d
--- /dev/null
+++ b/test/tracetesting/shipping/all.yaml
@@ -0,0 +1,12 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: TestSuite
+spec:
+ id: shipping-all
+ name: 'Shipping Service'
+ description: Run all Shipping Service tests enabled in sequence
+ steps:
+ - ./quote.yaml
+ - ./empty-quote.yaml
+ - ./order.yaml
diff --git a/test/tracetesting/shipping/empty-quote.yaml b/test/tracetesting/shipping/empty-quote.yaml
new file mode 100644
index 0000000..ae422d1
--- /dev/null
+++ b/test/tracetesting/shipping/empty-quote.yaml
@@ -0,0 +1,36 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: shipping-empty-quote
+ name: 'Shipping: Empty Quote'
+ description: Quote delivery for no items
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:SHIPPING_ADDR}
+ method: oteldemo.ShippingService.GetQuote
+ request: |-
+ {
+ "address": {
+ "streetAddress": "One Microsoft Way",
+ "city": "Redmond",
+ "state": "Washington",
+ "country": "United States",
+ "zipCode": "98052"
+ },
+ "items": []
+ }
+ specs:
+ - name: It called GetQuote correctly
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ShippingService/GetQuote" rpc.system="grpc"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - name: It returned a valid quote
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.costUsd.currencyCode' = "USD"
+ - attr:tracetest.response.body | json_path '$.costUsd.units' = 0
+ - attr:tracetest.response.body | json_path '$.costUsd.nanos' = 0
diff --git a/test/tracetesting/shipping/order.yaml b/test/tracetesting/shipping/order.yaml
new file mode 100644
index 0000000..8c18f1e
--- /dev/null
+++ b/test/tracetesting/shipping/order.yaml
@@ -0,0 +1,39 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: shipping-order
+ name: 'Shipping: Order'
+ description: Create one delivery order
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:SHIPPING_ADDR}
+ method: oteldemo.ShippingService.ShipOrder
+ request: |-
+ {
+ "address": {
+ "streetAddress": "One Microsoft Way",
+ "city": "Redmond",
+ "state": "Washington",
+ "country": "United States",
+ "zipCode": "98052"
+ },
+ "items": [
+ {
+ "productId": "66VCHSJNUP",
+ "quantity": 2
+ }
+ ]
+ }
+ specs:
+ - name: It called GetQuote correctly
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ShippingService/ShipOrder" rpc.system="grpc"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - name: It returned a trackingId
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.trackingId' != ""
diff --git a/test/tracetesting/shipping/quote.yaml b/test/tracetesting/shipping/quote.yaml
new file mode 100644
index 0000000..c263fa8
--- /dev/null
+++ b/test/tracetesting/shipping/quote.yaml
@@ -0,0 +1,40 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+type: Test
+spec:
+ id: shipping-quote
+ name: 'Shipping: Quote'
+ description: Quote delivery for one order
+ trigger:
+ type: grpc
+ grpc:
+ protobufFile: ../../../pb/demo.proto
+ address: ${var:SHIPPING_ADDR}
+ method: oteldemo.ShippingService.GetQuote
+ request: |-
+ {
+ "address": {
+ "streetAddress": "One Microsoft Way",
+ "city": "Redmond",
+ "state": "Washington",
+ "country": "United States",
+ "zipCode": "98052"
+ },
+ "items": [
+ {
+ "productId": "66VCHSJNUP",
+ "quantity": 2
+ }
+ ]
+ }
+ specs:
+ - name: It called GetQuote correctly
+ selector: span[tracetest.span.type="rpc" name="oteldemo.ShippingService/GetQuote" rpc.system="grpc"]
+ assertions:
+ - attr:rpc.grpc.status_code = 0
+ - name: It returned a valid quote
+ selector: span[tracetest.span.type="general" name="Tracetest trigger"]
+ assertions:
+ - attr:tracetest.response.body | json_path '$.costUsd.currencyCode' = "USD"
+ - attr:tracetest.response.body | json_path '$.costUsd.units' > 0
diff --git a/test/tracetesting/tracetest-config.yaml b/test/tracetesting/tracetest-config.yaml
new file mode 100644
index 0000000..7f24903
--- /dev/null
+++ b/test/tracetesting/tracetest-config.yaml
@@ -0,0 +1,24 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+postgres:
+ host: tracetest-postgres
+ user: postgres
+ password: postgres
+ port: 5432
+ dbname: postgres
+ params: sslmode=disable
+
+telemetry:
+ exporters:
+ collector:
+ serviceName: tracetest
+ sampling: 100
+ exporter:
+ type: collector
+ collector:
+ endpoint: otel-collector:4317
+
+server:
+ telemetry:
+ exporter: collector
diff --git a/test/tracetesting/tracetest-provision.yaml b/test/tracetesting/tracetest-provision.yaml
new file mode 100644
index 0000000..a37cc40
--- /dev/null
+++ b/test/tracetesting/tracetest-provision.yaml
@@ -0,0 +1,37 @@
+# Copyright The OpenTelemetry Authors
+# SPDX-License-Identifier: Apache-2.0
+
+---
+type: PollingProfile
+spec:
+ name: Default
+ strategy: periodic
+ default: true
+ periodic:
+ retryDelay: 5s
+ timeout: 3m
+
+---
+type: Demo
+spec:
+ name: "OpenTelemetry Shop"
+ enabled: true
+ type: otelstore
+ opentelemetryStore:
+ frontendEndpoint: http://frontend:8080
+
+---
+type: DataStore
+spec:
+ name: Opentelemetry Collector pipeline
+ type: otlp
+ default: true
+
+---
+type: TestRunner
+spec:
+ id: current
+ name: default
+ requiredGates:
+ - analyzer-score
+ - test-specs