Skip to content

Commit

Permalink
Adding trace-based tests for more services
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Jun 22, 2023
1 parent 32c0e72 commit d129654
Show file tree
Hide file tree
Showing 18 changed files with 3,282 additions and 23 deletions.
4 changes: 0 additions & 4 deletions test/tracetesting/business-tests/environment-vars.env

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ spec:
trigger:
type: http
httpRequest:
url: ${env:CART_API_URL}
url: http://frontend:8080/api/cart
method: POST
headers:
- key: Content-Type
value: application/json
body: '{"item":{"productId":"${env:PRODUCT_ID}","quantity":1},"userId":"${env:USER_ID}"}'
body: '{"item":{"productId":"OLJCESPC7Z","quantity":1},"userId":"2491f868-88f1-4345-8836-d5d8511a9f83"}'
specs:
- name: "The product was persisted correctly on the shopping cart"
selector: span[name="oteldemo.CartService/AddItem"]
assertions:
- attr:app.product.id = "${env:PRODUCT_ID}"
- attr:app.product.id = "OLJCESPC7Z"
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ spec:
trigger:
type: http
httpRequest:
url: ${env:CHECKOUT_API_URL}
url: http://frontend:8080/api/checkout
method: POST
headers:
- key: Content-Type
value: application/json
body: |
{
"userId": "${env:USER_ID}",
"userId": "2491f868-88f1-4345-8836-d5d8511a9f83",
"email": "[email protected]",
"address": {
"streetAddress": "1600 Amphitheatre Parkway",
Expand All @@ -37,7 +37,7 @@ spec:
- 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 = "${env:USER_ID}"
- 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"
Expand Down
23 changes: 11 additions & 12 deletions test/tracetesting/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ run_tracetest() {
return $?
}

run_tracetest_with_env() {
test_file=$1
env_file=$2

tracetest -c ./cli-config.yml test run -d $test_file --environment $env_file -w
return $?
}

check_if_tracetest_is_installed

echo "Starting tests..."
Expand All @@ -39,14 +31,21 @@ EXIT_STATUS=0
# run tech based tests
echo ""
echo "Running tech based tests..."
run_tracetest ./tech-based-tests/ad-get.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/currency-convert.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/currency-supported.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/ad-service/get.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/cart-service/all.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/currency-service/convert.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/currency-service/supported.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/checkout-service/place-order.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/email-service/confirmation.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/payment-service/valid-credit-card.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/payment-service/invalid-credit-card.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/payment-service/amex-credit-card-not-allowed.yaml || EXIT_STATUS=$?
run_tracetest ./tech-based-tests/payment-service/expired-credit-card.yaml || EXIT_STATUS=$?

# run business tests
echo ""
echo "Running business based tests..."
run_tracetest_with_env ./business-tests/user-purchase.yaml ./business-tests/environment-vars.env || EXIT_STATUS=$?
run_tracetest ./business-tests/user-purchase.yaml || EXIT_STATUS=$?

echo ""
echo "Tests done! Exit code: $EXIT_STATUS"
Expand Down
Loading

0 comments on commit d129654

Please sign in to comment.