def job(baseurl, num_player, eventurl, duration): testDeviceUrl = "http://" + baseurl + ":8080/playerTest" browserType = "chrome" playerType = "tfiPlayer" jobIds = [] for i in range(0, num_player): response = startTest(testDeviceUrl, eventurl, browserType, duration, playerType) data = json.loads(response) jobId = data["jobId"] jobIds.append(jobId) sleep_duration = duration * 1.1 print("{} finish provision player. sleep for {}".format( baseurl, sleep_duration)) time.sleep(sleep_duration) i = 0 success_cnt = 0 fail_cnt = 0 while True: _jobIds = [] for jobId in jobIds: response = getResult(testDeviceUrl, jobId) data = json.loads(response) status = data["status"] if status == "SUCCESS": #print(response) success_cnt += 1 f = open(jobId + ".txt", "a") f.write(json.dumps(data["testResult"], indent=4)) f.close() deleteTest(testDeviceUrl, jobId) elif status == "FAIL": fail_cnt += 1 deleteTest(testDeviceUrl, jobId) else: _jobIds.append(jobId) if len(_jobIds) == 0: print("[Done({})][{}] success:{} fail:{}".format( i, baseurl, success_cnt, fail_cnt)) break else: print("[Testing({})][{}] success:{} fail:{}".format( i, baseurl, success_cnt, fail_cnt)) jobIds = _jobIds time.sleep(5) i = i + 5 response = listTest(testDeviceUrl) print(response)
def test_lem_routine(baseurl, num_player, eventurl, duration): testDeviceUrl = "http://" + baseurl + ":8080/playerTest" browserType = "chrome" playerType = "idlePage" jobIds = [] for i in range(0, num_player): response = start_lem_test(testDeviceUrl, browserType, duration, playerType, eventurl) data = json.loads(response) jobId = data["jobId"] jobIds.append(jobId) #print("jobId: {} {}".format(jobId, response)) print("{} finish provision player. sleep for {}".format(baseurl, duration)) time.sleep(duration) i = 0 success_cnt = 0 fail_cnt = 0 while True: _jobIds = [] for jobId in jobIds: response = getResult(testDeviceUrl, jobId) data = json.loads(response) status = data["status"] if status == "SUCCESS": success_cnt += 1 deleteTest(testDeviceUrl, jobId) elif status == "FAIL": fail_cnt += 1 deleteTest(testDeviceUrl, jobId) else: _jobIds.append(jobId) if len(_jobIds) == 0: print("[Done({})][{}] success:{} fail:{}".format( i, baseurl, success_cnt, fail_cnt)) break else: print("[Testing({})][{}] success:{} fail:{}".format( i, baseurl, success_cnt, fail_cnt)) jobIds = _jobIds time.sleep(10) i = i + 10 response = listTest(testDeviceUrl) print(response)
def job(): testDeviceUrl = "http://18.162.111.9:8080/playerTest" streamUrl = "https://uat-ingest.hermeslive.com/origin/ingest/m3u8/master.m3u8" browserType = "chrome" duration = 30 playerType = "tfiPlayer" response = startTest(testDeviceUrl, streamUrl, browserType, duration, playerType) data = json.loads(response) jobId = data["jobId"] print("jobId: {}".format(jobId)) i = 0 while True: response = getResult(testDeviceUrl, jobId) data = json.loads(response) status = data["status"] if status == "SUCCESS": f = open(jobId+".txt", "a") f.write(data["testResult"]["resultInString"]) f.close() break else: print("{}({}) : {}".format(jobId, i, status)) time.sleep(10) i = i + 10 response = deleteTest(testDeviceUrl, jobId) print(response) response = listTest(testDeviceUrl) print(response)
def job2(): testDeviceUrl = "http://18.163.187.8:8080/playerTest" browserType = "chrome" duration = 30 playerType = "idlePage" response = start_lem_test(testDeviceUrl, browserType, duration, playerType) data = json.loads(response) jobId = data["jobId"] print("jobId: {}".format(jobId)) i = 0 while True: response = getResult(testDeviceUrl, jobId) data = json.loads(response) status = data["status"] if status == "SUCCESS": print(data["testResult"]) #f = open(jobId+".txt", "a") #f.write(data["testResult"]["resultInString"]) #f.close() break else: print("{}({}) : {}".format(jobId, i, status)) time.sleep(10) i = i + 10 response = deleteTest(testDeviceUrl, jobId) print(response) response = listTest(testDeviceUrl) print(response)
from aws_helper import listTest from aws_helper import deleteTest from aws_helper import describe_region_instances import json cluster = ['ap-east-1', 'ap-southeast-1', 'ap-northeast-1', 'ap-northeast-2'] #cluster = ['ap-east-1', 'ap-southeast-2'] ips = [] for region in cluster: response = describe_region_instances(region) for entry in response: if entry['key'] == 'andy_aws_test' and entry['state'] == 'running': ips.append(entry['ip']) for ip in ips: testDeviceUrl = "http://" + ip + ":8080/playerTest" response = listTest(testDeviceUrl) data = json.loads(response) i = 0 for status in data: print("({})jobid: {} {} duration: {}".format( i, status["jobId"], status["status"], status["config"]["duration"])) i = i + 1 deleteTest(testDeviceUrl, status["jobId"])