summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/stateful_tests/trex_imix_test.py
blob: f8fe0ed17f700abb196cd136ebe6b07f3c17d667 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/router/bin/python
from .trex_general_test import CTRexGeneral_Test
from CPlatform import CStaticRouteConfig
from .tests_exceptions import *
#import sys
import time
from nose.tools import nottest

class CTRexIMIX_Test(CTRexGeneral_Test):
    """This class defines the IMIX testcase of the TRex traffic generator"""
    def __init__(self, *args, **kwargs):
        # super(CTRexIMIX_Test, self).__init__()
        CTRexGeneral_Test.__init__(self, *args, **kwargs)

    def setUp(self):
        super(CTRexIMIX_Test, self).setUp() # launch super test class setUp process
        # CTRexGeneral_Test.setUp(self)       # launch super test class setUp process
        # self.router.clear_counters()
        pass

    def test_routing_imix_64(self):
        # test initializtion
        if not self.is_loopback:
            self.router.configure_basic_interfaces()
            self.router.config_pbr(mode = "config")

#       self.trex.set_yaml_file('cap2/imix_64.yaml')
        mult  = self.get_benchmark_param('multiplier')
        core  = self.get_benchmark_param('cores')

#       trex_res = self.trex.run(multiplier = mult, cores = core, duration = 30, l = 1000, p = True)
        ret = self.trex.start_trex(
            c = core,
            m = mult,
            p  = True,
            nc = True,
            d = 30,   
            f = 'cap2/imix_64.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        # trex_res is a CTRexResult instance- and contains the summary of the test results
        # you may see all the results keys by simply calling here for 'print trex_res.result'
        print("\nLATEST RESULT OBJECT:")
        print(trex_res)

        self.check_general_scenario_results(trex_res)
        self.check_CPU_benchmark(trex_res)

    # the name intentionally not matches nose default pattern, including the test should be specified explicitly
    def dummy(self):
        ret = self.trex.start_trex(
            c = 1,
            m = 1,
            p  = True,
            nc = True,
            d = 5,
            f = 'cap2/imix_fast_1g.yaml',
            l = 1000,
            trex_development = True)

        trex_res = self.trex.sample_to_run_finish()
        print(trex_res)

    def test_routing_imix (self):
        # test initializtion
        if not self.is_loopback:
            self.router.configure_basic_interfaces()
            self.router.config_pbr(mode = "config")

#       self.trex.set_yaml_file('cap2/imix_fast_1g.yaml')
        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

        ret = self.trex.start_trex(
            c = core,
            m = mult,
            p  = True,
            nc = True,
            d = 60,   
            f = 'cap2/imix_fast_1g.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        # trex_res is a CTRexResult instance- and contains the summary of the test results
        # you may see all the results keys by simply calling here for 'print trex_res.result'
        print("\nLATEST RESULT OBJECT:")
        print(trex_res)

        self.check_general_scenario_results(trex_res)

        self.check_CPU_benchmark(trex_res)


    def test_static_routing_imix (self):
        if self.is_loopback:
            self.skip('In loopback mode the test is same as test_routing_imix')
        # test initializtion
        if not self.is_loopback:
            self.router.configure_basic_interfaces()

            # Configure static routing based on benchmark data input
            stat_route_dict = self.get_benchmark_param('stat_route_dict')
            stat_route_obj = CStaticRouteConfig(stat_route_dict)
            self.router.config_static_routing(stat_route_obj, mode = "config")

        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

        ret = self.trex.start_trex(
            c = core,
            m = mult,
            p  = True,
            nc = True,
            d = 60,   
            f = 'cap2/imix_fast_1g.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        # trex_res is a CTRexResult instance- and contains the summary of the test results
        # you may see all the results keys by simply calling here for 'print trex_res.result'
        print("\nLATEST RESULT OBJECT:")
        print(trex_res)
        print("\nLATEST DUMP:")
        print(trex_res.get_latest_dump())

        self.check_general_scenario_results(trex_res)
        self.check_CPU_benchmark(trex_res)


    def test_static_routing_imix_asymmetric (self):
        # test initializtion
        if not self.is_loopback:
            self.router.configure_basic_interfaces()

            # Configure static routing based on benchmark data input
            stat_route_dict = self.get_benchmark_param('stat_route_dict')
            stat_route_obj = CStaticRouteConfig(stat_route_dict)
            self.router.config_static_routing(stat_route_obj, mode = "config")

        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

        ret = self.trex.start_trex(
            c = core,
            m = mult,
            nc = True,
            d = 100,   
            f = 'cap2/imix_fast_1g.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        # trex_res is a CTRexResults instance- and contains the summary of the test results
        # you may see all the results keys by simply calling here for 'print trex_res.result'
        print("\nLATEST RESULT OBJECT:")
        print(trex_res)

        self.check_general_scenario_results(trex_res)

        self.check_CPU_benchmark(trex_res, minimal_cpu = 25)


    def test_jumbo(self, duration = 100, **kwargs):
        if not self.is_loopback:
            self.router.configure_basic_interfaces(mtu = 9216)
            self.router.config_pbr(mode = "config")

        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

        ret = self.trex.start_trex(
            c = core,
            m = mult,
            p = True,
            nc = True,
            d = duration,
            f = 'cap2/imix_9k.yaml',
            l = 1000,
            **kwargs)

        trex_res = self.trex.sample_to_run_finish()

        # trex_res is a CTRexResults instance- and contains the summary of the test results
        # you may see all the results keys by simply calling here for 'print trex_res.result'
        print("\nLATEST RESULT OBJECT:")
        print(trex_res)

        self.check_general_scenario_results(trex_res)
        self.check_CPU_benchmark(trex_res, minimal_cpu = 0, maximal_cpu = 10)

    # don't include it to regular nose search
    @nottest
    def test_warm_up(self):
        try:
            self._testMethodName = 'test_jumbo'
            self.test_jumbo(duration = 5, trex_development = True)
        except Exception as e:
            print('Ignoring this error: %s' % e)
        if self.fail_reasons:
            print('Ignoring this error(s):\n%s' % '\n'.join(self.fail_reasons))
            self.fail_reasons = []

    def tearDown(self):
        CTRexGeneral_Test.tearDown(self)
        # remove nbar config here
        pass

if __name__ == "__main__":
    pass