forked from kubeshop/tracetest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): artillery integration example (kubeshop#3664)
* feat(docs): artillery integration example * fix testFile key * remove token * --wip-- [skip ci] * --wip-- [skip ci] * set basic flow * adding shared context * fix examples * . * cleanup * adding recipies and examples * cleanup * chore(examples): Adding Artillery + Playwright + Tracetest example (kubeshop#3709) * chore(examples): Adding Artillery + Playwright + Tracetest example * docs(recipes): add pw + artillery + tt --------- Co-authored-by: Adnan Rahic <ado.raha198@gmail.com> --------- Co-authored-by: Automation <automation@schoren.me> Co-authored-by: Oscar Reyes <oscar-rreyes1@hotmail.com> Co-authored-by: Adnan Rahic <ado.raha198@gmail.com>
- Loading branch information
1 parent
a3d8735
commit c861835
Showing
30 changed files
with
21,699 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
342 changes: 342 additions & 0 deletions
342
...s/recipes/running-playwright-performance-tests-with-artillery-and-tracetest.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TRACETEST_AGENT_API_KEY= | ||
TRACETEST_API_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Tracetest + Artillery + Playwright | ||
|
||
> [Read the detailed recipe for setting up Tracetest + Artillery + Playwright in our documentation.](https://docs.tracetest.io/examples-tutorials/recipes/running-playwright-performance-tests-with-artillery-and-tracetest) | ||
This is a quick start showing how you can create programs to run trace-based tests from your Artillery x Playwright setup utilizing the `@tracetest/playwright` NPM package. The example shows how to define the Tracetest tests, execute them, and wait for results to be ready. [Read the Tracetest + Artillery + Playwright Quick Start Docs](https://docs.tracetest.io/examples-tutorials/recipes/running-playwright-performance-tests-with-artillery-and-tracetest) to see how to run this example. |
8 changes: 8 additions & 0 deletions
8
examples/quick-start-artillery-playwright/artillery-playwright.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
config: | ||
target: http://localhost:8081 | ||
engines: | ||
playwright: {} | ||
processor: home.spec.ts | ||
scenarios: | ||
- engine: playwright | ||
testFunction: importPokemon |
35 changes: 35 additions & 0 deletions
35
examples/quick-start-artillery-playwright/collector.config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
cors: | ||
allowed_origins: | ||
- "http://*" | ||
- "https://*" | ||
|
||
processors: | ||
batch: | ||
|
||
exporters: | ||
logging: | ||
loglevel: debug | ||
jaeger: | ||
endpoint: ${JAEGER_ENDPOINT} | ||
tls: | ||
insecure: true | ||
otlp/trace: | ||
endpoint: tracetest-agent:4317 | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [logging, jaeger] | ||
traces/1: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [otlp/trace] |
146 changes: 146 additions & 0 deletions
146
examples/quick-start-artillery-playwright/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
version: "3.5" | ||
name: pokeshop | ||
|
||
services: | ||
tracetest-agent: | ||
environment: | ||
TRACETEST_API_KEY: ${TRACETEST_AGENT_API_KEY} | ||
image: kubeshop/tracetest-agent:latest | ||
networks: | ||
default: null | ||
|
||
# pokeshop demo services | ||
postgres: | ||
image: postgres:14 | ||
ports: | ||
- 5434:5432 | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: postgres | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] | ||
interval: 1s | ||
timeout: 5s | ||
retries: 60 | ||
|
||
cache: | ||
image: redis:6 | ||
ports: | ||
- 6379:6379 | ||
healthcheck: | ||
test: ["CMD", "redis-cli", "ping"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 | ||
|
||
queue: | ||
image: rabbitmq:3.12 | ||
restart: unless-stopped | ||
ports: | ||
- 5672:5672 | ||
- 15672:15672 | ||
healthcheck: | ||
test: rabbitmq-diagnostics -q check_running | ||
interval: 1s | ||
timeout: 5s | ||
retries: 60 | ||
|
||
otel-collector: | ||
image: otel/opentelemetry-collector-contrib:0.59.0 | ||
restart: unless-stopped | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
ports: | ||
- 4317:4317 | ||
- 4318:4318 | ||
command: | ||
- "--config" | ||
- "/otel-local-config.yaml" | ||
volumes: | ||
- ./collector.config.yaml:/otel-local-config.yaml | ||
environment: | ||
- JAEGER_ENDPOINT=jaeger:14250 | ||
depends_on: | ||
jaeger: | ||
condition: service_healthy | ||
|
||
api: | ||
image: kubeshop/demo-pokemon-api:latest | ||
restart: unless-stopped | ||
pull_policy: always | ||
environment: | ||
REDIS_URL: cache | ||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public | ||
RABBITMQ_HOST: queue | ||
POKE_API_BASE_URL: https://pokeapi.co/api/v2 | ||
COLLECTOR_ENDPOINT: http://otel-collector:4317 | ||
HTTP_COLLECTOR_ENDPOINT: http://localhost:4318/v1/traces | ||
NPM_RUN_COMMAND: api | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "localhost:8081"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 | ||
ports: | ||
- 8081:8081 | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
cache: | ||
condition: service_healthy | ||
queue: | ||
condition: service_healthy | ||
|
||
worker: | ||
image: kubeshop/demo-pokemon-api:latest | ||
restart: unless-stopped | ||
pull_policy: always | ||
environment: | ||
REDIS_URL: cache | ||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public | ||
RABBITMQ_HOST: queue | ||
POKE_API_BASE_URL: https://pokeapi.co/api/v2 | ||
COLLECTOR_ENDPOINT: http://otel-collector:4317 | ||
NPM_RUN_COMMAND: worker | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
cache: | ||
condition: service_healthy | ||
queue: | ||
condition: service_healthy | ||
|
||
rpc: | ||
image: kubeshop/demo-pokemon-api:latest | ||
restart: unless-stopped | ||
pull_policy: always | ||
environment: | ||
REDIS_URL: cache | ||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres?schema=public | ||
RABBITMQ_HOST: queue | ||
POKE_API_BASE_URL: https://pokeapi.co/api/v2 | ||
COLLECTOR_ENDPOINT: http://otel-collector:4317 | ||
NPM_RUN_COMMAND: rpc | ||
healthcheck: | ||
test: ["CMD", "lsof", "-i", "8082"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
cache: | ||
condition: service_healthy | ||
queue: | ||
condition: service_healthy | ||
|
||
jaeger: | ||
image: jaegertracing/all-in-one:latest | ||
ports: | ||
- 16686:16686 | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "localhost:16686"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Page } from 'playwright'; | ||
import { expect } from '@playwright/test'; | ||
import Tracetest from '@tracetest/playwright'; | ||
import { config } from 'dotenv'; | ||
|
||
config(); | ||
|
||
const { TRACETEST_API_TOKEN = '' } = process.env; | ||
|
||
const definition = ` | ||
type: Test | ||
spec: | ||
id: artillery-playwight-import-pokemon | ||
name: "Artillery Playwright - Import Pokemon" | ||
trigger: | ||
type: playwright | ||
specs: | ||
- selector: span[tracetest.span.type="general" name = "validate request"] span[tracetest.span.type="http"] | ||
name: "All HTTP Spans: Status code is 200" | ||
assertions: | ||
- attr:http.status_code = 200 | ||
- selector: span[tracetest.span.type="http" name="GET" http.method="GET"] | ||
assertions: | ||
- attr:http.route = "/api/v2/pokemon/\${var:POKEMON_ID}" | ||
- selector: span[tracetest.span.type="database"] | ||
name: "All Database Spans: Processing time is less than 1s" | ||
assertions: | ||
- attr:tracetest.span.duration < 1s | ||
outputs: | ||
- name: DATABASE_POKEMON_ID | ||
selector: span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres" db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"] | ||
value: attr:db.result | json_path '$.id' | ||
`; | ||
|
||
export async function importPokemon(page: Page) { | ||
const tracetest = await Tracetest({ apiToken: TRACETEST_API_TOKEN }); | ||
const title = 'Artillery Playwright - Import Pokemon'; | ||
const pokemonId = Math.floor(Math.random() * 101).toString(); | ||
await page.goto('/'); | ||
|
||
await tracetest?.setOptions({ | ||
[title]: { | ||
definition, | ||
runInfo: { | ||
variables: [ | ||
{ | ||
key: 'POKEMON_ID', | ||
value: pokemonId, | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
|
||
await tracetest?.capture(title, page); | ||
|
||
expect(await page.getByText('Pokeshop')).toBeTruthy(); | ||
|
||
await page.click('text=Import'); | ||
|
||
await page.getByLabel('ID').fill(pokemonId); | ||
await page.getByRole('button', { name: 'OK', exact: true }).click(); | ||
|
||
await tracetest?.summary(); | ||
} |
29 changes: 29 additions & 0 deletions
29
examples/quick-start-artillery-playwright/import-pokemon.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
type: Test | ||
spec: | ||
id: artillery-engine-import-pokemon | ||
name: "Artillery Engine: Import Pokemon" | ||
trigger: | ||
type: http | ||
httpRequest: | ||
method: POST | ||
url: ${var:ENDPOINT}/pokemon/import | ||
body: '{"id": ${var:POKEMON_ID}}' | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
specs: | ||
- selector: span[tracetest.span.type="general" name = "validate request"] span[tracetest.span.type="http"] | ||
name: "All HTTP Spans: Status code is 200" | ||
assertions: | ||
- attr:http.status_code = 200 | ||
- selector: span[tracetest.span.type="http" name="GET" http.method="GET"] | ||
assertions: | ||
- attr:http.route = "/api/v2/pokemon/${var:POKEMON_ID}" | ||
- selector: span[tracetest.span.type="database"] | ||
name: "All Database Spans: Processing time is less than 1s" | ||
assertions: | ||
- attr:tracetest.span.duration < 1s | ||
outputs: | ||
- name: DATABASE_POKEMON_ID | ||
selector: span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres" db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"] | ||
value: attr:db.result | json_path '$.id' |
Oops, something went wrong.