Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Build repos in a targeted way under the user
  • Loading branch information
jtaleric committed Jun 25, 2020
commit 77785921189c798e56adbcce6d6961e19bf1a3e3
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ The Quay Operator has been deployed.
## Additionall Tooling
This script assumes the Vegeta binary is colocated with the scripts.

To install Vegeta simply
### To install Vegeta simply

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

This will drop in an binary which we will execute with the scripts.

## Database
The database provided here is a dump from psql with a token generated for organization `test`

Expand All @@ -22,3 +24,14 @@ The default token is `opiqq6KJpCnn4YWqS4kkPku7pohjfzKX10EOGrUi`, after running t
$ 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/
{"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"}}]}
```

## targeted-build-script.sh
Script that will create 4 repos by default, each with different amount of tags:

- Repo with 10 tags
- Repo with 100 tags
- Repo with 500 tags
- Repo with 1000 tags

This script will choose a random user to build all the above with.

4 changes: 1 addition & 3 deletions assets/create-container-image-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ spec:
spec:
containers:
- command:
- /scripts/build-script.sh
- /scripts/targeted-build-script.sh
env:
- name: QUAY_URL
value: ${QUAY_URL}
- name: TOKEN
value: "${TOKEN}"
- name: NUM_USERS
value: "${NUM_USERS}"
- name: NUM_TAGS
value: "${NUM_TAGS}"
image: quay.io/podman/stable
imagePullPolicy: Always
name: load
Expand Down
38 changes: 38 additions & 0 deletions assets/run-vegeta-load.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: run-vegeta
namespace: quay-perf
spec:
parallelism: ${PARALLELISM}
completions: ${POD_COUNT}
template:
spec:
containers:
- command:
- /scripts/run-script.sh
env:
- name: QUAY_URL
value: ${QUAY_URL}
- name: TOKEN
value: "${TOKEN}"
- name: NUM_USERS
value: "${NUM_USERS}"
- name: NUM_TAGS
value: "${NUM_TAGS}"
image: quay.io/cloud-bulldozer/vegeta:latest
imagePullPolicy: Always
name: load
securityContext:
privileged: true
volumeMounts:
- mountPath: /scripts
name: run-script
volumes:
- configMap:
defaultMode: 484
name: run-script
name: run-script
restartPolicy: Never

9 changes: 4 additions & 5 deletions attack.sh → attack_load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

set -u

export TOKEN=<Token>
export TOKEN=<TOKEN>
export QUAY_URL=<URL>
export PARALLELISM=10
export POD_COUNT=100
export POD_COUNT=1000
export NUM_USERS=1000
export NUM_TAGS=100

kubectl delete ns quay-perf
kubectl create ns quay-perf
kubectl delete cm load-script -n quay-perf --ignore-not-found
kubectl create cm --from-file=build-script.sh load-script -n quay-perf
kubectl create cm --from-file=targeted-build-script.sh load-script -n quay-perf
kubectl apply -f assets/role.yaml
kubectl apply -f assets/rolebinding.yaml
cat assets/create-container-image-job.yaml | envsubst > newjob.yaml
kubectl apply -f newjob.yaml

19 changes: 19 additions & 0 deletions attack_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -u

export TOKEN=<TOKEN>
export QUAY_URL=<URL>
export PARALLELISM=10
export POD_COUNT=10
export NUM_USERS=1000
export RATE=10

kubectl delete ns quay-perf
kubectl create ns quay-perf
kubectl delete cm run-script -n quay-perf --ignore-not-found
kubectl create cm --from-file=run-script.sh run-script -n quay-perf
kubectl apply -f assets/role.yaml
kubectl apply -f assets/rolebinding.yaml
cat assets/run-vegeta-load.yaml | envsubst > run_job.yaml
kubectl apply -f run_job.yaml
51 changes: 51 additions & 0 deletions targeted-build-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/bash -u
organization=test
prefix=perf-test
num_users=${NUM_USERS:-500}
num_tags=${NUM_TAGS:-10}
num_repo=${NUM_REPO:-10}
quay=${QUAY_URL}
token=${TOKEN}

repos="10_tags 100_tags 500_tags 1000_tags"

pick=$((1 + RANDOM % ${num_users}))
quay=$QUAY_URL

cat > /tmp/Dockerfile <<EOF
FROM quay.io/jitesoft/alpine:latest

RUN echo "hello" > hello.out
EOF

for repo in $repos; do

cd /tmp
podman login ${quay} --tls-verify=false -u ${prefix}_user_${pick} -p password
podman build --layers --force-rm --tag ${pick} -f /tmp/Dockerfile
podman tag ${pick} ${quay}/${prefix}_user_${pick}/repo_${repo}

echo Pushing image
start=$(date +%s)
podman push --tls-verify=false ${quay}/${prefix}_user_${pick}/repo_${repo}
echo Init : $(($(date +%s) - ${start})) >> /tmp/push-performance.log

num_tags=$(echo ${repo} | awk -F_ '{print $1}')

if [[ $num_tags -gt 0 ]]; then
for iter in $(seq 1 $num_tags); do
cat > /tmp/Dockerfile <<EOF
FROM quay.io/jitesoft/alpine:latest

RUN echo "hello $iter" > hello.out
EOF
podman build --layers --force-rm --tag $iter -f /tmp/Dockerfile
podman tag ${iter} ${quay}/${prefix}_user_${pick}/repo_${repo}:$iter
start=$(date +%s)
podman push --tls-verify=false ${quay}/${prefix}_user_${pick}/repo_${repo}:$iter
echo Tag : $(($(date +%s) - ${start})) >> /tmp/push-performance.log
done
fi
done

cat /tmp/push-performance.log