Skip to content

Commit

Permalink
feat: Locust examples (including distributed) (#6053)
Browse files Browse the repository at this point in the history
* locust example

* example workflows - locust and lucust distributed

* updated after CR

* typo fixed
  • Loading branch information
tkonieczny authored Dec 10, 2024
1 parent 8f3f8de commit f9adfc9
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 0 deletions.
72 changes: 72 additions & 0 deletions test/locust/crd-workflow/smoke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: locust-workflow-smoke
labels:
core-tests: workflows
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/locust/locust-project
container:
workingDir: /data/repo/test/locust/locust-project
steps:
- name: Run test
run:
image: locustio/locust:2.32.3
shell: |
mkdir /data/artifacts
locust -f locust_test.py --host https://testkube-test-page-lipsum.pages.dev/ --headless --users 6 --spawn-rate 3 --run-time 10s --html=/data/artifacts/report.html
artifacts:
paths:
- "/data/artifacts/**"
---
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: distributed-locust-workflow-smoke
labels:
core-tests: workflows
spec:
config:
workers: {type: integer, default: 2}
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/locust/locust-project
services:
master:
transfer:
- from: /data/repo/test/locust/locust-project
count: 1
timeout: 30s # initialization timeout
logs: 'always'
image: locustio/locust:2.32.3
shell: |
mkdir /data/artifacts
cd /data/repo/test/locust/locust-project
locust --master -f locust_test.py --host https://testkube-test-page-lipsum.pages.dev/ --headless \
--users 20 --spawn-rate 10 --run-time 60s --stop-timeout 180 --html=/data/artifacts/report.html
readinessProbe:
tcpSocket:
port: 5557
periodSeconds: 1
steps:
- name: Run test
parallel:
count: 'config.workers'
transfer:
- from: /data/repo
use:
- name: distribute/evenly
container:
workingDir: /data/repo/test/locust/locust-project
paused: true # synchronize running all workers - optional
run:
image: locustio/locust:2.32.3
shell: locust -f - --worker --master-host {{ services.master.0.ip }} --processes {{ config.workers }}
6 changes: 6 additions & 0 deletions test/locust/locust-project/locust_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from locust import HttpUser, task

class locust_example_test(HttpUser):
@task
def locust_example(self):
self.client.get("/")
1 change: 1 addition & 0 deletions test/locust/locust-project/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
locust==2.32.3
12 changes: 12 additions & 0 deletions test/scripts/executor-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,15 @@ workflow-k6-smoke() {
common_workflow_run "$name" "$workflow_crd_file" "$workflow_suite_name" "$workflow_suite_file"
}

workflow-locust-smoke() {
name="Test Workflow - Locust"
workflow_crd_file="test/locust/crd-workflow/smoke.yaml"
workflow_suite_name="locust-workflow-suite"
workflow_suite_file="test/suites/test-workflows/locust-workflow.yaml"

common_workflow_run "$name" "$workflow_crd_file" "$workflow_suite_name" "$workflow_suite_file"
}

workflow-maven-smoke() {
name="Test Workflow - Maven"
workflow_crd_file="test/maven/executor-smoke/crd-workflow/smoke.yaml"
Expand Down Expand Up @@ -581,6 +590,7 @@ main() {
workflow-jmeter-smoke
workflow-junit-smoke
workflow-k6-smoke
workflow-locust-smoke
workflow-maven-smoke
workflow-nunit-smoke
workflow-playwright-smoke
Expand Down Expand Up @@ -617,6 +627,7 @@ main() {
workflow-jmeter-smoke
workflow-junit-smoke
workflow-k6-smoke
workflow-locust-smoke
workflow-maven-smoke
workflow-nunit-smoke
workflow-playwright-smoke
Expand All @@ -638,6 +649,7 @@ main() {
workflow-jmeter-smoke
workflow-junit-smoke
workflow-k6-smoke
workflow-locust-smoke
workflow-maven-smoke
workflow-nunit-smoke
workflow-playwright-smoke
Expand Down
1 change: 1 addition & 0 deletions test/suites/test-workflows/full-smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spec:
- name: jmeter-workflow-suite
- name: junit-workflow-suite
- name: k6-workflow-suite
- name: locust-workflow-suite
- name: maven-workflow-suite
- name: nunit-workflow-suite
- name: playwright-workflow-suite
Expand Down
13 changes: 13 additions & 0 deletions test/suites/test-workflows/locust-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: locust-workflow-suite
labels:
core-tests: workflows-suite
spec:
steps:
- execute:
parallelism: 2
workflows:
- name: locust-workflow-smoke
- name: distributed-locust-workflow-smoke

0 comments on commit f9adfc9

Please sign in to comment.