summaryrefslogtreecommitdiff
path: root/test/tracetesting/cart
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/tracetesting/cart
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'test/tracetesting/cart')
-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
5 files changed, 131 insertions, 0 deletions
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"