summaryrefslogtreecommitdiffstats
path: root/loadtest/TestConfig.py
blob: c22e875c44ebf2c4f2326487290ecdb7b06bceef (plain)
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
'''
Created on Apr 7, 2017

@author: jf9860
'''
class TestConfig(object):
    '''
    The profile defines a cycle of tests. Each entry is defined as
    [<seconds to wait>, [<list of ete tags to run after the wait]],
    '''
    profile =    [
        [0, ["health"]],
        [5, ["instantiate", "distribute"]],
        [300, ["distribute"]],
        [300, ["distribute"]],
        [300, ["distribute"]],
        [300, ["distribute"]],
        [300, ["distribute"]],
    ]

    duration=10
    cyclelength=60

    def __init__(self, duration=10, cyclelength=1800, json=None):
        '''
        Constructor
        '''
        self.duration = duration
        self.cyclelength = cyclelength
        running_time = 0
        for p in self.profile:
            secs = p[0]
            running_time = running_time + secs
        if (running_time < cyclelength):
            last = cyclelength - running_time
            self.profile.append([last, []])

    def to_string(self):
        pstring = 'Cycle length is {} seconds'.format(self.cyclelength)
        pstring = '{}\nDuration is {} seconds'.format(pstring, self.duration)
        running_time = 0
        for p in self.profile:
            secs = p[0]
            running_time = running_time + secs
            for ete in p[1]:
                pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, ete)
            if (len(p[1]) == 0):
                pstring = "{0}\n{1:08d} : {2:08d} : {3}".format(pstring, secs, running_time, "")
        return pstring