TEST-2 load/soak test utility
[testsuite/python-testing-utils.git] / loadtest / TestConfig.py
1 '''
2 Created on Apr 7, 2017
3
4 @author: jf9860
5 '''
6 class TestConfig(object):
7     '''
8     The profile defines a cycle of tests. Each entry is defined as
9     [<seconds to wait>, [<list of ete tags to run after the wait]],
10     '''
11     profile =    [
12         [0, ["health"]],
13         [5, ["instantiate", "distribute"]],
14         [300, ["distribute"]],
15         [300, ["distribute"]],
16         [300, ["distribute"]],
17         [300, ["distribute"]],
18         [300, ["distribute"]],
19     ]
20
21     duration=10
22     cyclelength=60
23
24     def __init__(self, duration=10, cyclelength=1800, json=None):
25         '''
26         Constructor
27         '''
28         self.duration = duration
29         self.cyclelength = cyclelength
30         running_time = 0
31         for p in self.profile:
32             secs = p[0]
33             running_time = running_time + secs
34         if (running_time < cyclelength):
35             last = cyclelength - running_time
36             self.profile.append([last, []])
37
38     def to_string(self):
39         pstring = 'Cycle length is {} seconds'.format(self.cyclelength)
40         pstring = '{}\nDuration is {} seconds'.format(pstring, self.duration)
41         running_time = 0
42         for p in self.profile:
43             secs = p[0]
44             running_time = running_time + secs
45             for ete in p[1]:
46                 pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, ete)
47             if (len(p[1]) == 0):
48                 pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, "")
49         return pstring
50
51