Skip to content

Commit f214c4f

Browse files
committed
Add trace tests that run with Docker compose
1 parent b250393 commit f214c4f

File tree

6 files changed

+147
-0
lines changed

6 files changed

+147
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine
2+
3+
WORKDIR /app
4+
ARG TRACETEST_IMAGE_VERSION=v1.4.0
5+
6+
RUN apk --update add bash jq curl
7+
RUN curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash -s -- $TRACETEST_IMAGE_VERSION
8+
9+
WORKDIR /resources
10+
11+
ENTRYPOINT ["echo", "Tracetest CLI installed"]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: tracetest
2+
services:
3+
postgres:
4+
environment:
5+
POSTGRES_PASSWORD: postgres
6+
POSTGRES_USER: postgres
7+
healthcheck:
8+
test:
9+
- CMD-SHELL
10+
- pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
11+
timeout: 5s
12+
interval: 1s
13+
retries: 60
14+
image: postgres:14
15+
networks:
16+
default: null
17+
tracetest:
18+
command: --provisioning-file /app/provision.yaml
19+
depends_on:
20+
postgres:
21+
condition: service_healthy
22+
required: true
23+
environment:
24+
TRACETEST_DEV: ${TRACETEST_DEV}
25+
extra_hosts:
26+
- host.docker.internal:host-gateway
27+
healthcheck:
28+
test:
29+
- CMD
30+
- wget
31+
- --spider
32+
- localhost:11633
33+
timeout: 3s
34+
interval: 1s
35+
retries: 60
36+
image: kubeshop/tracetest:v1.7.1
37+
networks:
38+
default: null
39+
ports:
40+
- mode: ingress
41+
target: 11633
42+
published: 11633
43+
protocol: tcp
44+
volumes:
45+
- type: bind
46+
source: ./resources/tracetest.yaml
47+
target: /app/tracetest.yaml
48+
- type: bind
49+
source: ./resources/tracetest-provision.yaml
50+
target: /app/provision.yaml
51+
52+
tracetest-run:
53+
build:
54+
dockerfile: Dockerfile.tracetest
55+
volumes:
56+
- ./resources:/resources
57+
entrypoint:
58+
- bash
59+
- /resources/run.sh
60+
networks:
61+
default: null
62+
depends_on:
63+
tracetest:
64+
condition: service_healthy
65+
networks:
66+
default:
67+
name: tracetest_default
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
type: Test
2+
spec:
3+
id: chatbot-e2e-test
4+
name: Chatbot Trace Test
5+
description: Test to verify the chatbot's response to the work from home policy question.
6+
trigger:
7+
type: http
8+
httpRequest:
9+
method: POST
10+
url: http://host.docker.internal:4000/api/chat
11+
body: "{\"question\": \"What is the work from home policy?\"}"
12+
headers:
13+
- key: Content-Type
14+
value: application/json
15+
specs:
16+
- selector: span[tracetest.span.type="general" service.name="chatbot-rag-app" name="chat gpt-4o-mini"]
17+
assertions:
18+
- attr:event.outcome = "success"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
TOKEN=$TRACETEST_TOKEN
6+
ENVIRONMENT_ID=$TRACETEST_ENVIRONMENT_ID
7+
8+
run() {
9+
echo "Configuring Tracetest"
10+
tracetest configure --server-url http://tracetest:11633
11+
12+
echo "Running Trace-Based Tests..."
13+
tracetest run test -f /resources/chatbot-test.yaml
14+
}
15+
16+
run
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
---
3+
type: Config
4+
spec:
5+
analyticsEnabled: true
6+
---
7+
type: PollingProfile
8+
spec:
9+
name: Custom Profile
10+
strategy: periodic
11+
default: true
12+
periodic:
13+
timeout: 2m
14+
retryDelay: 3s
15+
---
16+
type: DataStore
17+
spec:
18+
id: current
19+
name: elasticapm
20+
type: elasticapm
21+
default: true
22+
elasticapm:
23+
addresses:
24+
- http://host.docker.internal:9200
25+
username: elastic
26+
password: elastic
27+
index: traces-apm-default
28+
insecureSkipVerify: true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
postgres:
2+
host: postgres
3+
user: postgres
4+
password: postgres
5+
port: 5432
6+
dbname: postgres
7+
params: sslmode=disable

0 commit comments

Comments
 (0)