File tree Expand file tree Collapse file tree 8 files changed +104
-0
lines changed
stable/network-performance-testing Expand file tree Collapse file tree 8 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 1+ deploy a distributed load testing framework that uses multiple containers to create traffic for a simple REST-based API
Original file line number Diff line number Diff line change 1+ FROM python:3.9.12-slim-bullseye
2+
3+ # Add the external tasks directory into /tasks
4+ ADD locust-tasks /locust-tasks
5+
6+ # Install the required dependencies via pip
7+ RUN pip install -r /locust-tasks/requirements.txt
8+
9+ # Expose the required Locust ports
10+ EXPOSE 5557 5558 8089
11+
12+ # Set script to be executable
13+ RUN chmod 755 /locust-tasks/run.sh
14+
15+ # Start Locust using LOCUS_OPTS environment variable
16+ ENTRYPOINT ["/locust-tasks/run.sh" ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ eval $( minikube docker-env)
3+ docker build -t locust-tasks .
Original file line number Diff line number Diff line change 1+ Brotli == 1.0.9
2+ certifi == 2021.10.8
3+ chardet == 4.0.0
4+ charset-normalizer == 2.0.12
5+ click == 8.1.2
6+ ConfigArgParse == 1.5.3
7+ Flask == 2.1.1
8+ Flask-BasicAuth == 0.2.0
9+ Flask-Cors == 3.0.10
10+ gevent == 21.12.0
11+ geventhttpclient == 1.5.3
12+ greenlet == 1.1.2
13+ idna == 3.3
14+ importlib-metadata == 4.11.3
15+ itsdangerous == 2.1.2
16+ Jinja2 == 3.0.3
17+ locust == 2.8.6
18+ MarkupSafe == 2.1.1
19+ msgpack == 1.0.3
20+ msgpack-python == 0.5.6
21+ psutil == 5.9.0
22+ pyzmq == 22.3.0
23+ requests == 2.27.1
24+ roundrobin == 0.0.2
25+ six == 1.16.0
26+ typing_extensions == 4.1.1
27+ urllib3 == 1.26.9
28+ Werkzeug == 2.1.1
29+ zipp == 3.8.0
30+ zope.event == 4.5.0
31+ zope.interface == 5.4.0
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ LOCUST=" /usr/local/bin/locust"
4+ LOCUS_OPTS=" -f /locust-tasks/tasks.py --host=$TARGET_HOST "
5+ LOCUST_MODE=${LOCUST_MODE:- standalone}
6+
7+ if [[ " $LOCUST_MODE " = " master" ]]; then
8+ LOCUS_OPTS=" $LOCUS_OPTS --master"
9+ elif [[ " $LOCUST_MODE " = " worker" ]]; then
10+ LOCUS_OPTS=" $LOCUS_OPTS --worker --master-host=$LOCUST_MASTER "
11+ fi
12+
13+ echo " $LOCUST $LOCUS_OPTS "
14+
15+ $LOCUST $LOCUS_OPTS
Original file line number Diff line number Diff line change 1+ import uuid
2+
3+ from datetime import datetime
4+ from locust import FastHttpUser , TaskSet , task
5+
6+
7+ # [START locust_test_task]
8+
9+ class MetricsTaskSet (TaskSet ):
10+ _deviceid = None
11+
12+ def on_start (self ):
13+ self ._deviceid = str (uuid .uuid4 ())
14+
15+ @task (1 )
16+ def login (self ):
17+ self .client .post (
18+ '/login' , {"deviceid" : self ._deviceid })
19+
20+ @task (999 )
21+ def post_metrics (self ):
22+ self .client .post (
23+ "/metrics" , {"deviceid" : self ._deviceid , "timestamp" : datetime .now ()})
24+
25+
26+ class MetricsLocust (FastHttpUser ):
27+ tasks = {MetricsTaskSet }
Original file line number Diff line number Diff line change 1+ apiVersion : kustomize.config.k8s.io/v1beta1
2+ kind : Kustomization
3+ namespace : sandbox
4+ resources :
5+ - namespace.yaml
6+ - ../../base/cfk-components/confluent-no-auth-tls
7+ - ../../base/cfk-components/confluent-no-auth-tls/schmea-registry
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Namespace
3+ metadata :
4+ name : sandbox
You can’t perform that action at this time.
0 commit comments