Skip to content

Commit

Permalink
Structured tests per service
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Jun 24, 2023
1 parent b4f896d commit c52d03b
Show file tree
Hide file tree
Showing 36 changed files with 224 additions and 201 deletions.
59 changes: 35 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,35 +722,22 @@ services:
build:
context: ./
dockerfile: ./test/tracetesting/Dockerfile
environment:
- AD_SERVICE_ADDR
- CART_SERVICE_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- EMAIL_SERVICE_ADDR
- FRONTEND_ADDR
- PAYMENT_SERVICE_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- RECOMMENDATION_SERVICE_ADDR
- SHIPPING_SERVICE_ADDR
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
tracetest-server:
condition: service_healthy

tracetest-server:
image: kubeshop/tracetest:v0.11.10-rc.2
platform: linux/amd64
container_name: tracetest-server
profiles:
- tests
volumes:
- type: bind
source: ./test/tracetesting/tracetest-config.yaml
target: /app/tracetest.yaml
- type: bind
source: ./test/tracetesting/tracetest-provision.yaml
target: /app/provision.yaml
command: --provisioning-file /app/provision.yaml
ports:
- 11633:11633
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
tracetest-postgres:
condition: service_healthy
otelcol:
condition: service_started
# adding demo services as dependencies
frontend:
condition: service_started
Expand All @@ -774,6 +761,30 @@ services:
condition: service_started
quoteservice:
condition: service_started

tracetest-server:
image: kubeshop/tracetest:latest
platform: linux/amd64
container_name: tracetest-server
profiles:
- tests
volumes:
- type: bind
source: ./test/tracetesting/tracetest-config.yaml
target: /app/tracetest.yaml
- type: bind
source: ./test/tracetesting/tracetest-provision.yaml
target: /app/provision.yaml
command: --provisioning-file /app/provision.yaml
ports:
- 11633:11633
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
tracetest-postgres:
condition: service_healthy
otelcol:
condition: service_started
healthcheck:
test: [ "CMD", "wget", "--spider", "localhost:11633" ]
interval: 1s
Expand Down
7 changes: 1 addition & 6 deletions test/tracetesting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ 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

RUN curl -L https://github.com/kubeshop/tracetest/releases/download/v0.11.10-rc.2/tracetest_0.11.10-rc.2_linux_i386.tar.gz --output /tmp/cli.tar.gz
RUN tar -xf /tmp/cli.tar.gz -C /tmp
RUN mv /tmp/tracetest /usr/local/bin/tracetest
RUN rm -f /tmp/cli.tar.gz
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash

COPY ./test/tracetesting ./test/tracetesting
COPY ./pb ./pb
Expand Down
10 changes: 10 additions & 0 deletions test/tracetesting/ad-service/all.yaml
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
type: Test
spec:
id: ad-get-ads
name: 'Ad: get ads'
description: Retrieve Ads
name: 'Ad: get'
description: Get Ads from API
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: adservice:9555
protobufFile: ../../../pb/demo.proto
address: ${env:AD_SERVICE_ADDR}
method: oteldemo.AdService.GetAds
request: |-
{
Expand Down

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions test/tracetesting/business-tests/user-purchase.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: cartservice:7070
protobufFile: ../../../pb/demo.proto
address: ${env:CART_SERVICE_ADDR}
method: oteldemo.CartService.AddItem
request: |-
{
Expand All @@ -22,9 +22,9 @@ spec:
}
specs:
- name: It added an item correctly into the shopping cart
selector: span[tracetest.span.type="http" name="oteldemo.CartService/AddItem" http.target="/oteldemo.CartService/AddItem" http.method="POST"]
selector: span[name="oteldemo.CartService/AddItem"]
assertions:
- attr:http.status_code = 200
- 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
type: Transaction
spec:
id: cart-all
name: 'Cart: all'
description: Run sequence of cart tests that depends on service state
name: 'Cart Service'
description: Run all Cart tests enabled in sequence
steps:
- ./empty-cart.yaml
- ./add-item-to-cart.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: cartservice:7070
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[tracetest.span.type="http" name="oteldemo.CartService/GetCart" http.target="/oteldemo.CartService/GetCart" http.method="POST"]
selector: span[name="oteldemo.CartService/GetCart"]
assertions:
- attr:http.status_code = 200
- attr:rpc.grpc.status_code = 0
- name: It returned no items
selector: span[tracetest.span.type="general" name="Tracetest trigger"]
assertions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: cartservice:7070
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[tracetest.span.type="http" name="oteldemo.CartService/GetCart" http.target="/oteldemo.CartService/GetCart" http.method="POST"]
selector: span[name="oteldemo.CartService/GetCart"]
assertions:
- attr:http.status_code = 200
- 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: cartservice:7070
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[tracetest.span.type="http" name="oteldemo.CartService/EmptyCart"]
selector: span[name="oteldemo.CartService/EmptyCart"]
assertions:
- attr:http.status_code = 200
- 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"]
selector: span[tracetest.span.type="database" name="EXPIRE" db.system="redis" db.redis.database_index="0"]
assertions:
- attr:db.statement = "EXPIRE 1234"
10 changes: 10 additions & 0 deletions test/tracetesting/checkout-service/all.yaml
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: checkoutservice:5050
protobufFile: ../../../pb/demo.proto
address: ${env:CHECKOUT_SERVICE_ADDR}
method: oteldemo.CheckoutService.PlaceOrder
request: |-
{
Expand Down
11 changes: 11 additions & 0 deletions test/tracetesting/currency-service/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

type: Transaction
spec:
id: currency-service-all
name: 'Currency Service'
description: Run all Currency Service tests enabled in sequence
steps:
- ./convert.yaml
- ./supported.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: currencyservice:7001
protobufFile: ../../../pb/demo.proto
address: ${env:CURRENCY_SERVICE_ADDR}
method: oteldemo.CurrencyService.Convert
request: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ spec:
trigger:
type: grpc
grpc:
protobufFile: ../../../../pb/demo.proto
address: currencyservice:7001
protobufFile: ../../../pb/demo.proto
address: ${env:CURRENCY_SERVICE_ADDR}
method: oteldemo.CurrencyService.GetSupportedCurrencies
specs:
- name: It has a span called "CurrencyService/GetSupportedCurrencies"
Expand Down
10 changes: 10 additions & 0 deletions test/tracetesting/email-service/all.yaml
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: email-service-all
name: 'Email Service'
description: Run all Email Service tests enabled in sequence
steps:
- ./confirmation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
trigger:
type: http
httpRequest:
url: http://emailservice:6060/send_order_confirmation
url: ${env:EMAIL_SERVICE_ADDR}/send_order_confirmation
method: POST
headers:
- key: Content-Type
Expand Down
Loading

0 comments on commit c52d03b

Please sign in to comment.