Skip to content

Commit 33571e3

Browse files
authored
Add distributed locust (#43)
1 parent 6ef2b87 commit 33571e3

File tree

2 files changed

+174
-55
lines changed

2 files changed

+174
-55
lines changed

README.md

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ identify bottlenecks and slow operations.
1111

1212
## Quickstart
1313

14-
The test suite is designed to run in-cluster and is fairly simple to start.
14+
The test suite is designed to run both in-cluster and on local and is fairly simple to start.
1515
There are a few prerequisites and they will be explained below.
1616

1717
### Prerequisites
@@ -24,52 +24,6 @@ There are a few prerequisites and they will be explained below.
2424
permissions (checkboxes) granted. Hold on to this token as it will be used
2525
later.
2626

27-
### Execution
28-
29-
The test suite will run as a collection of jobs within the Kubernetes cluster.
30-
It is recommended to use a separate namespace for the tests.
31-
32-
In this repository, there is a Job YAML file which will deploy the performance
33-
tests. This YAML file specifies some environment variables which should be
34-
overridden for your specific environment. The deployment file also creates
35-
a service account used for the Job(s) and deploys a Redis instance used as a
36-
central queue.
37-
38-
1. Ensure the Job can run privileged. In Openshift, you may have to run
39-
`oc adm policy add-scc-to-user privileged system:serviceaccount:$NAMESPACE:default`
40-
2. Edit the deployment file `deploy/test.job.yaml`
41-
1. Change `QUAY_HOST` to the value of your Quay deployment's URL. This
42-
should match the value of `SERVER_HOSTNAME` in Quay's `config.yaml`.
43-
2. Change `QUAY_OAUTH_TOKEN` to the value of the token you created for
44-
your application during the prerequisites.
45-
3. Change `QUAY_ORG` to the name of the organization you created during
46-
the prerequisites. Example: `test`.
47-
4. Change `ES_HOST` to the hostname of your Elasticsearch instance.
48-
5. Change `ES_PORT` to the port number your Elasticsearch instance is
49-
listening on.
50-
3. Deploy the performance tests job: `kubectl create -f deploy/test.job.yaml -n $NAMESPACE`
51-
52-
At this point, a Job with a single pod should be running. The job will output
53-
a decent amount of information to the logs if you'd like to watch its progress.
54-
Eventually, the Job gets to a point where it will perform tests against the
55-
registry aspects of the container (using podman) and will create other Jobs to
56-
execute those operations.
57-
58-
## Environment Variables
59-
60-
The following environment variables can be specified in the Job's deployment
61-
file to change the behavior of the tests.
62-
63-
| Key | Type | Required | Description |
64-
| --- | ---- | :------: | ----------- |
65-
| QUAY_HOST | string | y | hostname of Quay instance to test |
66-
| QUAY_OAUTH_TOKEN | string | y | Quay Application OAuth Token. Used for authentication purposes on certain API endpoints. |
67-
| QUAY_ORG | string | y | The organization which will contain all created resources during the tests. |
68-
| ES_HOST | string | y | Hostname of the Elasticsearch instance used to store the test results. |
69-
| ES_PORT | string | y | Port of the Elasticsearch instance used for storing test results. |
70-
| BATCH_SIZE | string | n | Number of items to pop off the queue in each batch. This primarily applies to the registry push and pull tests. Do not exceed 400 until the known issue is resolved. |
71-
| CONCURRENCY | int | n | Defaults to 4. The quantity of requests or test executions to perform in parallel. |
72-
7327
## Changelog
7428

7529
**v0.1.0**
@@ -118,11 +72,10 @@ known issues:
11872
### Setup
11973

12074
The project expects the following environment variables:
121-
- PODMAN_USERNAME: Username to log into Podman
122-
- PODMAN_PASSWORD: Password for the above user
123-
- PODMAN_HOST: The url of the host registry where images will be pushed
124-
- QUAY_HOST: The url where Quay is hosted
125-
- OAUTH_TOKEN: The Authorization Token to enable API calls(On Quay: Create an organization followed by creating an application in the organization. Generate token for the application.)
75+
- `QUAY_USERNAME`: Username to log into Podman
76+
- `QUAY_PASSWORD`: Password for the above user
77+
- `QUAY_HOST`: The url where Quay is hosted
78+
- `OAUTH_TOKEN`: The Authorization Token to enable API calls(On Quay: Create an organization followed by creating an application in the organization. Generate token for the application.)
12679

12780
### Building
12881

@@ -156,13 +109,28 @@ the number of users defined in `testfiles/run.py` to run all user classes.
156109

157110
The tests are run via locust in distributed mode. There is a single master
158111
which controls multiple worker pods. The number of replicas for the workers are
159-
defined in `deploy/locust-distributed.yaml` file.
112+
defined in `deploy/locust-distributed.yaml.example` file.
113+
114+
Copy the `deploy/locust-distribyted.yaml.example` file to `deploy/locust-distributed.yaml`
115+
116+
117+
```
118+
cp deploy/locust-distribyted.yaml.example deploy/locust-distributed.yaml
119+
```
160120

161-
Edit the `ConfigMap` `quay-locust-config` in the
162-
`deploy/locust-distributed.yaml` and set the variables accordingly
121+
1. Replace the placeholder `NAMESPACE` with your namespace
122+
2. Edit the `ConfigMap` `quay-locust-config` in the `deploy/locust-distributed.yaml` and set the variables accordingly
123+
3. If you want to use a different image update the `image` field in the master and worker deployment
124+
4. Change the `replicas` field in the `worker` Deployment to the number you need (default is 2 workers)
163125

164126
Deploy locust on the cluster by running:
165127

166128
```
167129
kubectl apply -f deploy/locust-distributed.yaml
168130
```
131+
132+
This should deploy locust in distributed mode on the cluster. To access the web UI port-foward it locally
133+
134+
```
135+
kubectl port-forward svc/locust-master -n <namespace> 8089
136+
```
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: NAMESPACE
5+
---
6+
apiVersion: v1
7+
kind: ConfigMap
8+
metadata:
9+
namespace: NAMESPACE
10+
name: locust-config
11+
data:
12+
QUAY_HOST: quay-app.syed-py2-quay
13+
QUAY_USERNAME: admin
14+
QUAY_PASSWORD: password
15+
OAUTH_TOKEN: 4tW1FMzhHOZ73uy5R4H2MnOGOzzVAxLz7Mm2B965
16+
REGISTRY_AUTH_FILE: /tmp/auth.json
17+
---
18+
apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
labels:
22+
role: locust-master
23+
name: locust-master
24+
namespace: NAMESPACE
25+
spec:
26+
replicas: 1
27+
selector:
28+
matchLabels:
29+
role: locust-master
30+
template:
31+
metadata:
32+
labels:
33+
role: locust-master
34+
spec:
35+
containers:
36+
- image: quay.io/syed/quay-perftest-locust:latest
37+
imagePullPolicy: Always
38+
name: locust-master
39+
command: ["locust"]
40+
args: ["-f", "/quay-performance-scripts/locustfiles/run.py", "--master"]
41+
env:
42+
- name: QUAY_HOST
43+
valueFrom:
44+
configMapKeyRef:
45+
name: locust-config
46+
key: QUAY_HOST
47+
- name: QUAY_USERNAME
48+
valueFrom:
49+
configMapKeyRef:
50+
name: locust-config
51+
key: QUAY_USERNAME
52+
- name: QUAY_PASSWORD
53+
valueFrom:
54+
configMapKeyRef:
55+
name: locust-config
56+
key: QUAY_PASSWORD
57+
- name: OAUTH_TOKEN
58+
valueFrom:
59+
configMapKeyRef:
60+
name: locust-config
61+
key: OAUTH_TOKEN
62+
- name: REGISTRY_AUTH_FILE
63+
valueFrom:
64+
configMapKeyRef:
65+
name: locust-config
66+
key: REGISTRY_AUTH_FILE
67+
ports:
68+
- containerPort: 5557
69+
name: comm
70+
- containerPort: 5558
71+
name: comm-plus-1
72+
- containerPort: 8089
73+
name: web-ui
74+
---
75+
apiVersion: apps/v1
76+
kind: Deployment
77+
metadata:
78+
annotations:
79+
deployment.kubernetes.io/revision: "1"
80+
labels:
81+
role: locust-worker
82+
name: locust-worker
83+
namespace: NAMESPACE
84+
spec:
85+
replicas: 2
86+
selector:
87+
matchLabels:
88+
role: locust-worker
89+
strategy:
90+
rollingUpdate:
91+
maxSurge: 1
92+
maxUnavailable: 1
93+
type: RollingUpdate
94+
template:
95+
metadata:
96+
labels:
97+
role: locust-worker
98+
spec:
99+
containers:
100+
- image: quay.io/syed/quay-perftest-locust:latest
101+
imagePullPolicy: Always
102+
name: locust-worker
103+
command: ["locust"]
104+
args: ["-f", "/quay-performance-scripts/locustfiles/run.py", "--worker", "--master-host=locust-master"]
105+
env:
106+
- name: QUAY_HOST
107+
valueFrom:
108+
configMapKeyRef:
109+
name: locust-config
110+
key: QUAY_HOST
111+
- name: QUAY_USERNAME
112+
valueFrom:
113+
configMapKeyRef:
114+
name: locust-config
115+
key: QUAY_USERNAME
116+
- name: QUAY_PASSWORD
117+
valueFrom:
118+
configMapKeyRef:
119+
name: locust-config
120+
key: QUAY_PASSWORD
121+
- name: OAUTH_TOKEN
122+
valueFrom:
123+
configMapKeyRef:
124+
name: locust-config
125+
key: OAUTH_TOKEN
126+
- name: REGISTRY_AUTH_FILE
127+
valueFrom:
128+
configMapKeyRef:
129+
name: locust-config
130+
key: REGISTRY_AUTH_FILE
131+
132+
restartPolicy: Always
133+
---
134+
apiVersion: v1
135+
kind: Service
136+
metadata:
137+
labels:
138+
role: locust-master
139+
name: locust-master
140+
namespace: NAMESPACE
141+
spec:
142+
ports:
143+
- port: 5557
144+
name: communication
145+
- port: 5558
146+
name: communication-plus-1
147+
- port: 8089
148+
targetPort: 8089
149+
name: web-ui
150+
selector:
151+
role: locust-master

0 commit comments

Comments
 (0)