Skip to content

Commit

Permalink
updating pokeshop example
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Aug 16, 2024
1 parent 2e3e43e commit 8fd1a0b
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/tracetest-azure-app-insights-pokeshop/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Get the required information here: https://app.tracetest.io/retrieve-token

TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>"

# Azure
APP_INSIGHTS_ACCESS_TOKEN=""
APP_INSIGHTS_ARM_ID="/subscriptions/<id>/resourceGroups/app-insights-1/providers/microsoft.insights/components/<name>"
APP_INSIGHTS_INSTRUMENTATION_STRING=""
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine

WORKDIR /app
ARG TRACETEST_IMAGE_VERSION=v1.4.0

RUN apk --update add bash jq curl
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION

WORKDIR /resources

ENTRYPOINT ["echo", "Tracetest CLI installed"]
32 changes: 32 additions & 0 deletions examples/tracetest-azure-app-insights-pokeshop/resources/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID
ARM_ID=$APP_INSIGHTS_ARM_ID
ACCESS_TOKEN=$APP_INSIGHTS_ACCESS_TOKEN

apply() {
echo "Configuring TraceTest"
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID

echo "
type: DataStore
spec:
name: azureappinsights
type: azureappinsights
azureappinsights:
connectionType: direct
resourceArmId: ${ARM_ID}
accessToken: ${ACCESS_TOKEN}
useAzureActiveDirectoryAuth: false
" > /resources/datastore.yaml

echo "Applying Resources"
tracetest apply datastore -f /resources/datastore.yaml
tracetest apply pollingprofile -f /resources/pollingprofile.yaml
tracetest apply test -f /resources/test.yaml
}

apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: PollingProfile
spec:
id: azure
name: azure
strategy: periodic
periodic:
retryDelay: 4s
timeout: 10m
16 changes: 16 additions & 0 deletions examples/tracetest-azure-app-insights-pokeshop/resources/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

TOKEN=$TRACETEST_TOKEN
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID

run() {
echo "Configuring Tracetest"
tracetest configure --token $TOKEN --environment $ENVIRONMENT_ID

echo "Running Trace-Based Tests..."
tracetest run test -f /resources/test.yaml
}

run
28 changes: 28 additions & 0 deletions examples/tracetest-azure-app-insights-pokeshop/resources/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type: Test
spec:
id: -ao9stJVg
name: Pokeshop - Import
description: Import a Pokemon
pollingProfile: azure
trigger:
type: http
httpRequest:
url: http://demo-api:8081/pokemon/import
method: POST
headers:
- key: Content-Type
value: application/json
body: '{"id":6}'
specs:
- name: Import Pokemon Span Exists
selector: span[tracetest.span.type="general" name="import pokemon"]
assertions:
- attr:tracetest.selected_spans.count = 1
- name: Uses Correct PokemonId
selector: span[tracetest.span.type="http" name="GET /pokemon/6" http.method="GET"]
assertions:
- attr:http.url = "https://pokeapi.co/api/v2/pokemon/6"
- name: Matching db result with the Pokemon Name
selector: span[tracetest.span.type="database" name="create pokeshop.pokemon"]:first
assertions:
- attr:db.result contains "charizard"

0 comments on commit 8fd1a0b

Please sign in to comment.