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

run tests through agent #26

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
9f0828e
run tests through agent
schoren Oct 23, 2023
67e3593
test disable cache
schoren Oct 23, 2023
e299e13
revert
schoren Oct 23, 2023
d015ba5
test improvements to dockerfile
schoren Oct 23, 2023
20c5c26
more tests
schoren Oct 23, 2023
2c70f78
revert
schoren Oct 23, 2023
ad04fde
test maxsock
schoren Oct 24, 2023
079a664
maxsockets
schoren Oct 24, 2023
ce9190b
maxsockets increase
schoren Oct 24, 2023
110af8e
rever
schoren Oct 24, 2023
4866ec0
use rc
schoren Oct 24, 2023
f492c1b
use makefile to run
schoren Oct 24, 2023
b524e39
use makefile to run
schoren Oct 24, 2023
52f5f25
use specific docker compose file
schoren Oct 24, 2023
17ed291
use makefile to run
schoren Oct 24, 2023
23fab53
test
schoren Oct 24, 2023
369cfdb
fix tt cmd
schoren Oct 25, 2023
b3fda05
fix settings
schoren Oct 25, 2023
3306458
fix settings
schoren Oct 25, 2023
5359612
fix settings
schoren Oct 25, 2023
97e6936
fix settings
schoren Oct 25, 2023
7bb1e76
disable kafka
schoren Oct 25, 2023
8b5730a
unexport ports
schoren Oct 25, 2023
0510492
add cli token
schoren Oct 25, 2023
187e349
test
schoren Oct 31, 2023
8d1dbfd
test
schoren Oct 31, 2023
3eeadb2
fix typo
schoren Oct 31, 2023
fff08c2
add verbose
schoren Oct 31, 2023
f83c8df
--wip-- [skip ci]
schoren Nov 3, 2023
04ab793
fix kafka port
schoren Nov 7, 2023
fa5d0ab
run on stage
schoren Nov 7, 2023
8239fe0
check for poke api readiness
schoren Nov 7, 2023
6987414
force update
schoren Nov 7, 2023
e10a68b
debug docker
schoren Nov 7, 2023
0844d4a
fix typo
schoren Nov 7, 2023
fa0ca6e
fix typo
schoren Nov 7, 2023
2e08170
dump log on test fail
schoren Nov 8, 2023
7a33bc9
add delay before tests
schoren Nov 8, 2023
07f0d64
try restarting services to ensure everything is working
schoren Nov 8, 2023
ad5b238
replace rabbitmq
schoren Nov 8, 2023
3c0e0c2
remove restarts
schoren Nov 8, 2023
637bac1
update all dokcer compose
schoren Nov 8, 2023
c77421d
add token
schoren Nov 8, 2023
0050a5c
update tt version
schoren Nov 8, 2023
b1a9aae
use prod
schoren Nov 8, 2023
3d08f18
remove line
schoren Nov 8, 2023
d65214e
remove cloudconfig
schoren Nov 8, 2023
5672c58
pin action to v1
schoren Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,35 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
kubeshop/demo-pokemon-api:latest
kubeshop/demo-pokemon-api:latest

tracet-tests:
needs: [build]
name: Tracetests
runs-on: ubuntu-latest

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

- name: Setup Tracetest
uses: kubeshop/tracetest-agent-action@v1
with:
apiKey: ${{ secrets.TRACETEST_API_KEY }}
token: ${{ secrets.TRACETEST_TOKEN}}

- name: Start pokeshop services
run: |
docker compose -f docker-compose.agent.yml up -d \
|| (docker compose -f docker-compose.agent.yml logs; exit 1)
- name: Wait for pokeshop services
run: |
sleep 15 # it might take some time for docker compose to start up
timeout 60 bash -c 'until nc -z -w 1 localhost '8081' > /dev/null 2>&1; do sleep 1; done; echo "pokeshop http api ready"'
- name: Run tracetests
run: |
tracetest run \
--file ./tracetest/tests/testsuite.yaml \
--vars ./tracetest/tests/vars.agent.yaml \
|| (docker compose -f docker-compose.agent.yml logs; exit 1)

10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ FROM node:20.5.1-alpine as build-ui

