forked from dgubanovv/qa-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datapath_sanity.py
348 lines (294 loc) · 11.7 KB
/
datapath_sanity.py
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import os
import shutil
import time
import pytest
import tools.ping
from infra.test_base import TestBase
from tools.atltoolper import AtlTool
from tools.constants import FELICITY_CARDS, LINK_SPEED_AUTO, LINK_SPEED_100M, LINK_SPEED_1G, LINK_SPEED_2_5G, \
LINK_SPEED_5G, LINK_SPEED_10G, DIRECTION_RX, DIRECTION_RXTX
from tools.driver import Driver
from tools.utils import get_atf_logger
from tools.lom import LightsOutManagement
log = get_atf_logger()
def setup_module(module):
# import tools._test_setup # uncomment for manual test setup
os.environ["TEST"] = "datapath_sanity"
class TestDatapathSanity(TestBase):
"""
@description: The datapath sanity test is dedicated to perform fast datapath check of new firmware release.
It performs several datapath checks using ping, iperf and other tools.
@setup: Two Aquantia devices connected back to back.
"""
BEFORE_PING_DELAY = 10
BEFORE_IPERF_DELAY = 10
@classmethod
def setup_class(cls):
super(TestDatapathSanity, cls).setup_class()
try:
cls.log_server_dir = cls.create_logs_dir_on_log_server()
cls.install_firmwares()
cls.dut_driver = Driver(port=cls.dut_port, version=cls.dut_drv_version)
cls.lkp_driver = Driver(port=cls.lkp_port, version=cls.lkp_drv_version, host=cls.lkp_hostname)
cls.dut_driver.install()
cls.lkp_driver.install()
cls.dut_ifconfig.set_ip_address(cls.DUT_IPV4_ADDR, cls.NETMASK_IPV4, None)
cls.lkp_ifconfig.set_ip_address(cls.LKP_IPV4_ADDR, cls.NETMASK_IPV4, None)
if cls.MCP_LOG or os.environ.get("LOM_TEST", None):
cls.dut_atltool_wrapper = AtlTool(port=cls.dut_port)
cls.lkp_atltool_wrapper = AtlTool(port=cls.lkp_port, host=cls.lkp_hostname)
except Exception as e:
log.exception("Failed while setting up class")
raise e
def setup_method(self, method):
super(TestDatapathSanity, self).setup_method(method)
if os.environ.get("LOM_TEST", None):
self.LOM_ctrl = LightsOutManagement(host=self.dut_hostname, port=self.dut_port)
self.LOM_ctrl.dut_atltool_wrapper = AtlTool(port=self.dut_port)
self.LOM_ctrl.set_lom_mac_address(self.LOM_ctrl.LOM_MAC_ADDRESS)
self.LOM_ctrl.LoM_enable()
self.LOM_ctrl.set_lom_ip_address(self.LOM_ctrl.LOM_IP_ADDRESS)
if self.MCP_LOG:
self.bin_log_file, self.txt_log_file = self.dut_atltool_wrapper.debug_buffer_enable(True)
self.lkp_atltool_wrapper.debug_buffer_enable(True)
def teardown_method(self, method):
super(TestDatapathSanity, self).teardown_method(method)
if os.environ.get("LOM_TEST", None):
self.LOM_ctrl.LoM_disable()
if self.MCP_LOG:
self.dut_atltool_wrapper.debug_buffer_enable(False)
shutil.copy(self.bin_log_file, self.test_log_dir)
shutil.copy(self.txt_log_file, self.test_log_dir)
self.lkp_bin_log_file, self.lkp_txt_log_file = self.lkp_atltool_wrapper.debug_buffer_enable(False)
shutil.copy(self.lkp_bin_log_file, self.test_log_dir)
shutil.copy(self.lkp_txt_log_file, self.test_log_dir)
def setup_speeds(self, speed):
if self.dut_fw_card in FELICITY_CARDS or self.lkp_fw_card in FELICITY_CARDS:
if speed == LINK_SPEED_AUTO:
pytest.skip()
if self.supported_speeds is None:
raise Exception("Do not know supported speeds on Felicity")
if speed not in self.supported_speeds:
pytest.skip()
else:
if speed != LINK_SPEED_AUTO:
if speed not in self.supported_speeds:
pytest.skip()
self.dut_ifconfig.set_link_speed(speed)
self.lkp_ifconfig.set_link_speed(speed)
self.dut_ifconfig.wait_link_up(retry_interval=2)
time.sleep(self.BEFORE_PING_DELAY)
def run_ping_test(self, speed):
self.setup_speeds(speed)
assert tools.ping.ping(16, self.LKP_IPV4_ADDR, payload_size=0)
assert tools.ping.ping(16, self.LKP_IPV4_ADDR, payload_size=17000)
def run_iperf_test(self, speed, iperf_kwargs):
self.setup_speeds(speed)
self.run_iperf(**iperf_kwargs)
def test_ping_100m(self):
"""
@description: This subtest performs ping check on 100M link speed.
@steps:
1. Run ping with default packet size (16 ping requests).
2. Make sure all pings are answered.
3. Run ping with 17000 bytes packet size (16 ping requests).
4. Make sure all pings are answered.
@result: Ping is passed.
@duration: 2 minutes.
"""
self.run_ping_test(LINK_SPEED_100M)
def test_ping_1g(self):
"""
@description: This subtest performs ping check on 1G link speed.
@steps:
1. Run ping with default packet size (16 ping requests).
2. Make sure all pings are answered.
3. Run ping with 17000 bytes packet size (16 ping requests).
4. Make sure all pings are answered.
@result: Ping is passed.
@duration: 2 minutes.
"""
self.run_ping_test(LINK_SPEED_1G)
def test_ping_2_5g(self):
"""
@description: This subtest performs ping check on 2.5G link speed.
@steps:
1. Run ping with default packet size (16 ping requests).
2. Make sure all pings are answered.
3. Run ping with 17000 bytes packet size (16 ping requests).
4. Make sure all pings are answered.
@result: Ping is passed.
@duration: 2 minutes.
"""
self.run_ping_test(LINK_SPEED_2_5G)
def test_ping_5g(self):
"""
@description: This subtest performs ping check on 5G link speed.
@steps:
1. Run ping with default packet size (16 ping requests).
2. Make sure all pings are answered.
3. Run ping with 17000 bytes packet size (16 ping requests).
4. Make sure all pings are answered.
@result: Ping is passed.
@duration: 2 minutes.
"""
self.run_ping_test(LINK_SPEED_5G)
def test_ping_10g(self):
"""
@description: This subtest performs ping check on 10G link speed.
@steps:
1. Run ping with default packet size (16 ping requests).
2. Make sure all pings are answered.
3. Run ping with 17000 bytes packet size (16 ping requests).
4. Make sure all pings are answered.
@result: Ping is passed.
@duration: 2 minutes.
"""
self.run_ping_test(LINK_SPEED_10G)
def test_iperf_100m(self):
"""
@description: This subtest performs bidirectional iperf check on 100M link speed.
@steps:
1. Run iperf server on DUT.
2. Run iperf server on LKP.
3. Run iperf client on DUT for 27 seconds.
4. Run iperf client on LKP for 27 seconds.
5. Make sure that perf exited without error.
@result: Iperf exited without error, there are no traffic drops.
@duration: 2 minutes.
"""
args = {
'direction': DIRECTION_RXTX,
'speed': LINK_SPEED_100M,
'num_threads': 1,
'num_process': 1,
'time': 27,
'ipv': 4,
'buffer_len': 0,
'is_udp': False,
'is_eee': False,
'is_ptp': False,
'lkp': self.lkp_hostname,
'dut': self.dut_hostname,
'lkp4': self.LKP_IPV4_ADDR,
'dut4': self.DUT_IPV4_ADDR,
}
self.run_iperf_test(LINK_SPEED_100M, args)
def test_iperf_1g(self):
"""
@description: This subtest performs bidirectional iperf check on 1G link speed.
@steps:
1. Run iperf server on DUT.
2. Run iperf server on LKP.
3. Run iperf client on DUT for 27 seconds.
4. Run iperf client on LKP for 27 seconds.
5. Make sure that perf exited without error.
@result: Iperf exited without error, there are no traffic drops.
@duration: 2 minutes.
"""
args = {
'direction': DIRECTION_RXTX,
'speed': LINK_SPEED_1G,
'num_threads': 1,
'num_process': 1,
'time': 27,
'ipv': 4,
'buffer_len': 0,
'is_udp': False,
'is_eee': False,
'is_ptp': False,
'lkp': self.lkp_hostname,
'dut': self.dut_hostname,
'lkp4': self.LKP_IPV4_ADDR,
'dut4': self.DUT_IPV4_ADDR,
}
self.run_iperf_test(LINK_SPEED_1G, args)
def test_iperf_2_5g(self):
"""
@description: This subtest performs bidirectional iperf check on 2.5G link speed.
@steps:
1. Run iperf server on DUT.
2. Run iperf server on LKP.
3. Run iperf client on DUT for 27 seconds.
4. Run iperf client on LKP for 27 seconds.
5. Make sure that perf exited without error.
@result: Iperf exited without error, there are no traffic drops.
@duration: 2 minutes.
"""
args = {
'direction': DIRECTION_RXTX,
'speed': LINK_SPEED_2_5G,
'num_threads': 1,
'num_process': 1,
'time': 27,
'ipv': 4,
'buffer_len': 0,
'is_udp': False,
'is_eee': False,
'is_ptp': False,
'lkp': self.lkp_hostname,
'dut': self.dut_hostname,
'lkp4': self.LKP_IPV4_ADDR,
'dut4': self.DUT_IPV4_ADDR,
}
self.run_iperf_test(LINK_SPEED_2_5G, args)
def test_iperf_5g(self):
"""
@description: This subtest performs bidirectional iperf check on 5G link speed.
@steps:
1. Run iperf server on DUT.
2. Run iperf server on LKP.
3. Run iperf client on DUT for 27 seconds.
4. Run iperf client on LKP for 27 seconds.
5. Make sure that perf exited without error.
@result: Iperf exited without error, there are no traffic drops.
@duration: 2 minutes.
"""
args = {
'direction': DIRECTION_RXTX,
'speed': LINK_SPEED_5G,
'num_threads': 1,
'num_process': 1,
'time': 27,
'ipv': 4,
'buffer_len': 0,
'is_udp': False,
'is_eee': False,
'is_ptp': False,
'lkp': self.lkp_hostname,
'dut': self.dut_hostname,
'lkp4': self.LKP_IPV4_ADDR,
'dut4': self.DUT_IPV4_ADDR,
}
self.run_iperf_test(LINK_SPEED_5G, args)
def test_iperf_10g(self):
"""
@description: This subtest performs bidirectional iperf check on 10G link speed.
@steps:
1. Run iperf server on DUT.
2. Run iperf server on LKP.
3. Run iperf client on DUT for 27 seconds.
4. Run iperf client on LKP for 27 seconds.
5. Make sure that perf exited without error.
@result: Iperf exited without error, there are no traffic drops.
@duration: 2 minutes.
"""
args = {
'direction': DIRECTION_RXTX,
'speed': LINK_SPEED_10G,
'num_threads': 1,
'num_process': 1,
'time': 27,
'ipv': 4,
'buffer_len': 0,
'is_udp': False,
'is_eee': False,
'is_ptp': False,
'lkp': self.lkp_hostname,
'dut': self.dut_hostname,
'lkp4': self.LKP_IPV4_ADDR,
'dut4': self.DUT_IPV4_ADDR,
}
self.run_iperf_test(LINK_SPEED_10G, args)
if __name__ == "__main__":
pytest.main([__file__, "-s", "-v"])