Fixed target url
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-10-23 17:31:23 +02:00
parent 0b5a47b531
commit 2910c0a2e2

View File

@ -31,9 +31,9 @@ class ReturnedRequest:
arrived: float arrived: float
def independent_worker(result_queue, filename: str, timeout: float): def independent_worker(result_queue, filename: str, timeout: float, target_url: str):
prepared_curl = pycurl.Curl() prepared_curl = pycurl.Curl()
prepared_curl.setopt(pycurl.URL, "https://birb.k8s.kmlabz.com/benchmark") prepared_curl.setopt(pycurl.URL, target_url)
prepared_curl.setopt(pycurl.SSL_VERIFYPEER, 0) prepared_curl.setopt(pycurl.SSL_VERIFYPEER, 0)
prepared_curl.setopt(pycurl.SSL_VERIFYHOST, 0) prepared_curl.setopt(pycurl.SSL_VERIFYHOST, 0)
# prepared_curl.setopt(pycurl.FORBID_REUSE, 0) # prepared_curl.setopt(pycurl.FORBID_REUSE, 0)
@ -101,14 +101,14 @@ def mqtt_on_subscribe(client, userdata, mid, granted_qos):
userdata.set() userdata.set()
def run_benchmark(num_workers: int, timeout: float, filename: str): def run_benchmark(num_workers: int, timeout: float, filename: str, target_url: str):
result_queue = multiprocessing.Queue() result_queue = multiprocessing.Queue()
workers = [] workers = []
for _ in range(num_workers): for _ in range(num_workers):
workers.append(multiprocessing.Process( workers.append(multiprocessing.Process(
target=independent_worker, target=independent_worker,
args=(result_queue, filename, timeout) args=(result_queue, filename, timeout, target_url)
)) ))
for w in workers: for w in workers:
@ -148,7 +148,8 @@ def write_results(results, file_handle):
# Latency and rtt are in ms # Latency and rtt are in ms
writer.writerow( writer.writerow(
['id', 'http_start_time', 'http_complete_time', 'http_time', 'status_code', 'mqtt_arrive_time', 'latency', 'rtt'] ['id', 'http_start_time', 'http_complete_time', 'http_time', 'status_code', 'mqtt_arrive_time', 'latency',
'rtt']
) )
for result in results: for result in results:
@ -192,7 +193,7 @@ def main():
help='Maximum time for request sending (0 for unlimited)') help='Maximum time for request sending (0 for unlimited)')
parser.add_argument('--file', type=str, required=True, help='Name of the sound file to upload') parser.add_argument('--file', type=str, required=True, help='Name of the sound file to upload')
parser.add_argument('--target-url', type=str, required=False, default="https://birb.k8s.kmlabz.com/sample", parser.add_argument('--target-url', type=str, required=False, default="https://birb.k8s.kmlabz.com/benchmark",
help='The target endpoint') help='The target endpoint')
parser.add_argument('--inflight-timeout', type=int, required=False, default=30, parser.add_argument('--inflight-timeout', type=int, required=False, default=30,
@ -235,7 +236,7 @@ def main():
print("MQTT Complete!") print("MQTT Complete!")
print("Running benchmark...") print("Running benchmark...")
benchmark_results = run_benchmark(args.workers, args.timeout, args.file) benchmark_results = run_benchmark(args.workers, args.timeout, args.file, args.target_url)
# Wait for inflight messages for a little # Wait for inflight messages for a little
total_successful_uploads = len([req for req in benchmark_results if req.upload_status_code == 200]) total_successful_uploads = len([req for req in benchmark_results if req.upload_status_code == 200])
@ -280,7 +281,6 @@ def main():
if not paired: if not paired:
print("Bruh moment: Alert arrived with an id that's not sent", returned_job.id) print("Bruh moment: Alert arrived with an id that's not sent", returned_job.id)
total_answered += 1 total_answered += 1
# print some mini statistics # print some mini statistics