-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic_test.py
50 lines (36 loc) · 1.04 KB
/
dynamic_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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
import random
from configparser import ConfigParser
from aioload.utils import get_logger
from aioload.runner import Runner
from aioload import get_arguments
PARAMS = [{
'name': 'foo',
}, {
'name': 'bar',
}, {
'name': 'baz',
}]
class CustomRunner(Runner):
async def request(self, *args, **kwargs):
"""Updates params in a random way."""
kwargs['params'].update(random.choice(PARAMS))
return await super(CustomRunner, self).request(*args, **kwargs)
def main():
"""Start script."""
args = get_arguments()
config = ConfigParser()
config.add_section('logging')
config.read(args.testfile)
logger, uuid = get_logger(args, config)
logger.info('Starting script...')
loop = asyncio.get_event_loop()
kwargs = {
'url': 'http://localhost:8000',
'method': 'get',
'params': dict(config['params']),
}
loop.run_until_complete(Runner(logger, args, **kwargs).start())
logger.info('Exiting script...')
if __name__ == '__main__':
main()