trex_imix_test.py revision 193013a8
1#!/router/bin/python
2from .trex_general_test import CTRexGeneral_Test
3from CPlatform import CStaticRouteConfig
4from .tests_exceptions import *
5#import sys
6import time
7from nose.tools import nottest
8
9class CTRexIMIX_Test(CTRexGeneral_Test):
10    """This class defines the IMIX testcase of the TRex traffic generator"""
11    def __init__(self, *args, **kwargs):
12        # super(CTRexIMIX_Test, self).__init__()
13        CTRexGeneral_Test.__init__(self, *args, **kwargs)
14
15    def setUp(self):
16        super(CTRexIMIX_Test, self).setUp() # launch super test class setUp process
17        # CTRexGeneral_Test.setUp(self)       # launch super test class setUp process
18        # self.router.clear_counters()
19        pass
20
21    def test_short_flow(self):
22        """ short UDP flow with 64B packets, this test with small number of active flows """
23        # test initializtion
24        if not self.is_loopback:
25            self.router.configure_basic_interfaces()
26            self.router.config_pbr(mode = "config")
27
28        mult  = self.get_benchmark_param('multiplier')
29        core  = self.get_benchmark_param('cores')
30
31        ret = self.trex.start_trex(
32            c = core,
33            m = mult,
34            p  = True,
35            nc = True,
36            d = 30,
37            f = 'cap2/cur_flow.yaml',
38            l = 1000)
39
40        trex_res = self.trex.sample_to_run_finish()
41
42        # trex_res is a CTRexResult instance- and contains the summary of the test results
43        # you may see all the results keys by simply calling here for 'print trex_res.result'
44        print("\nLATEST RESULT OBJECT:")
45        print(trex_res)
46
47        self.check_general_scenario_results(trex_res)
48        self.check_CPU_benchmark(trex_res)
49
50    def test_short_flow_high_active(self):
51        """ short UDP flow with 64B packets, this test with 8M  active flows """
52        # test initializtion
53        if not self.is_loopback:
54            self.router.configure_basic_interfaces()
55            self.router.config_pbr(mode = "config")
56
57        mult  = self.get_benchmark_param('multiplier')
58        core  = self.get_benchmark_param('cores')
59        active_flows =self.get_benchmark_param('active_flows')
60
61
62        ret = self.trex.start_trex(
63            c = core,
64            m = mult,
65            p  = True,
66            nc = True,
67            d = 60,
68            active_flows = active_flows,
69            f = 'cap2/cur_flow.yaml',
70            l = 1000)
71
72        trex_res = self.trex.sample_to_run_finish()
73
74        # trex_res is a CTRexResult instance- and contains the summary of the test results
75        # you may see all the results keys by simply calling here for 'print trex_res.result'
76        print("\nLATEST RESULT OBJECT:")
77        print(trex_res)
78
79        self.check_general_scenario_results(trex_res)
80        self.check_CPU_benchmark(trex_res)
81
82    def test_short_flow_high_active2(self):
83        """ short UDP flow with 64B packets, this test with 8M  active flows """
84        # test initializtion
85        if not self.is_loopback:
86            self.router.configure_basic_interfaces()
87            self.router.config_pbr(mode = "config")
88
89        mult  = self.get_benchmark_param('multiplier')
90        core  = self.get_benchmark_param('cores')
91        active_flows =self.get_benchmark_param('active_flows')
92
93
94        ret = self.trex.start_trex(
95            c = core,
96            m = mult,
97            p  = True,
98            nc = True,
99            d = 60,
100            active_flows = active_flows,
101            f = 'cap2/cur_flow_single.yaml',
102            l = 1000)
103
104        trex_res = self.trex.sample_to_run_finish()
105
106        # trex_res is a CTRexResult instance- and contains the summary of the test results
107        # you may see all the results keys by simply calling here for 'print trex_res.result'
108        print("\nLATEST RESULT OBJECT:")
109        print(trex_res)
110
111        self.check_general_scenario_results(trex_res)
112        self.check_CPU_benchmark(trex_res)
113
114    def test_routing_imix_64(self):
115        # test initializtion
116        if not self.is_loopback:
117            self.router.configure_basic_interfaces()
118            self.router.config_pbr(mode = "config")
119
120#       self.trex.set_yaml_file('cap2/imix_64.yaml')
121        mult  = self.get_benchmark_param('multiplier')
122        core  = self.get_benchmark_param('cores')
123
124
125        # in case of VMXNET3 the number of bytes reported is 60 bytes for 64B
126        if self.is_VM:
127            self.trex.result_obj.set_warmup (0.89)
128
129#       trex_res = self.trex.run(multiplier = mult, cores = core, duration = 30, l = 1000, p = True)
130        ret = self.trex.start_trex(
131            c = core,
132            m = mult,
133            p  = True,
134            nc = True,
135            d = 30,
136            f = 'cap2/imix_64.yaml',
137            l = 1000)
138
139        trex_res = self.trex.sample_to_run_finish()
140
141        # trex_res is a CTRexResult instance- and contains the summary of the test results
142        # you may see all the results keys by simply calling here for 'print trex_res.result'
143        print("\nLATEST RESULT OBJECT:")
144        print(trex_res)
145
146        self.check_general_scenario_results(trex_res)
147        self.check_CPU_benchmark(trex_res)
148
149        if self.is_VM:
150            self.trex.result_obj.set_warmup_default()
151
152
153    # the name intentionally not matches nose default pattern, including the test should be specified explicitly
154    def dummy(self):
155        ret = self.trex.start_trex(
156            c = 1,
157            m = 1,
158            p  = True,
159            nc = True,
160            d = 5,
161            f = 'cap2/imix_fast_1g.yaml',
162            l = 1000,
163            trex_development = True)
164
165        trex_res = self.trex.sample_to_run_finish()
166        print(trex_res)
167
168    def test_routing_imix (self):
169        # test initializtion
170        if not self.is_loopback:
171            self.router.configure_basic_interfaces()
172            self.router.config_pbr(mode = "config")
173
174#       self.trex.set_yaml_file('cap2/imix_fast_1g.yaml')
175        mult = self.get_benchmark_param('multiplier')
176        core = self.get_benchmark_param('cores')
177
178        ret = self.trex.start_trex(
179            c = core,
180            m = mult,
181            p  = True,
182            nc = True,
183            d = 60,
184            f = 'cap2/imix_fast_1g.yaml',
185            l = 1000)
186
187        trex_res = self.trex.sample_to_run_finish()
188
189        # trex_res is a CTRexResult instance- and contains the summary of the test results
190        # you may see all the results keys by simply calling here for 'print trex_res.result'
191        print("\nLATEST RESULT OBJECT:")
192        print(trex_res)
193
194        self.check_general_scenario_results(trex_res)
195
196        self.check_CPU_benchmark(trex_res)
197
198
199    def test_static_routing_imix (self):
200        if self.is_loopback:
201            self.skip('In loopback mode the test is same as test_routing_imix')
202        # test initializtion
203        if not self.is_loopback:
204            self.router.configure_basic_interfaces()
205
206            # Configure static routing based on benchmark data input
207            stat_route_dict = self.get_benchmark_param('stat_route_dict')
208            stat_route_obj = CStaticRouteConfig(stat_route_dict)
209            self.router.config_static_routing(stat_route_obj, mode = "config")
210
211        mult = self.get_benchmark_param('multiplier')
212        core = self.get_benchmark_param('cores')
213
214        ret = self.trex.start_trex(
215            c = core,
216            m = mult,
217            e  = True,
218            nc = True,
219            d = 60,
220            f = 'cap2/imix_fast_1g.yaml',
221            l = 1000)
222
223        trex_res = self.trex.sample_to_run_finish()
224
225        # trex_res is a CTRexResult instance- and contains the summary of the test results
226        # you may see all the results keys by simply calling here for 'print trex_res.result'
227        print("\nLATEST RESULT OBJECT:")
228        print(trex_res)
229        print("\nLATEST DUMP:")
230        print(trex_res.get_latest_dump())
231
232        self.check_general_scenario_results(trex_res)
233        self.check_CPU_benchmark(trex_res)
234
235
236    def test_static_routing_imix_asymmetric (self):
237        # test initializtion
238        if not self.is_loopback:
239            self.router.configure_basic_interfaces()
240
241            # Configure static routing based on benchmark data input
242            stat_route_dict = self.get_benchmark_param('stat_route_dict')
243            stat_route_obj = CStaticRouteConfig(stat_route_dict)
244            self.router.config_static_routing(stat_route_obj, mode = "config")
245
246        mult = self.get_benchmark_param('multiplier')
247        core = self.get_benchmark_param('cores')
248
249        ret = self.trex.start_trex(
250            c = core,
251            m = mult,
252            nc = True,
253            d = 100,
254            f = 'cap2/imix_fast_1g.yaml',
255            l = 1000)
256
257        trex_res = self.trex.sample_to_run_finish()
258
259        # trex_res is a CTRexResults instance- and contains the summary of the test results
260        # you may see all the results keys by simply calling here for 'print trex_res.result'
261        print("\nLATEST RESULT OBJECT:")
262        print(trex_res)
263
264        self.check_general_scenario_results(trex_res)
265
266        self.check_CPU_benchmark(trex_res, minimal_cpu = 25)
267
268
269    def test_jumbo(self, duration = 100, **kwargs):
270        if not self.is_loopback:
271            self.router.configure_basic_interfaces(mtu = 9216)
272            self.router.config_pbr(mode = "config")
273
274        mult = self.get_benchmark_param('multiplier')
275        core = self.get_benchmark_param('cores')
276
277        ret = self.trex.start_trex(
278            c = core,
279            m = mult,
280            p = True,
281            nc = True,
282            d = duration,
283            f = 'cap2/imix_9k.yaml',
284            l = 1000,
285            **kwargs)
286
287        trex_res = self.trex.sample_to_run_finish()
288
289        # trex_res is a CTRexResults instance- and contains the summary of the test results
290        # you may see all the results keys by simply calling here for 'print trex_res.result'
291        print("\nLATEST RESULT OBJECT:")
292        print(trex_res)
293
294        self.check_general_scenario_results(trex_res)
295        self.check_CPU_benchmark(trex_res, minimal_cpu = 0, maximal_cpu = 10)
296
297    # don't include it to regular nose search
298    @nottest
299    def test_warm_up(self):
300        try:
301            self._testMethodName = 'test_jumbo'
302            self.test_jumbo(duration = 5, trex_development = True)
303        except Exception as e:
304            print('Ignoring this error: %s' % e)
305        if self.fail_reasons:
306            print('Ignoring this error(s):\n%s' % '\n'.join(self.fail_reasons))
307            self.fail_reasons = []
308
309    def tearDown(self):
310        CTRexGeneral_Test.tearDown(self)
311        # remove nbar config here
312        pass
313
314if __name__ == "__main__":
315    pass
316