Skip to content

Commit 7dc19e6

Browse files
vishnuchallaVishnu Challa
andauthored
Cleaning up dockerfile and fixing bugs (#52)
* cleaning dockerfile and fixing bugs --------- Co-authored-by: Vishnu Challa <vchalla@vchalla.remote.csb>
1 parent 378331b commit 7dc19e6

4 files changed

Lines changed: 81 additions & 62 deletions

File tree

Dockerfile

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
1-
FROM ubuntu:20.10
1+
FROM ubuntu
22

33
LABEL maintainer="syahmed@redhat.com"
44

55
WORKDIR /tmp
66
ARG DEBIAN_FRONTEND=noninteractive
77

8-
# ALPINE
9-
RUN apt-get update
10-
RUN apt-get upgrade -y
11-
RUN apt-get install -y podman
12-
RUN apt-get install -y wget python3 git dumb-init
13-
14-
# Snafu Build Dependencies
15-
# TODO: A lot of the *-dev dependencies were added while attempting to build
16-
# snafu's requirements (mainly numpy, scipy, pandas). Now that these are
17-
# installed using Alpine's package manager, they may not all be necessary
18-
# anymore.
19-
RUN apt-get install -y python3-numpy python3-scipy python3-pandas gcc python3-dev \
20-
postgresql-client-12 libffi-dev libxml2 \
21-
libxml2-dev libxslt-dev libjpeg-dev \
22-
zlib1g-dev musl-dev
23-
24-
# RUN apt-get install -y libressl-dev
25-
# Install required third-party packages
26-
RUN wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-amd64.tar.gz
27-
RUN tar -xzf vegeta-12.8.3-linux-amd64.tar.gz
28-
RUN mv vegeta /usr/local/bin/vegeta
29-
30-
# Install Python Dependencies
31-
# RUN python3 -m ensurepip
32-
RUN python3 -m pip install --upgrade pip
33-
COPY requirements.txt .
34-
RUN pip3 install -r requirements.txt
8+
# Install necessary libraries for subsequent commands
9+
RUN apt-get update && apt-get install -y podman wget git dumb-init python3.6 python3-distutils python3-pip python3-apt redis-server
10+
# Install vegeta for HTTP benchmarking
11+
RUN wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-amd64.tar.gz \
12+
&& tar -xzf vegeta-12.8.3-linux-amd64.tar.gz \
13+
&& mv vegeta /usr/local/bin/vegeta \
14+
&& rm -rf vegeta-12.8.3-linux-amd64.tar.gz
15+
16+
# Install and setup snafu for storing vegeta results into ES
17+
RUN mkdir -p /opt/snafu/ \
18+
&& wget -O /tmp/benchmark-wrapper.tar.gz https://github.com/cloud-bulldozer/benchmark-wrapper/archive/refs/tags/v1.0.0.tar.gz \
19+
&& tar -xzf /tmp/benchmark-wrapper.tar.gz -C /opt/snafu/ --strip-components=1 \
20+
&& pip3 install --upgrade pip \
21+
&& pip3 install -e /opt/snafu/ \
22+
&& rm -rf /tmp/benchmark-wrapper.tar.gz
3523

3624
COPY tests.py .
3725

38-
RUN apt-get clean autoclean
39-
RUN apt-get autoremove --yes
40-
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
26+
# Cleanup the installation remainings
27+
RUN apt-get clean autoclean && \
28+
apt-get autoremove --yes && \
29+
rm -rf /var/lib/{apt,dpkg,cache,log}/
4130

31+
# Start the command
4232
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
4333
CMD ["python3", "tests.py"]

deploy/test.job.yaml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Role
44
metadata:
55
name: quay-perf-test-serviceaccount
66
rules:
7-
- apiGroups: ["extensions", "apps", "batch"]
8-
resources: ["deployments", "jobs", "pods", "services", "jobs/status"]
9-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
7+
- apiGroups: ["extensions", "apps", "batch", "security.openshift.io", "policy"]
8+
resources: ["deployments", "jobs", "pods", "services", "jobs/status", "podsecuritypolicies", "securitycontextconstraints"]
9+
verbs: ["use", "get", "list", "watch", "create", "update", "patch", "delete"]
1010
---
1111
apiVersion: rbac.authorization.k8s.io/v1
1212
kind: RoleBinding
@@ -66,22 +66,32 @@ spec:
6666
spec:
6767
containers:
6868
- name: python
69-
image: quay.io/syed/quay-performance-tests:latest
69+
image: quay.io/vchalla/quay-load:latest
7070
securityContext:
7171
privileged: true
7272
env:
7373
- name: QUAY_HOST
7474
value: <quay-host>
7575
- name: QUAY_OAUTH_TOKEN
76-
value: <quay-oauth-token>
76+
value: <quay-token>
7777
- name: QUAY_ORG
78-
value: loadtesting
78+
value: <quay-test-org>
7979
- name: ES_HOST
8080
value: <es-host>
8181
- name: ES_PORT
82-
value: "9200"
82+
value: <es-port>
8383
- name: PYTHONUNBUFFERED
8484
value: "0"
85+
- name: ES_INDEX
86+
value: <es-index>
87+
- name: PUSH_PULL_IMAGE
88+
value: <image-for-testing>
89+
- name: TARGET_HIT_SIZE
90+
value: <hit-size>
91+
- name: CONCURRENCY
92+
value: <concurrency>
93+
- name: TEST_NAMESPACE
94+
value: <test-namespace>
8595
resources:
8696
requests:
8797
cpu: "1"

requirements.txt

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

tests.py

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Configuration Options
2323
LOG_DIRECTORY = './logs'
2424
PROTOCOL = 'https' # TODO: Use environment variable
25-
CONCURRENCY = 4
25+
CONCURRENCY = None
2626

2727

2828
# In cases where only a single URL is hit, request it multiple times to get
@@ -32,12 +32,16 @@
3232

3333
# Globals: ugly, but simplifies the rest of the code
3434
QUAY_HOST = None
35-
BASE_URL = None # e.g. https://staging.quay.io
35+
QUAY_ORG = None
36+
BASE_URL = None
3637
TEST_UUID = None
3738
AUTH_TOKEN = None
3839
ES_HOST = None
3940
ES_PORT = None
40-
ES_INDEX = 'quay-vegeta' # TODO: Use environment variable
41+
ES_INDEX = None
42+
PUSH_PULL_IMAGE = None
43+
TARGET_HIT_SIZE = None
44+
TEST_NAMESPACE = None
4145

4246

4347
# Used for executing tests across multiple pods
@@ -92,11 +96,13 @@ def run_vegeta(test_name, request_dicts, target_name):
9296

9397
# Some tests do not need authentication. Allow them to pass `None`
9498
# as the request header to avoid injecting it.
95-
if 'header' not in req_dict or req_dict['header'] is not None:
99+
if 'header' not in req_dict:
96100
req['header'] = {
97101
'Authorization': ['Bearer %s' % AUTH_TOKEN],
98102
'Content-Type': ['application/json']
99103
}
104+
else:
105+
req['header'] = req_dict['header']
100106

101107
req_string = json.dumps(req) + '\n'
102108
reqs = reqs + req_string
@@ -502,7 +508,7 @@ def podman_create(tags):
502508
# Create an Elasticsearch Doc
503509
doc = {
504510
'_index': index,
505-
'_type': '_doc',
511+
'type': '_doc',
506512
'_source': result
507513
}
508514
docs.append(doc)
@@ -621,7 +627,7 @@ def podman_pull(tags):
621627
# Create an Elasticsearch Doc
622628
doc = {
623629
'_index': index,
624-
'_type': '_doc',
630+
'type': '_doc',
625631
'_source': result
626632
}
627633
docs.append(doc)
@@ -697,7 +703,7 @@ def test_push(num_tags):
697703

698704

699705
def create_test_push_job(namespace, quay_host, username, password, concurrency,
700-
test_uuid, token, batch_size, tag_count):
706+
test_uuid, token, batch_size, tag_count, image, target_hit_size):
701707
"""
702708
Create a Kubernetes Job Batch where each job will pull <batch_size> items
703709
off the queue and perform the podman build + podman push action on them.
@@ -711,13 +717,17 @@ def create_test_push_job(namespace, quay_host, username, password, concurrency,
711717
client.V1EnvVar(name='QUAY_USERNAME', value=username),
712718
client.V1EnvVar(name='QUAY_PASSWORD', value=password),
713719
client.V1EnvVar(name='CONCURRENCY', value=str(concurrency)),
720+
client.V1EnvVar(name='TARGET_HIT_SIZE', value=str(target_hit_size)),
721+
client.V1EnvVar(name='PUSH_PULL_IMAGE', value=image),
714722
client.V1EnvVar(name='TEST_UUID', value=test_uuid),
723+
client.V1EnvVar(name='TEST_NAMESPACE', value=namespace),
715724
client.V1EnvVar(name='QUAY_OAUTH_TOKEN', value=token),
716725
client.V1EnvVar(name='QUAY_TEST_NAME', value='push'),
717726
client.V1EnvVar(name='QUAY_ORG', value=QUAY_ORG),
718727
client.V1EnvVar(name='TEST_BATCH_SIZE', value=str(batch_size)),
719728
client.V1EnvVar(name='ES_HOST', value=ES_HOST),
720729
client.V1EnvVar(name='ES_PORT', value=str(ES_PORT)),
730+
client.V1EnvVar(name='ES_INDEX', value=ES_INDEX),
721731
]
722732

723733
resource_requirements = client.V1ResourceRequirements(
@@ -729,7 +739,7 @@ def create_test_push_job(namespace, quay_host, username, password, concurrency,
729739

730740
container = client.V1Container(
731741
name='python',
732-
image='quay.io/kmullins/quay-performance-test:latest',
742+
image=image,
733743
security_context={'privileged': True},
734744
env=env_vars,
735745
resources=resource_requirements,
@@ -762,7 +772,7 @@ def create_test_push_job(namespace, quay_host, username, password, concurrency,
762772

763773

764774
def create_test_pull_job(namespace, quay_host, username, password, concurrency,
765-
test_uuid, token, batch_size, tag_count):
775+
test_uuid, token, batch_size, tag_count, image, target_hit_size):
766776
"""
767777
Create a Kubernetes Job Batch where each job will pull <batch_size> items
768778
off the queue and perform the podman pull action on them.
@@ -776,13 +786,17 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
776786
client.V1EnvVar(name='QUAY_USERNAME', value=username),
777787
client.V1EnvVar(name='QUAY_PASSWORD', value=password),
778788
client.V1EnvVar(name='CONCURRENCY', value=str(concurrency)),
789+
client.V1EnvVar(name='TARGET_HIT_SIZE', value=str(target_hit_size)),
790+
client.V1EnvVar(name='PUSH_PULL_IMAGE', value=image),
779791
client.V1EnvVar(name='TEST_UUID', value=test_uuid),
792+
client.V1EnvVar(name='TEST_NAMESPACE', value=namespace),
780793
client.V1EnvVar(name='QUAY_OAUTH_TOKEN', value=token),
781794
client.V1EnvVar(name='QUAY_TEST_NAME', value='pull'),
782795
client.V1EnvVar(name='QUAY_ORG', value=QUAY_ORG),
783796
client.V1EnvVar(name='TEST_BATCH_SIZE', value=str(batch_size)),
784797
client.V1EnvVar(name='ES_HOST', value=ES_HOST),
785798
client.V1EnvVar(name='ES_PORT', value=str(ES_PORT)),
799+
client.V1EnvVar(name='ES_INDEX', value=ES_INDEX),
786800
]
787801

