Skip to content

Commit 7778592

Browse files
committed
Build repos in a targeted way under the user
1 parent 8379b9a commit 7778592

File tree

6 files changed

+127
-9
lines changed

6 files changed

+127
-9
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ The Quay Operator has been deployed.
55
## Additionall Tooling
66
This script assumes the Vegeta binary is colocated with the scripts.
77

8-
To install Vegeta simply
8+
### To install Vegeta simply
99

1010
```
1111
$ wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-amd64.tar.gz
1212
$ tar -xzf vegeta-12.8.3-linux-amd64.tar.gz
1313
```
1414

15+
This will drop in an binary which we will execute with the scripts.
16+
1517
## Database
1618
The database provided here is a dump from psql with a token generated for organization `test`
1719

@@ -22,3 +24,14 @@ The default token is `opiqq6KJpCnn4YWqS4kkPku7pohjfzKX10EOGrUi`, after running t
2224
$ curl -k -X GET -H "Authorization: Bearer opiqq6KJpCnn4YWqS4kkPku7pohjfzKX10EOGrUi" https://rook-quay-quay-openshift-quay.apps.rook43quay.perf-testing.devcluster.openshift.com/api/v1/superuser/users/
2325
{"users": [{"username": "quay", "kind": "user", "verified": true, "name": "quay", "super_user": true, "enabled": true, "email": "[email protected]", "avatar": {"color": "#8c6d31", "kind": "user", "hash": "5cc105f67a24cab8379ad1cfd5dfdebb", "name": "quay"}}]}
2426
```
27+
28+
## targeted-build-script.sh
29+
Script that will create 4 repos by default, each with different amount of tags:
30+
31+
- Repo with 10 tags
32+
- Repo with 100 tags
33+
- Repo with 500 tags
34+
- Repo with 1000 tags
35+
36+
This script will choose a random user to build all the above with.
37+

assets/create-container-image-job.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ spec:
1111
spec:
1212
containers:
1313
- command:
14-
- /scripts/build-script.sh
14+
- /scripts/targeted-build-script.sh
1515
env:
1616
- name: QUAY_URL
1717
value: ${QUAY_URL}
1818
- name: TOKEN
1919
value: "${TOKEN}"
2020
- name: NUM_USERS
2121
value: "${NUM_USERS}"
22-
- name: NUM_TAGS
23-
value: "${NUM_TAGS}"
2422
image: quay.io/podman/stable
2523
imagePullPolicy: Always
2624
name: load

assets/run-vegeta-load.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: run-vegeta
6+
namespace: quay-perf
7+
spec:
8+
parallelism: ${PARALLELISM}
9+
completions: ${POD_COUNT}
10+
template:
11+
spec:
12+
containers:
13+
- command:
14+
- /scripts/run-script.sh
15+
env:
16+
- name: QUAY_URL
17+
value: ${QUAY_URL}
18+
- name: TOKEN
19+
value: "${TOKEN}"
20+
- name: NUM_USERS
21+
value: "${NUM_USERS}"
22+
- name: NUM_TAGS
23+
value: "${NUM_TAGS}"
24+
image: quay.io/cloud-bulldozer/vegeta:latest
25+
imagePullPolicy: Always
26+
name: load
27+
securityContext:
28+
privileged: true
29+
volumeMounts:
30+
- mountPath: /scripts
31+
name: run-script
32+
volumes:
33+
- configMap:
34+
defaultMode: 484
35+
name: run-script
36+
name: run-script
37+
restartPolicy: Never
38+

attack.sh renamed to attack_load.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
set -u
44

5-
export TOKEN=<Token>
5+
export TOKEN=<TOKEN>
66
export QUAY_URL=<URL>
77
export PARALLELISM=10
8-
export POD_COUNT=100
8+
export POD_COUNT=1000
99
export NUM_USERS=1000
10-
export NUM_TAGS=100
1110

11+
kubectl delete ns quay-perf
1212
kubectl create ns quay-perf
1313
kubectl delete cm load-script -n quay-perf --ignore-not-found
14-
kubectl create cm --from-file=build-script.sh load-script -n quay-perf
14+
kubectl create cm --from-file=targeted-build-script.sh load-script -n quay-perf
1515
kubectl apply -f assets/role.yaml
1616
kubectl apply -f assets/rolebinding.yaml
1717
cat assets/create-container-image-job.yaml | envsubst > newjob.yaml
1818
kubectl apply -f newjob.yaml
19-

attack_run.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -u
4+
5+
export TOKEN=<TOKEN>
6+
export QUAY_URL=<URL>
7+
export PARALLELISM=10
8+
export POD_COUNT=10
9+
export NUM_USERS=1000
10+
export RATE=10
11+
12+
kubectl delete ns quay-perf
13+
kubectl create ns quay-perf
14+
kubectl delete cm run-script -n quay-perf --ignore-not-found
15+
kubectl create cm --from-file=run-script.sh run-script -n quay-perf
16+
kubectl apply -f assets/role.yaml
17+
kubectl apply -f assets/rolebinding.yaml
18+
cat assets/run-vegeta-load.yaml | envsubst > run_job.yaml
19+
kubectl apply -f run_job.yaml

targeted-build-script.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/bash -u
2+
organization=test
3+
prefix=perf-test
4+
num_users=${NUM_USERS:-500}
5+
num_tags=${NUM_TAGS:-10}
6+
num_repo=${NUM_REPO:-10}
7+
quay=${QUAY_URL}
8+
token=${TOKEN}
9+
10+
repos="10_tags 100_tags 500_tags 1000_tags"
11+
12+
pick=$((1 + RANDOM % ${num_users}))
13+
quay=$QUAY_URL
14+
15+
cat > /tmp/Dockerfile <<EOF
16+
FROM quay.io/jitesoft/alpine:latest
17+
18+
RUN echo "hello" > hello.out
19+
EOF
20+
21+
for repo in $repos; do
22+
23+
cd /tmp
24+
podman login ${quay} --tls-verify=false -u ${prefix}_user_${pick} -p password
25+
podman build --layers --force-rm --tag ${pick} -f /tmp/Dockerfile
26+
podman tag ${pick} ${quay}/${prefix}_user_${pick}/repo_${repo}
27+
28+
echo Pushing image
29+
start=$(date +%s)
30+
podman push --tls-verify=false ${quay}/${prefix}_user_${pick}/repo_${repo}
31+
echo Init : $(($(date +%s) - ${start})) >> /tmp/push-performance.log
32+
33+
num_tags=$(echo ${repo} | awk -F_ '{print $1}')
34+
35+
if [[ $num_tags -gt 0 ]]; then
36+
for iter in $(seq 1 $num_tags); do
37+
cat > /tmp/Dockerfile <<EOF
38+
FROM quay.io/jitesoft/alpine:latest
39+
40+
RUN echo "hello $iter" > hello.out
41+
EOF
42+
podman build --layers --force-rm --tag $iter -f /tmp/Dockerfile
43+
podman tag ${iter} ${quay}/${prefix}_user_${pick}/repo_${repo}:$iter
44+
start=$(date +%s)
45+
podman push --tls-verify=false ${quay}/${prefix}_user_${pick}/repo_${repo}:$iter
46+
echo Tag : $(($(date +%s) - ${start})) >> /tmp/push-performance.log
47+
done
48+
fi
49+
done
50+
51+
cat /tmp/push-performance.log

0 commit comments

Comments
 (0)