WORKDIR /ui
ENV PATH /ui/node_modules/.bin:$PATH
COPY ./web/package.json ./
COPY ./web/package-lock.json ./
COPY ./web/package*.json ./

RUN npm ci --silent
RUN npm ci --maxsockets 1 --silent
COPY ./web ./

RUN npm run build
Expand All @@ -16,7 +15,7 @@ FROM node:alpine as build
WORKDIR /build
RUN npm i -g typescript
COPY ./api/package*.json ./
RUN npm ci
RUN npm ci --maxsockets 1 --silent

COPY ./api ./

Expand All @@ -27,12 +26,11 @@ FROM node:alpine as app

WORKDIR /app
COPY ./api/package.json ./api/package-lock.json ./
RUN npm clean-install

EXPOSE 80

ENV NPM_RUN_COMMAND=api

COPY --from=build /build/node_modules ./node_modules
COPY --from=build /build/.build/* ./
COPY --from=build /build/migrations/* ./migrations/
COPY --from=build-ui /ui/build ./ui
Expand Down
122 changes: 122 additions & 0 deletions docker-compose.agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
services:
db:
image: postgres:14
environment:
POSTGRES_USER: ashketchum
POSTGRES_PASSWORD: squirtle123
POSTGRES_DB: pokeshop
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
interval: 1s
timeout: 5s
retries: 60

cache:
image: redis:6
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 1s
timeout: 3s
retries: 60

queue:
image: cloudamqp/lavinmq:1.2.5
restart: unless-stopped

stream:
image: confluentinc/cp-kafka:latest-ubi8
ports:
- 29092:29092
- 9092:9092
environment:
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://stream:9092,PLAINTEXT_HOST://127.0.0.1:29092
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093,PLAINTEXT_HOST://:29092
- [email protected]:9093
- KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
- KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0
- KAFKA_PROCESS_ROLES=controller,broker
- KAFKA_NODE_ID=1
- KAFKA_METADATA_LOG_SEGMENT_MS=15000
- KAFKA_METADATA_MAX_RETENTION_MS=60000
- KAFKA_METADATA_LOG_MAX_RECORD_BYTES_BETWEEN_SNAPSHOTS=2800
- KAFKA_AUTO_CREATE_TOPICS_ENABLE=true
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
- KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1
- KAFKA_HEAP_OPTS=-Xmx200m -Xms200m
- CLUSTER_ID=ckjPoprWQzOf0-FuNkGfFQ
healthcheck:
test: nc -z stream 9092
start_period: 10s
interval: 5s
timeout: 10s
retries: 10

api:
image: kubeshop/demo-pokemon-api:latest
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
REDIS_URL: cache
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
RABBITMQ_HOST: guest:guest@queue
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://host.docker.internal:4317
ZIPKIN_URL: http://localhost:9411
healthcheck:
test: ['CMD', 'wget', '--spider', 'localhost:8081/pokemon/healthcheck']
interval: 1s
timeout: 3s
retries: 60
ports:
- 8081:8081
- 8082:8082
depends_on:
db:
condition: service_healthy
cache:
condition: service_healthy
queue:
condition: service_healthy

worker:
image: kubeshop/demo-pokemon-api:latest
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
REDIS_URL: cache
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
RABBITMQ_HOST: guest:guest@queue
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://host.docker.internal:4317
ZIPKIN_URL: http://localhost:9411
NPM_RUN_COMMAND: worker
depends_on:
db:
condition: service_healthy
cache:
condition: service_healthy
queue:
condition: service_healthy

streaming-worker:
image: kubeshop/demo-pokemon-api:latest
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://host.docker.internal:4317
ZIPKIN_URL: http://localhost:9411
NPM_RUN_COMMAND: stream-worker
KAFKA_BROKER: 'stream:9092'
KAFKA_TOPIC: 'pokemon'
KAFKA_CLIENT_ID: 'streaming-worker'
REDIS_URL: cache
depends_on:
db:
condition: service_healthy
stream:
condition: service_healthy
cache:
condition: service_healthy
15 changes: 5 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ services:
retries: 60

queue:
image: rabbitmq:3.12
image: cloudamqp/lavinmq:1.2.5
restart: unless-stopped
ports:
- 5672:5672
- 15672:15672
healthcheck:
test: rabbitmq-diagnostics -q check_running
interval: 1s
timeout: 5s
retries: 60

jaeger:
image: jaegertracing/all-in-one:latest
Expand Down Expand Up @@ -78,7 +73,7 @@ services:
environment:
REDIS_URL: cache
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
RABBITMQ_HOST: queue
RABBITMQ_HOST: guest:guest@queue
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://otel-collector:4317
ZIPKIN_URL: http://localhost:9411
Expand All @@ -100,13 +95,13 @@ services:
condition: service_healthy
otel-collector:
condition: service_started

rpc:
build: .
environment:
REDIS_URL: cache
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
RABBITMQ_HOST: queue
RABBITMQ_HOST: guest:guest@queue
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://otel-collector:4317
ZIPKIN_URL: http://localhost:9411
Expand Down Expand Up @@ -135,7 +130,7 @@ services:
environment:
REDIS_URL: cache
DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public
RABBITMQ_HOST: queue
RABBITMQ_HOST: guest:guest@queue
POKE_API_BASE_URL: https://pokeapi.co/api/v2
COLLECTOR_ENDPOINT: http://otel-collector:4317
ZIPKIN_URL: http://localhost:9411
Expand Down
8 changes: 5 additions & 3 deletions tracetest/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ services:
- type: bind
source: ./tracetest/config/tracetest-cli.yaml
target: /app/tracetest-cli.yaml
entrypoint:
entrypoint:
- tracetest
command:
command:
- run
- testsuite
- --config
- /app/tracetest-cli.yaml
- --file
- /app/tracebased-tests/testsuite.yaml
- --vars
- /app/tracebased-tests/vars.docker.yaml
depends_on:
tracetest-server:
condition: service_healthy

tracetest-server:
image: kubeshop/tracetest:${TAG:-latest}
volumes:
Expand Down
2 changes: 1 addition & 1 deletion tracetest/tests/add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
type: http
httpRequest:
method: POST
url: http://api:8081/pokemon
url: http://${var:API_HOST}/pokemon
body: |
{
"name": "meowth",
Expand Down
2 changes: 1 addition & 1 deletion tracetest/tests/importqueue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
type: http
httpRequest:
method: POST
url: http://api:8081/pokemon/import
url: http://${var:API_HOST}/pokemon/import
body: |
{
"id": 143
Expand Down
4 changes: 2 additions & 2 deletions tracetest/tests/importstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
type: kafka
kafka:
brokerUrls:
- stream:9092
- ${env:KAFKA_HOST}
topic: pokemon
headers: []
messageKey: snorlax-key
Expand All @@ -20,4 +20,4 @@ spec:
- selector: span[tracetest.span.type="general" name="import pokemon"]
name: Import Pokemon use case was triggered
assertions:
- attr:name = "import pokemon"
- attr:name = "import pokemon"
2 changes: 1 addition & 1 deletion tracetest/tests/list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
type: http
httpRequest:
method: GET
url: http://api:8081/pokemon?take=20&skip=0
url: http://${var:API_HOST}/pokemon?take=20&skip=0
headers:
- key: Content-Type
value: application/json
Expand Down
4 changes: 2 additions & 2 deletions tracetest/tests/testsuite.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: Transaction
type: TestSuite
spec:
id: ILYjqDQ4g
name: Running all tests
Expand All @@ -7,4 +7,4 @@ spec:
- ./add.yaml
- ./importqueue.yaml
- ./importstream.yaml
- ./list.yaml
- ./list.yaml
9 changes: 9 additions & 0 deletions tracetest/tests/vars.agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type: VariableSet
spec:
id: agent
name: Agent Values
values:
- key: API_HOST
value: localhost:8081
- key: KAFKA_HOST
value: localhost:29092
9 changes: 9 additions & 0 deletions tracetest/tests/vars.docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type: VariableSet
spec:
id: docker
name: Docker Values
values:
- key: API_HOST
value: api:8081
- key: KAFKA_HOST
value: stream:9092
Loading