Commit 5159a88b authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Add some more parameters to the loader test script

parent 1c2bc02c
......@@ -10,11 +10,14 @@ import json
import os
import sys
import time
import random
from zoe_lib.statistics import ZoeStatisticsAPI
from zoe_lib.executions import ZoeExecutionsAPI
TARGET_QUEUE_LENGTH = 5
TARGET_QUEUE_LENGTH = 10
TOTAL_JOBS = 1000
MAX_TO_START_PER_LOOP = 30
def zoe_url():
......@@ -49,20 +52,41 @@ def submit_zapp(zapp):
"""Submits one ZApp for execution."""
exec_api = ZoeExecutionsAPI(zoe_url(), zoe_user(), zoe_pass())
ret = exec_api.start('boinc-loader', zapp)
print("Application scheduled successfully with ID {}, use the exec-get command to check its status".format(ret))
print("Application scheduled successfully with ID {}".format(ret))
def count_jobs():
"""Count how many zapps have already been submitted."""
exec_api = ZoeExecutionsAPI(zoe_url(), zoe_user(), zoe_pass())
execs = exec_api.list()
count = 0
for e_id in execs:
e = exec_api.get(e_id)
if e['name'] != 'boinc-loader' or e['status'] != 'terminated':
continue
else:
count += 1
return count
def main():
"""Main."""
zapps_to_start = TOTAL_JOBS - count_jobs()
print('I need to start {} zapps'.format(zapps_to_start))
zapp = load_zapp(sys.argv[1])
queue_length = check_queue_length()
while queue_length < TARGET_QUEUE_LENGTH:
number_to_submit = TARGET_QUEUE_LENGTH - queue_length
print('Current queue length is {}, submitting {} new zapps'.format(queue_length, number_to_submit))
for i in range(number_to_submit):
while zapps_to_start > 0:
queue_length = check_queue_length()
if queue_length >= TARGET_QUEUE_LENGTH:
to_sleep = random.randint(10, 300)
print("Target scheduler queue length reached, sleeping for {} seconds".format(to_sleep))
time.sleep(to_sleep)
continue
to_start_now = random.randint(1, MAX_TO_START_PER_LOOP)
print('Will submit {} new zapps'.format(to_start_now))
for i in range(to_start_now):
submit_zapp(zapp)
time.sleep(5)
print('Zoe scheduler target queue length reached, my work is done.')
zapps_to_start -= 1
print('All Zapps submitted, my work is done.')
if __name__ == "__main__":
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment