Skip to content

Commit c8ef357

Browse files
committed
Use Skopeo instead of podman
1 parent 443f417 commit c8ef357

File tree

6 files changed

+134
-132
lines changed

6 files changed

+134
-132
lines changed

Dockerfile-locust

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
1-
FROM fedora:32
1+
ARG PYTHON_VERSION=3.8.6-alpine3.12
22

3-
RUN dnf -y update && dnf -y install fuse3-devel && yum install python3
4-
RUN dnf -y install podman
3+
FROM python:${PYTHON_VERSION} as builder
54

6-
ADD . /mnt
7-
WORKDIR /mnt
5+
ENV PYTHONUNBUFFERED 1
86

9-
RUN pip install -r /mnt/requirements.txt
7+
# build time dependencies
8+
RUN apk update && \
9+
apk add --no-cache \
10+
gcc \
11+
g++ \
12+
musl-dev \
13+
linux-headers \
14+
zeromq-dev \
15+
libffi-dev \
16+
make
17+
18+
# build wheels instead of installing
19+
WORKDIR /wheels
20+
21+
COPY requirements.txt .
22+
23+
RUN pip install -U pip && \
24+
pip wheel -r requirements.txt
25+
26+
27+
FROM python:${PYTHON_VERSION}
28+
29+
# dependencies you need in your final image
30+
RUN apk update && \
31+
apk add --no-cache \
32+
bash \
33+
libzmq
34+
35+
# copy built previously wheels archives
36+
COPY --from=builder /wheels /wheels
37+
38+
COPY requirements.txt /wheels/requirements.txt
39+
40+
# use archives from /weels dir
41+
RUN pip install -U pip \
42+
&& pip install -r /wheels/requirements.txt -f /wheels \
43+
&& rm -rf /wheels \
44+
&& rm -rf /root/.cache/pip/*
45+
46+
# install skopeo
47+
RUN apk add skopeo
48+
49+
# Expose locust web ui port
1050
EXPOSE 8089
11-
CMD ["locust", "-f", "/mnt/testfiles/run.py"]
51+
52+
CMD ["locust", "-f", "/quay-performance-scripts/testfiles/run.py"]

README.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ There are a few prerequisites and they will be explained below.
1616

1717
### Prerequisites
1818

19-
- Create an Elasticsearch instance. The results will be stored here.
2019
- Deploy a Kubernetes environment. The tests will run within the cluster.
2120
- Deploy Quay, itself.
2221
- In Quay, as a superuser (important), create an organization for testing
@@ -73,6 +72,13 @@ file to change the behavior of the tests.
7372

7473
## Changelog
7574

75+
**v0.1.0**
76+
changes:
77+
78+
- Tests are run using locust framework
79+
- Concurrent testing is done using Locust in distributed mode
80+
- Metrics are now exported as Prometheus metrics
81+
7682
**v0.0.2**
7783

7884
changes:
@@ -116,12 +122,47 @@ The project expects the following environment variables:
116122
- PODMAN_PASSWORD: Password for the above user
117123
- PODMAN_HOST: The url of the host registry where images will be pushed
118124
- QUAY_HOST: The url where Quay is hosted
119-
- AUTH_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.)
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.)
126+
127+
### Building
128+
129+
From the main directory, the docker image can be built using the command:
130+
131+
```bash
132+
docker build -t perf-test -f Dockerfile-locust .
133+
```
120134

121135
### Running
122136

123-
From the main directory, the docker image can be built using the command: `docker build -t perf-test -f Dockerfile-locust .`
124-
The built image can be run using the command: `docker run -e PODMAN_USERNAME="username" -e PODMAN_PASSWORD="password" -e PODMAN_HOST="localhost:8080" -e QUAY_HOST="http://www.localhost:8080" -e AUTH_TOKEN="abc" --privileged -v /tmp/csivvv:/var/lib/containers -p 8089:8089 --name quay-test -d perf-test`
125-
Upon successful starting of the container, the locust dashboard is accessible on port 8089.
137+
#### Locally for dev
138+
139+
```
140+
docker run -e PODMAN_USERNAME="username" \
141+
-e PODMAN_PASSWORD="password" \
142+
-e PODMAN_HOST="localhost:8080" \
143+
-e QUAY_HOST="http://www.localhost:8080" \
144+
-e AUTH_TOKEN="abc" --privileged \
145+
-v /tmp/csivvv:/var/lib/containers \
146+
-p 8089:8089 --name quay-test -d perf-test`
147+
```
148+
149+
Upon successful starting of the container, the locust dashboard is accessible
150+
on port 8089.
151+
152+
The minimum number of users spawned to run the tests must be at least equal to
153+
the number of users defined in `testfiles/run.py` to run all user classes.
154+
155+
#### Cluster
156+
157+
The tests are run via locust in distributed mode. There is a single master
158+
which controls multiple worker pods. The number of replicas for the workers are
159+
defined in `deploy/locust-distributed.yaml` file.
160+
161+
Edit the `ConfigMap` `quay-locust-config` in the
162+
`deploy/locust-distributed.yaml` and set the variables accordingly
163+
164+
Deploy locust on the cluster by running:
126165

127-
The minimum number of users spawned to run the tests must be at least equal to the number of users defined in `testfiles/run.py` to run all user classes.
166+
```
167+
kubectl apply -f deploy/locust-distributed.yaml
168+
```

requirements.txt

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,2 @@
1-
boto3==1.18.8
2-
botocore==1.21.8
3-
cachetools==4.2.2
4-
certifi==2021.5.30
5-
charset-normalizer==2.0.3
6-
click==8.0.1
7-
ConfigArgParse==1.5.1
8-
configparser==5.0.2
9-
confluent-kafka==1.7.0
10-
contextvars==2.4
11-
dataclasses==0.6
12-
dateparser==1.0.0
13-
dictdiffer==0.9.0
14-
docutils==0.17.1
15-
elasticsearch==7.13.4
16-
Flask==1.1.2
17-
Flask-BasicAuth==0.2.0
18-
Flask-Cors==3.0.10
19-
flent==2.0.1
20-
gevent==21.1.2
21-
geventhttpclient==1.4.4
22-
google-api-core==1.31.1
23-
google-auth==1.34.0
24-
googleapis-common-protos==1.53.0
25-
greenlet==1.1.0
26-
idna==3.2
27-
immutables==0.15
28-
importlib-metadata==4.6.1
29-
itsdangerous==2.0.1
30-
Jinja2==3.0.1
31-
jmespath==0.10.0
32-
kafka-python==2.0.2
33-
kubernetes==11.0.0
341
locust==1.6.0
35-
locust-plugins==1.1.0
36-
lxml==4.6.3
37-
MarkupSafe==2.0.1
38-
msgpack==1.0.2
39-
numpy==1.19.5
40-
oauthlib==3.1.1
41-
opencensus==0.7.13
42-
opencensus-context==0.1.2
43-
opencensus-ext-azure==1.0.8
44-
openshift==0.11.0
45-
packaging==21.0
46-
pandas==1.1.5
47-
prometheus-api-client==0.4.2
48-
protobuf==3.17.3
49-
psutil==5.8.0
50-
psycogreen==1.0.2
51-
psycopg2-binary==2.9.1
52-
pyasn1==0.4.8
53-
pyasn1-modules==0.2.8
54-
pymongo==3.12.0
55-
pyparsing==2.4.7
56-
python-dateutil==2.8.2
57-
python-string-utils==1.0.0
58-
pytz==2021.1
59-
PyYAML==5.4.1
60-
pyzmq==22.1.0
61-
redis==3.5.3
62-
regex==2021.7.6
63-
requests==2.26.0
64-
requests-oauthlib==1.3.0
65-
rsa==4.7.2
66-
ruamel.yaml==0.17.10
67-
ruamel.yaml.clib==0.2.6
68-
s3transfer==0.5.0
69-
scipy==1.5.4
70-
selenium==3.141.0
71-
six==1.16.0
72-
snafu==0.0.1
73-
statistics==1.0.3.5
74-
ttp==0.7.2
75-
typing-extensions==3.10.0.0
76-
tzlocal==2.1
77-
urllib3==1.26.6
78-
websocket-client==1.1.0
79-
Werkzeug==2.0.1
80-
zipp==3.5.0
81-
zope.event==4.5.0
82-
zope.interface==5.4.0
2+

testfiles/podman_operations.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

testfiles/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from api import QuayUser
2-
from podman_operations import PodmanUser
2+
from skopeo_operations import SkopeoUser

testfiles/skopeo_operations.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from locust import User, task, tag
2+
from subprocess import run
3+
4+
from utils import trigger_event
5+
import os
6+
7+
class SkopeoUser(User):
8+
9+
def on_start(self):
10+
pass
11+
12+
@trigger_event(request_type="skopeo", name="Remove Images")
13+
def on_stop(self):
14+
"""
15+
Clear all images from local cache
16+
"""
17+
cmd = f"skopeo rmi --all --force"
18+
return run(cmd, shell=True, capture_output=True)
19+
20+
@task
21+
@tag('skopeo_push_image')
22+
@trigger_event(request_type="skopeo", name="Image push")
23+
def push_image(self):
24+
"""
25+
Pushing image via skopeo.
26+
"""
27+
username = os.environ.get('QUAY_USERNAME', 'admin')
28+
password = os.environ['QUAY_PASSWORD']
29+
host = os.environ['QUAY_HOST']
30+
31+
cmd = f"skopeo login -u {username} -p {password} --tls-verify=false {host} "
32+
run(cmd, shell=True, capture_output=True)
33+
34+
cmd = ("skopeo copy --tls-verify=false"
35+
"docker://quay.io/alecmerdler/bad-image:critical"
36+
f"docker://{host}/{username}/bad-image:critial")
37+
run(cmd, shell=True, capture_output=True)

0 commit comments

Comments
 (0)