From 82e03978b89938219958032efb1448cc76baa181 Mon Sep 17 00:00:00 2001 From: Saumit Date: Sat, 27 Sep 2025 02:14:26 +0530 Subject: Initial snapshot - OpenTelemetry demo 2.1.3 -f --- test/tracetesting/frontend/01-see-ads.yaml | 35 ++++++++++++ .../frontend/02-get-product-recommendation.yaml | 36 ++++++++++++ test/tracetesting/frontend/03-browse-product.yaml | 31 +++++++++++ .../frontend/04-add-product-to-cart.yaml | 38 +++++++++++++ test/tracetesting/frontend/05-view-cart.yaml | 25 +++++++++ .../frontend/06-checking-out-cart.yaml | 64 ++++++++++++++++++++++ test/tracetesting/frontend/all.yaml | 15 +++++ 7 files changed, 244 insertions(+) create mode 100644 test/tracetesting/frontend/01-see-ads.yaml create mode 100644 test/tracetesting/frontend/02-get-product-recommendation.yaml create mode 100644 test/tracetesting/frontend/03-browse-product.yaml create mode 100644 test/tracetesting/frontend/04-add-product-to-cart.yaml create mode 100644 test/tracetesting/frontend/05-view-cart.yaml create mode 100644 test/tracetesting/frontend/06-checking-out-cart.yaml create mode 100644 test/tracetesting/frontend/all.yaml (limited to 'test/tracetesting/frontend') 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 -- cgit v1.2.3