-
Notifications
You must be signed in to change notification settings - Fork 947
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for frontend service following endpoints used on loadgene…
…rator
- Loading branch information
1 parent
c52d03b
commit 02d7f7b
Showing
9 changed files
with
246 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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://${env: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 | ||
|
||
36 changes: 36 additions & 0 deletions
36
test/tracetesting/frontend-service/02-get-product-recommendation.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,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://${env: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 |
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,32 @@ | ||
# 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://${env: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" | ||
|
||
38 changes: 38 additions & 0 deletions
38
test/tracetesting/frontend-service/04-add-product-to-cart.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,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://${env: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="oteldemo.CartService/AddItem"] | ||
assertions: | ||
- attr:rpc.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" |
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: frontend-view-cart | ||
name: 'Frontend: View cart' | ||
description: Simulate a user viewing the shopping cart | ||
trigger: | ||
type: http | ||
httpRequest: | ||
url: http://${env:FRONTEND_ADDR}/api/cart | ||
method: GET | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
specs: | ||
- name: It called the frontend with success and returned the first item with correct attributes | ||
selector: span[tracetest.span.type="general" name="Tracetest trigger"] | ||
assertions: | ||
- attr:tracetest.response.status = 200 | ||
- attr:tracetest.response.body | json_path '$.items[0].quantity' = 1 | ||
- attr:tracetest.response.body | json_path '$.items[0].productId' = "0PUK6V6EV0" | ||
- name: It retrieved the cart items correctly | ||
selector: span[name="oteldemo.CartService/GetCart"] | ||
assertions: | ||
- attr:rpc.grpc.status_code = 0 |
60 changes: 60 additions & 0 deletions
60
test/tracetesting/frontend-service/06-checking-out-cart.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,60 @@ | ||
# 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://${env: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 | ||
- selector: span[tracetest.span.type="rpc" name="oteldemo.CheckoutService/PlaceOrder" rpc.system="grpc" rpc.method="PlaceOrder" rpc.service="oteldemo.CheckoutService"] | ||
name: "The order was placed" | ||
assertions: | ||
- attr:app.user.id = "2491f868-88f1-4345-8836-d5d8511a9f83" | ||
- attr:app.order.items.count = 1 | ||
- selector: span[tracetest.span.type="rpc" name="oteldemo.PaymentService/Charge" rpc.system="grpc" rpc.method="Charge" rpc.service="oteldemo.PaymentService"] | ||
name: "The user was charged" | ||
assertions: | ||
- attr:rpc.grpc.status_code = 0 | ||
- attr:tracetest.selected_spans.count >= 1 | ||
- selector: span[tracetest.span.type="rpc" name="oteldemo.ShippingService/ShipOrder" rpc.system="grpc" rpc.method="ShipOrder" rpc.service="oteldemo.ShippingService"] | ||
name: "The product was shipped" | ||
assertions: | ||
- attr:rpc.grpc.status_code = 0 | ||
- attr:tracetest.selected_spans.count >= 1 | ||
- selector: span[tracetest.span.type="rpc" name="oteldemo.CartService/EmptyCart" rpc.system="grpc" rpc.method="EmptyCart" rpc.service="oteldemo.CartService"] | ||
name: "The cart was emptied" | ||
assertions: | ||
- attr:rpc.grpc.status_code = 0 | ||
- attr:tracetest.selected_spans.count >= 1 |
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,15 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
type: Transaction | ||
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-see-cart.yaml | ||
- ./06-checking-out-cart.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
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