Skip to content

Commit

Permalink
feat(tracetesting): Adding Serverless Synthetic Tests (#3658)
Browse files Browse the repository at this point in the history
* feat(tracetesting): Adding Serverless Synthetic Tests

* feat(tracetesting): Validating new RC

* feat(tracetesting): Validating new RC

* feat(tracetesting): Updating definitions

* feat(tracetesting): Updaing token
  • Loading branch information
xoscar committed Feb 19, 2024
1 parent 6942e65 commit 271e00d
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/scheduled-jobs.yml
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
@@ -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"
@@ -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
@@ -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"
@@ -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
@@ -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

0 comments on commit 271e00d

Please sign in to comment.