788802
resource_requirements = client.V1ResourceRequirements(
@@ -794,7 +808,7 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
794808

795809
container = client.V1Container(
796810
name='python',
797-
image='quay.io/kmullins/quay-performance-test:latest',
811+
image=image,
798812
security_context={'privileged': True},
799813
env=env_vars,
800814
resources=resource_requirements,
@@ -828,20 +842,22 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
828842

829843
if __name__ == '__main__':
830844

831-
# Load Kubernetes configuration from the Cluster
832-
# NOTE: This will not work when running this script outside of k8s
833845
config.load_incluster_config()
834846

835847
QUAY_HOST = os.environ.get("QUAY_HOST")
836848
AUTH_TOKEN = os.environ.get("QUAY_OAUTH_TOKEN")
837-
CONCURRENCY = os.environ.get("CONCURRENCY", 4)
849+
CONCURRENCY = int(os.environ.get("CONCURRENCY", 50))
838850
QUAY_ORG = os.environ.get("QUAY_ORG")
839851

840852
TEST_UUID = os.environ.get('TEST_UUID', str(uuid.uuid4()))
841853
BASE_URL = '%s://%s' % (PROTOCOL, QUAY_HOST)
842854

843855
ES_HOST = os.environ.get('ES_HOST')
844856
ES_PORT = os.environ.get('ES_PORT')
857+
ES_INDEX = os.environ.get('ES_INDEX')
858+
PUSH_PULL_IMAGE = os.environ.get('PUSH_PULL_IMAGE')
859+
TARGET_HIT_SIZE = int(os.environ.get('TARGET_HIT_SIZE'))
860+
TEST_NAMESPACE = os.environ.get("TEST_NAMESPACE")
845861

846862
# Generate a new prefix for user, repository, and team names on each run.
847863
# This is to avoid name collisions in the case of a re-run.
@@ -862,6 +878,9 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
862878
assert ES_HOST
863879
assert ES_PORT
864880
assert ES_INDEX
881+
assert PUSH_PULL_IMAGE
882+
assert isinstance(TARGET_HIT_SIZE, int)
883+
assert TEST_NAMESPACE
865884

866885
# Avoid p_thread exception in currently used Dockerfile base image
867886
# TODO: Remove this when Alpine + Podman is fixed to avoid leaving
@@ -889,17 +908,17 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
889908
organization = QUAY_ORG # Organization/Namespace used for performance tests
890909
password = 'password' # Password used for all created Users
891910

892-
num_users = 100
893-
num_repos = 100
894-
num_teams = 10
911+
num_users = TARGET_HIT_SIZE
912+
num_repos = TARGET_HIT_SIZE
913+
num_teams = TARGET_HIT_SIZE
895914

896915
users = ['%s_user_%s' % (PREFIX, n) for n in range(0, num_users)]
897916
teams = ['%s_team_%s' % (PREFIX, n) for n in range(0, num_teams)]
898917
repos = ['%s_repo_%s' % (PREFIX, n) for n in range(0, num_repos)]
899918

900919
# Create repositories which will contain a specified number of tags when the
901920
# registry operation tests are performed.
902-
repo_sizes = (1, 5, 10, 50, 100, 500, 1000, 5000)
921+
repo_sizes = (100,)
903922
repos_with_data = ['repo_with_%s_tags' % n for n in repo_sizes]
904923
repos.extend(repos_with_data) # Create these while running tests
905924

@@ -922,13 +941,15 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
922941
num_users=num_users,
923942
num_repos=len(repos),
924943
num_teams=num_teams,
944+
target_hit_size=TARGET_HIT_SIZE,
925945
concurrency=CONCURRENCY,
926946
repos_with_tags_sizes=repo_sizes,
947+
total_tags=len(tags),
948+
pull_push_batch_size=BATCH_SIZE,
949+
number_of_push_pull_jobs_per_user=len(tags)//BATCH_SIZE,
927950
)
928951

929-
# Get current namespace. Workaround for:
930-
# https://github.com/kubernetes-client/python/issues/363
931-
namespace = open("/var/run/secrets/kubernetes.io/serviceaccount/namespace").read()
952+
namespace = TEST_NAMESPACE
932953

933954
# These tests should run before container images are pushed
934955
create_users(users)
@@ -944,7 +965,7 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
944965
logger.info('Queued %s tags to be created' % len(tags))
945966

946967
# Start the Registry Push Test job
947-
create_test_push_job(namespace, QUAY_HOST, users[0], password, CONCURRENCY, TEST_UUID, AUTH_TOKEN, BATCH_SIZE, len(tags))
968+
create_test_push_job(namespace, QUAY_HOST, users[0], password, CONCURRENCY, TEST_UUID, AUTH_TOKEN, BATCH_SIZE, len(tags), PUSH_PULL_IMAGE, TARGET_HIT_SIZE)
948969
time.sleep(60) # Give the Job time to start
949970
while True:
950971

@@ -966,7 +987,7 @@ def create_test_pull_job(namespace, quay_host, username, password, concurrency,
966987
logger.info('Queued %s tags to be pulled' % len(tags))
967988

968989
# Start the Registry Pull Test job
969-
create_test_pull_job(namespace, QUAY_HOST, users[0], password, CONCURRENCY, TEST_UUID, AUTH_TOKEN, BATCH_SIZE, len(tags))
990+
create_test_pull_job(namespace, QUAY_HOST, users[0], password, CONCURRENCY, TEST_UUID, AUTH_TOKEN, BATCH_SIZE, len(tags), PUSH_PULL_IMAGE, TARGET_HIT_SIZE)
970991
time.sleep(60) # Give the Job time to start
971992
while True:
972993

0 commit comments

Comments
 (0)