trex_imix_test.py revision 9fa4e8f9
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_routing_imix_64(self):
22        # test initializtion
23        if not self.is_loopback:
24            self.router.configure_basic_interfaces()
25            self.router.config_pbr(mode = "config")
26
27#       self.trex.set_yaml_file('cap2/imix_64.yaml')
28        mult  = self.get_benchmark_param('multiplier')
29        core  = self.get_benchmark_param('cores')
30
31#       trex_res = self.trex.run(multiplier = mult, cores = core, duration = 30, l = 1000, p = True)
32        ret = self.trex.start_trex(
33            c = core,
34            m = mult,
35            p  = True,
36            nc = True,
37            d = 30,
38            f = 'cap2/imix_64.yaml',
39            l = 1000)
40
41        trex_res = self.trex.sample_to_run_finish()
42
43        # trex_res is a CTRexResult instance- and contains the summary of the test results
44        # you may see all the results keys by simply calling here for 'print trex_res.result'
45        print("\nLATEST RESULT OBJECT:")
46        print(trex_res)
47
48        self.check_general_scenario_results(trex_res)
49        self.check_CPU_benchmark(trex_res)
50
51    # the name intentionally not matches nose default pattern, including the test should be specified explicitly
52    def dummy(self):
53        ret = self.trex.start_trex(
54            c = 1,
55            m = 1,
56            p  = True,
57            nc = True,
58            d = 5,
59            f = 'cap2/imix_fast_1g.yaml',
60            l = 1000,
61            trex_development = True)
62
63        trex_res = self.trex.sample_to_run_finish()
64        print(trex_res)
65
66    def test_routing_imix (self):
67        # test initializtion
68        if not self.is_loopback:
69            self.router.configure_basic_interfaces()
70            self.router.config_pbr(mode = "config")
71
72#       self.trex.set_yaml_file('cap2/imix_fast_1g.yaml')
73        mult = self.get_benchmark_param('multiplier')
74        core = self.get_benchmark_param('cores')
75
76        ret = self.trex.start_trex(
77            c = core,
78            m = mult,
79            p  = True,
80            nc = True,
81            d = 60,
82            f = 'cap2/imix_fast_1g.yaml',
83            l = 1000)
84
85        trex_res = self.trex.sample_to_run_finish()
86
87        # trex_res is a CTRexResult instance- and contains the summary of the test results
88        # you may see all the results keys by simply calling here for 'print trex_res.result'
89        print("\nLATEST RESULT OBJECT:")
90        print(trex_res)
91
92        self.check_general_scenario_results(trex_res)
93
94        self.check_CPU_benchmark(trex_res)
95
96
97    def test_static_routing_imix (self):
98        if self.is_loopback:
99            self.skip('In loopback mode the test is same as test_routing_imix')
100        # test initializtion
101        if not self.is_loopback:
102            self.router.configure_basic_interfaces()
103
104            # Configure static routing based on benchmark data input
105            stat_route_dict = self.get_benchmark_param('stat_route_dict')
106            stat_route_obj = CStaticRouteConfig(stat_route_dict)
107            self.router.config_static_routing(stat_route_obj, mode = "config")
108
109        mult = self.get_benchmark_param('multiplier')
110        core = self.get_benchmark_param('cores')
111
112        ret = self.trex.start_trex(
113            c = core,
114            m = mult,
115            e  = True,
116            nc = True,
117            d = 60,
118            f = 'cap2/imix_fast_1g.yaml',
119            l = 1000)
120
121        trex_res = self.trex.sample_to_run_finish()
122
123        # trex_res is a CTRexResult instance- and contains the summary of the test results
124        # you may see all the results keys by simply calling here for 'print trex_res.result'
125        print("\nLATEST RESULT OBJECT:")
126        print(trex_res)
127        print("\nLATEST DUMP:")
128        print(trex_res.get_latest_dump())
129
130        self.check_general_scenario_results(trex_res)
131        self.check_CPU_benchmark(trex_res)
132
133
134    def test_static_routing_imix_asymmetric (self):
135        # test initializtion
136        if not self.is_loopback:
137            self.router.configure_basic_interfaces()
138
139            # Configure static routing based on benchmark data input
140            stat_route_dict = self.get_benchmark_param('stat_route_dict')
141            stat_route_obj = CStaticRouteConfig(stat_route_dict)
142            self.router.config_static_routing(stat_route_obj, mode = "config")
143
144        mult = self.get_benchmark_param('multiplier')
145        core = self.get_benchmark_param('cores')
146
147        ret = self.trex.start_trex(
148            c = core,
149            m = mult,
150            nc = True,
151            d = 100,
152            f = 'cap2/imix_fast_1g.yaml',
153            l = 1000)
154
155        trex_res = self.trex.sample_to_run_finish()
156
157        # trex_res is a CTRexResults instance- and contains the summary of the test results
158        # you may see all the results keys by simply calling here for 'print trex_res.result'
159        print("\nLATEST RESULT OBJECT:")
160        print(trex_res)
161
162        self.check_general_scenario_results(trex_res)
163
164        self.check_CPU_benchmark(trex_res, minimal_cpu = 25)
165
166
167    def test_jumbo(self, duration = 100, **kwargs):
168        if not self.is_loopback:
169            self.router.configure_basic_interfaces(mtu = 9216)
170            self.router.config_pbr(mode = "config")
171
172        mult = self.get_benchmark_param('multiplier')
173        core = self.get_benchmark_param('cores')
174
175        ret = self.trex.start_trex(
176            c = core,
177            m = mult,
178            p = True,
179            nc = True,
180            d = duration,
181            f = 'cap2/imix_9k.yaml',
182            l = 1000,
183            **kwargs)
184
185        trex_res = self.trex.sample_to_run_finish()
186
187        # trex_res is a CTRexResults instance- and contains the summary of the test results
188        # you may see all the results keys by simply calling here for 'print trex_res.result'
189        print("\nLATEST RESULT OBJECT:")
190        print(trex_res)
191
192        self.check_general_scenario_results(trex_res)
193        self.check_CPU_benchmark(trex_res, minimal_cpu = 0, maximal_cpu = 10)
194
195    # don't include it to regular nose search
196    @nottest
197    def test_warm_up(self):
198        try:
199            self._testMethodName = 'test_jumbo'
200            self.test_jumbo(duration = 5, trex_development = True)
201        except Exception as e:
202            print('Ignoring this error: %s' % e)
203        if self.fail_reasons:
204            print('Ignoring this error(s):\n%s' % '\n'.join(self.fail_reasons))
205            self.fail_reasons = []
206
207    def tearDown(self):
208        CTRexGeneral_Test.tearDown(self)
209        # remove nbar config here
210        pass
211
212if __name__ == "__main__":
213    pass
214