-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trace based testing examples (#877)
* Adding a user purchasing product trace-based test case * Adding more tests * Adding run script * Fixed yaml lint issues * Adding license header to the files * Adding trace-based tests for more services * Updating tests and adding them on the same format as the integration tests * Fixed payment tests * Fixing e2e web tests * Fixing details found by yamllint * Updating trace-based tests to refer a protobuf file instead of embedding it * Fixed data types for email test and improved test time * Structured tests per service * Added tests for frontend service following endpoints used on loadgenerator * fixing yaml lint issues * Fixing small issues on tests
- Loading branch information
1 parent
5a05737
commit c7588d4
Showing
45 changed files
with
1,292 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
FROM alpine | ||
|
||
WORKDIR /app | ||
|
||
RUN apk --update add bash jq curl | ||
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash | ||
|
||
COPY ./test/tracetesting ./test/tracetesting | ||
COPY ./pb ./pb | ||
|
||
WORKDIR /app/test/tracetesting | ||
|
||
CMD ["/bin/sh", "/app/test/tracetesting/run.bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
type: Transaction | ||
spec: | ||
id: ad-service-all | ||
name: 'Ad Service' | ||
description: Run all Ad Service tests enabled in sequence | ||
steps: | ||
- ./get.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ${env:AD_SERVICE_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/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ${env:CART_SERVICE_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="oteldemo.CartService/AddItem"] | ||
assertions: | ||
- attr:rpc.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}'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
type: Transaction | ||
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 |
27 changes: 27 additions & 0 deletions
27
test/tracetesting/cart-service/check-if-cart-is-empty.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ${env:CART_SERVICE_ADDR} | ||
method: oteldemo.CartService.GetCart | ||
request: |- | ||
{ | ||
"userId": "1234" | ||
} | ||
specs: | ||
- name: It retrieved the cart items correctly | ||
selector: span[name="oteldemo.CartService/GetCart"] | ||
assertions: | ||
- attr:rpc.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' = "[]" |
28 changes: 28 additions & 0 deletions
28
test/tracetesting/cart-service/check-if-cart-is-populated.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ${env:CART_SERVICE_ADDR} | ||
method: oteldemo.CartService.GetCart | ||
request: |- | ||
{ | ||
"userId": "1234" | ||
} | ||
specs: | ||
- name: It retrieved the cart items correctly | ||
selector: span[name="oteldemo.CartService/GetCart"] | ||
assertions: | ||
- attr:rpc.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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ${env:CART_SERVICE_ADDR} | ||
method: oteldemo.CartService.EmptyCart | ||
request: |- | ||
{ | ||
"userId": "1234" | ||
} | ||
specs: | ||
- name: It emptied the shopping cart with success | ||
selector: span[name="oteldemo.CartService/EmptyCart"] | ||
assertions: | ||
- attr:rpc.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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
type: Transaction | ||
spec: | ||
id: checkout-service-all | ||
name: 'Checkout Service' | ||
description: Run all Checkout Service tests enabled in sequence | ||
steps: | ||
- ./place-order.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# 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: ${env:CHECKOUT_SERVICE_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": "[email protected]", | ||
"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 |
Oops, something went wrong.