2222# Configuration Options
2323LOG_DIRECTORY = './logs'
2424PROTOCOL = '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
3232
3333# Globals: ugly, but simplifies the rest of the code
3434QUAY_HOST = None
35- BASE_URL = None # e.g. https://staging.quay.io
35+ QUAY_ORG = None
36+ BASE_URL = None
3637TEST_UUID = None
3738AUTH_TOKEN = None
3839ES_HOST = None
3940ES_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
699705def 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
764774def 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
829843if __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