-
Notifications
You must be signed in to change notification settings - Fork 20
/
yayclient
executable file
·63 lines (47 loc) · 1.42 KB
/
yayclient
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
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
yayclient - command-line development tool
"""
import unittest
import getopt
import sys
import os
sys.path.append("tests/pytests")
import DbClient
import load_generator
from post_tests import TestPostFunction
from basic_tests import TestBasicFunctions
from ConfigParser import SafeConfigParser
def main():
os.environ['yay_root'] = os.getcwd()
commands = {
'reset' : reset,
'test' : test,
'bootstrap': bootstrap
}
del sys.argv[0]
cmd = sys.argv[0]
del sys.argv[0]
args = sys.argv
if cmd not in commands:
err_message = ("'%s' is not a command; see -h for more help.") % cmd
print err_message
exit
cfg = SafeConfigParser()
cfg.read(['tests/yay.ini'])
args.insert(0, cfg)
commands[cmd](*args)
def reset(cfg):
DbClient.reset_database(cfg.get('db', 'host'), cfg.get('db', 'database'),
cfg.get('db', 'username'), cfg.get('db', 'password'))
def test(cfg):
basic = unittest.TestLoader().loadTestsFromTestCase(TestBasicFunctions)
post = unittest.TestLoader().loadTestsFromTestCase(TestPostFunction)
suite = unittest.TestSuite([basic, post])
unittest.TextTestRunner(verbosity=2).run(suite)
def bootstrap(cfg, users=5, threads=10, replies=100):
reset(cfg)
load_generator.bootstrap(int(users), int(threads), int(replies))
if __name__ == '__main__':
main()