Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tracetesting): Adding Serverless Synthetic Tests #3658

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/scheduled-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,60 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SYNTETIC_MONITORING_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

pokeshop-serverless-trace-based-tests:
name: Run trace based tests for Pokeshop Serverless
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure Tracetest CLI
uses: kubeshop/tracetest-github-action@v1
with:
token: ${{secrets.TRACETEST_SERVERLESS_POKESHOP_TOKEN}}

- name: Run synthetic monitoring tests
run: |
tracetest run testsuite --file ./testing/synthetic-monitoring/pokeshop-serverless/_testsuite.yaml --vars ./testing/synthetic-monitoring/pokeshop-serverless/_variableset.yaml

- name: Send message on Slack in case of failure
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.24.0
with:
# check the block kit builder docs to understand how it works
# and how to modify it: https://api.slack.com/block-kit
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":warning: Synthetic Monitoring Alert - Serverless Pokeshop Demo :warning:",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Status:*\nFailed"
},
{
"type": "mrkdwn",
"text": "*Pipeline:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow>"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SYNTETIC_MONITORING_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

otel-demo-trace-based-tests:
name: Run trace based tests for Open Telemetry demo
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
type: Test
spec:
id: pokeshop-serverless-demo-add-pokemon
name: Serverless - Pokeshop - Add
description: Add a Pokemon
trigger:
type: http
httpRequest:
method: POST
url: ${var:POKESHOP_API_URL}/pokemon
body: "{\n \"name\": \"meowth\",\n \"type\":\"normal\",\n \"imageUrl\":\"https://assets.pokemon.com/assets/cms2/img/pokedex/full/052.png\",\n \"isFeatured\": true\n}\n"
headers:
- key: Content-Type
value: application/json
specs:
- selector: span[tracetest.span.type="http" name="POST /pokemon"]
name: The POST /pokemon was called correctly
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[tracetest.span.type="database" name="create pokeshop.pokemon" db.operation="create" db.sql.table="pokemon"]
name: A Pokemon was inserted on database
assertions:
- attr:db.result | json_path '$.imageUrl' = "https://assets.pokemon.com/assets/cms2/img/pokedex/full/052.png"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
type: Test
spec:
id: pokeshop-serverless-demo-import-pokemon-queue
name: Serverless - Import a Pokemon using API and Worker
description: Import a Pokemon
trigger:
type: http
httpRequest:
method: POST
url: ${var:POKESHOP_API_URL}/pokemon/import
body: "{\n \"id\": 6\n}\n"
headers:
- key: Content-Type
value: application/json
specs:
- selector: span[tracetest.span.type="http" name="POST /pokemon/import"]
name: POST /pokemon/import was called successfuly
assertions:
- attr:http.request.body contains "6"
- selector: span[tracetest.span.type="messaging" name="queue.synchronizePokemon publish" messaging.system="sqs" messaging.destination="queue.synchronizePokemon" messaging.operation="publish"]
name: A message was enqueued to the worker
assertions:
- attr:messaging.payload | json_path '$.id' = "6"
- selector: span[tracetest.span.type="messaging" name="queue.synchronizePokemon process" messaging.system="sqs" messaging.destination="queue.synchronizePokemon" messaging.operation="process"]
name: A message was read by the worker
assertions:
- attr:messaging.payload | json_path '$.attributes.MessageGroupId' = "queue.synchronizePokemon"
- selector: span[tracetest.span.type="general" name="import pokemon"]
name: A "import pokemon" action was triggered
assertions:
- attr:tracetest.selected_spans.count >= 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type: Test
spec:
id: pokeshop-serverless-demo-list-pokemon
name: Serverless - List Pokemons
trigger:
type: http
httpRequest:
method: GET
url: ${var:POKESHOP_API_URL}/pokemon?take=100&skip=0
headers:
- key: Content-Type
value: application/json
specs:
- selector: span[tracetest.span.type="http" name="GET /pokemon"]
name: GET /pokemon endpoint was called and returned valid data
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[tracetest.span.type="database" name="count pokeshop.pokemon" db.system="postgres" db.name="pokeshop" db.user="ashketchum" db.operation="count" db.sql.table="pokemon"]
name: A count operation was triggered on database
assertions:
- attr:db.operation = "count"
- selector: span[tracetest.span.type="database" name="findMany pokeshop.pokemon" db.system="postgres" db.name="pokeshop" db.user="ashketchum" db.operation="findMany" db.sql.table="pokemon"]
name: A select operation was triggered on database
assertions:
- attr:db.operation = "findMany"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type: Transaction
spec:
id: pokeshop-serverless-demo-test-suite
name: "Serverless - Pokeshop Synthetic tests"
description: Simulate a user doing a series of imports on Pokeshop and listing its results
steps:
- ./01-add-pokemon-with-api.yaml
- ./02-import-pokemon-with-queue.yaml
- ./04-list-pokemons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: VariableSet
spec:
id: tracetesting-vars-serverless
name: tracetesting-vars-serverless
values:
- key: POKESHOP_API_URL
value: https://75yj353nn7.execute-api.us-east-1.amazonaws.com