Skip to content

Commit

Permalink
feat: Example workflows - playwright examples simplified, expected-fa…
Browse files Browse the repository at this point in the history
…il - timeout examples (#6078)

* workflow example: expected-fail-timeout

* playwright workflows simplified - shell instead of cmd/args

* expected fail - timeout examples - activeDeadlineSeconds and Step timeout, playwright example fixed

* expected-fail-k6-test-report-condition-always-no-artifacts updated

* expected-fail-timeout-step updated
  • Loading branch information
tkonieczny authored Dec 19, 2024
1 parent 6af5236 commit 31d5a7b
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 48 deletions.
59 changes: 19 additions & 40 deletions test/playwright/executor-tests/crd-workflow/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,17 @@ spec:
paths:
- test/playwright/executor-tests/playwright-project
container:
image: mcr.microsoft.com/playwright:v1.32.3-focal
resources:
requests:
cpu: 2
memory: 2Gi
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- npm
args:
- ci
shell: "npm ci"
- name: Run tests
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- "npx"
args:
- "--yes"
- "[email protected]"
- "test"
shell: "npx playwright test"
- name: Save artifacts
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
artifacts:
Expand Down Expand Up @@ -61,23 +50,10 @@ spec:
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- npm
args:
- ci
shell: "npm ci"
- name: Run tests
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- "npx"
args:
- "--yes"
- "[email protected]"
- "test"
- "--output"
- "/data/artifacts"
shell: "npx playwright test --output /data/artifacts"
env:
- name: PLAYWRIGHT_HTML_REPORT
value: /data/artifacts/playwright-report
Expand All @@ -91,7 +67,7 @@ spec:
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: playwright-workflow-smoke-v1.32.3-shell
name: playwright-workflow-smoke-v1.32.3-command-args
labels:
core-tests: workflows
spec:
Expand All @@ -110,15 +86,22 @@ spec:
steps:
- name: Install dependencies
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
image: mcr.microsoft.com/playwright:v1.32.3-focal # image on step level
command:
- npm
args:
- ci
- name: Run tests
shell: "npx --yes [email protected] test --output /data/artifacts && cd /data/artifacts && ls -lah"
container:
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- "npx"
args:
- "--yes"
- "[email protected]"
- "test"
- "--output"
- "/data/artifacts"
env:
- name: PLAYWRIGHT_HTML_REPORT
value: /data/artifacts/playwright-report
Expand All @@ -129,7 +112,6 @@ spec:
paths:
- '**/*'
---
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
Expand Down Expand Up @@ -176,6 +158,7 @@ spec:
paths:
- test/playwright/executor-tests/playwright-project
container:
image: mcr.microsoft.com/playwright:v1.32.3-focal
resources:
requests:
cpu: 2
Expand All @@ -184,14 +167,12 @@ spec:
steps:
- name: Install dependencies
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- npm
args:
- ci
- name: Run tests
run:
image: mcr.microsoft.com/playwright:v1.32.3-focal
command:
- "npx"
args:
Expand Down Expand Up @@ -249,7 +230,6 @@ spec:
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
# TODO: Upgrade our Playwright tests to use newer version; Blob reporter was not available in 1.32.3
shell: 'npm install --save-dev @playwright/[email protected] && npm ci'
- name: Run tests
parallel:
Expand All @@ -264,7 +244,7 @@ spec:
- name: Merge reports
condition: always
shell: 'npx playwright merge-reports --reporter=html /data/reports'
artifacts:
artifacts: # artifacts with fetch from parallel steps
paths:
- "playwright-report/**"
---
Expand All @@ -286,7 +266,6 @@ spec:
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
# TODO: Upgrade our Playwright tests to use newer version; Blob reporter was not available in 1.32.3
shell: 'npm install --save-dev @playwright/[email protected] && npm ci'
- name: Run tests
parallel:
Expand All @@ -295,7 +274,7 @@ spec:
- from: /data/repo
run:
shell: 'mkdir /data/artifacts && npx playwright test --reporter=junit --shard {{ index + 1 }}/{{ count }} > /data/artifacts/junit-report{{ index + 1 }}.xml'
artifacts:
artifacts: # artifacts directly on parallel step
workingDir: /data/artifacts/
paths:
- '**/*'
75 changes: 68 additions & 7 deletions test/special-cases/test-workflows/edge-cases-expected-fails.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,72 @@ spec:
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: expected-fail-timeout-activedeadlineseconds
labels:
core-tests: expected-fail
spec:
job:
activeDeadlineSeconds: 1
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-smoke-test.js
container:
resources:
requests:
cpu: 128m
memory: 128Mi
workingDir: /data/repo/test/k6/executor-tests
steps:
- name: Run test
run:
image: grafana/k6:0.43.1
args:
- run
- k6-smoke-test.js
- -e
- K6_ENV_FROM_PARAM=K6_ENV_FROM_PARAM_value
env:
- name: K6_SYSTEM_ENV
value: K6_SYSTEM_ENV_value
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: expected-fail-timeout-step
labels:
core-tests: expected-fail
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/playwright/executor-tests/playwright-project
container:
image: mcr.microsoft.com/playwright:v1.32.3-focal
resources:
requests:
cpu: 2
memory: 2Gi
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
steps:
- name: Install dependencies
shell: "npm ci"
- name: Run tests
timeout: 1s
shell: "npx playwright test"
- name: Save artifacts
workingDir: /data/repo/test/playwright/executor-tests/playwright-project
artifacts:
paths:
- playwright-report/**/*
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: expected-fail-cypress-artifacts-condition-always-with-artifacts
labels:
Expand Down Expand Up @@ -212,14 +278,9 @@ spec:
- run:
args:
- run
- k6-smoke-test.js
env:
- name: K6_WEB_DASHBOARD
value: "true"
- name: K6_WEB_DASHBOARD_EXPORT
value: "/data/artifacts/k6-test-report.html"
- some-incorrect-file-name.js
steps:
- name: Saving artifacts
- name: Saving artifacts # should be run despite step failure
condition: always
workingDir: /data/artifacts
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion test/suites/test-workflows/playwright-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
workflows:
- name: playwright-workflow-smoke-v1.32.3
- name: playwright-workflow-smoke-v1.32.3-custom-report-dir
- name: playwright-workflow-smoke-v1.32.3-shell
- name: playwright-workflow-smoke-v1.32.3-command-args
- name: playwright-workflow-smoke-junit
- name: playwright-workflow-smoke-artifacts-double-asterisk
- name: playwright-workflow-smoke-template
Expand Down

0 comments on commit 31d5a7b

Please sign in to comment.