-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstress-test.py
27 lines (20 loc) · 863 Bytes
/
stress-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!bin/python3
import argparse
from stress_test.request_thread import RequestThread
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--calls', type=int, help='Amount of calls to be done per each Thread')
parser.add_argument('-t', '--threads', type=int, help='Amount of Threads to be used')
parser.add_argument('--host', type=str, help='IP address or hostname to be called')
arguments = parser.parse_args()
calls = arguments.calls or 10
threads = arguments.threads or 1
host = arguments.host or 'http://localhost/'
if not host.startswith('http'):
print('[WARN] - Protocol not selected, using default (HTTP)')
host = 'http://' + host
threads_pool = []
for i in range(threads):
name = 'thread-{id}'.format(id=i)
thread = RequestThread(name=name, calls_amount=calls, address=host)
threads_pool.append(thread)
thread.start()