-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflood_test.py
419 lines (327 loc) · 14.7 KB
/
flood_test.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
import os
import time
import timeit
import pytest
from tools.atltoolper import AtlTool
from tools.eee import EEE
from tools.killer import Killer
from tools.command import Command
from tools.driver import Driver
from tools.utils import get_atf_logger
from tools.ops import OpSystem
from tools.constants import LINK_SPEED_100M, LINK_SPEED_1G, LINK_SPEED_2_5G, LINK_SPEED_5G, LINK_SPEED_10G, \
DIRECTION_RX, DIRECTION_TX
from infra.test_base import TestBase
log = get_atf_logger()
def setup_module(module):
# import tools._test_setup # uncomment for manual test setup
os.environ["TEST"] = "ping_flood"
class TestPingFlood(TestBase):
"""
@description: The TestPingFlood test is dedicated to perform check of EEE stability with switches.
It performs several cycles of ping flood from the host with EEE enabled.
@setup: Two Aquantia devices connected to 2 ports with EEE support on switch.
"""
PING_LOG_PATH = "~/pingFlood.log"
FLOOD_TIME = 600
NOF_CYCLES = 3
@classmethod
def setup_class(cls):
super(TestPingFlood, 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_IPV4_ADDR = cls.suggest_test_ip_address(cls.dut_port)
cls.LKP_IPV4_ADDR = cls.suggest_test_ip_address(cls.lkp_port, cls.lkp_hostname)
cls.NETMASK_IPV4 = "255.255.0.0"
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)
cls.atltool_wrapper_dut = AtlTool(port=cls.dut_port)
cls.atltool_wrapper_lkp = AtlTool(host=cls.lkp_hostname, port=cls.lkp_port)
cls.op_sys_lkp = OpSystem(host=cls.lkp_hostname)
cls.op_sys_dut = OpSystem()
cls.eee = EEE(dut_hostname=cls.dut_hostname, dut_port=cls.dut_port,
lkp_hostname=cls.lkp_hostname, lkp_port=cls.lkp_port)
except Exception as e:
log.exception("Failed while setting up class")
raise e
def kill_ping_on_machines(self):
Killer().kill("ping")
Killer(host=self.lkp_hostname).kill("ping")
@classmethod
def teardown_class(cls):
super(TestPingFlood, cls).teardown_class()
command_rm = 'rm -rf {}'.format(cls.PING_LOG_PATH)
Command(cmd=command_rm, host=cls.dut_hostname).run()
Command(cmd=command_rm, host=cls.lkp_hostname).run()
def verify_eee_fails_during_ping_flood(self, speed, ip_address, host):
statistics_base_addr = self.atltool_wrapper_dut.readreg(0x360)
nof_eee_failures_before = self.atltool_wrapper_dut.readmem(statistics_base_addr + 0xe0, 4)[0]
command_host = 'sudo ping -f {} > {}'.format(ip_address, self.PING_LOG_PATH)
command_run_host = Command(cmd=command_host, host=host)
command_run_host.run_async()
start = timeit.default_timer()
while True:
nof_eee_failures_after = self.atltool_wrapper_dut.readmem(statistics_base_addr + 0xe0, 4)[0]
if (nof_eee_failures_before != nof_eee_failures_after) | (timeit.default_timer() - start > self.FLOOD_TIME):
command_run_host.join(1)
self.kill_ping_on_machines()
break
time.sleep(5)
def verify_link_downs_during_ping_flood(self, speed, ip_address, host):
statistics_base_addr = self.atltool_wrapper_dut.readreg(0x360)
nof_link_downs_before = self.atltool_wrapper_dut.readmem(statistics_base_addr + 0xb8, 4)[0]
command_host = 'sudo ping -f {} > {}'.format(ip_address, self.PING_LOG_PATH)
command_run_host = Command(cmd=command_host, host=host)
command_run_host.run_async()
start = timeit.default_timer()
while True:
nof_link_downs_after = self.atltool_wrapper_dut.readmem(statistics_base_addr + 0xb8, 4)[0]
if (nof_link_downs_before != nof_link_downs_after) | (timeit.default_timer() - start > self.FLOOD_TIME):
command_run_host.join(1)
self.kill_ping_on_machines()
break
time.sleep(5)
def cfg_hosts_and_run_ping_flood(self, speed, direction):
if speed not in self.supported_speeds:
pytest.skip()
self.kill_ping_on_machines()
times_eee_disable = []
for i in range(self.NOF_CYCLES):
self.dut_ifconfig.set_link_speed(speed)
self.lkp_ifconfig.set_link_speed(speed)
# Wait for link up on both hosts since they are connected with switch
# On Buffalo switch sometimes link becomes UP very slow, so we use 300 sec timeout here
self.dut_ifconfig.wait_link_up(timeout=300, retry_interval=5)
self.lkp_ifconfig.wait_link_up(timeout=300, retry_interval=5)
start = timeit.default_timer()
if direction == DIRECTION_TX:
self.verify_link_downs_during_ping_flood(speed, ip_address=self.LKP_IPV4_ADDR, host=self.dut_hostname)
elif direction == DIRECTION_RX:
self.verify_link_downs_during_ping_flood(speed, ip_address=self.DUT_IPV4_ADDR, host=self.lkp_hostname)
duration = timeit.default_timer() - start
if duration < self.FLOOD_TIME:
log.info("Link was dropped after {} second".format(duration))
else:
log.debug("Link was stable during {} seconds".format(duration))
times_eee_disable.append(duration)
time.sleep(5)
if all(i > self.FLOOD_TIME for i in times_eee_disable):
log.debug("Link was stable {} seconds".format(times_eee_disable))
assert all(i > self.FLOOD_TIME for i in times_eee_disable), \
"Link unexpectedly was dropped unexpectedly {}".format(times_eee_disable)
def cfg_hosts_with_eee_and_run_ping_flood(self, speed, direction):
if speed not in self.supported_speeds:
pytest.skip()
times_eee_disable = []
for i in range(self.NOF_CYCLES):
self.dut_ifconfig.set_link_speed(speed)
self.lkp_ifconfig.set_link_speed(speed)
# Wait for link up on both hosts since they are connected with switch
# On Buffalo switch sometimes link becomes UP very slow, so we use 300 sec timeout here
self.dut_ifconfig.wait_link_up(timeout=300, retry_interval=5)
self.lkp_ifconfig.wait_link_up(timeout=300, retry_interval=5)
self.eee.enable()
self.eee.disable(EEE.LKP)
# Wait 10 seconds for EEE become enable
time.sleep(10)
start = timeit.default_timer()
if direction == DIRECTION_TX:
self.verify_eee_fails_during_ping_flood(speed, ip_address=self.LKP_IPV4_ADDR, host=self.dut_hostname)
elif direction == DIRECTION_RX:
self.verify_eee_fails_during_ping_flood(speed, ip_address=self.DUT_IPV4_ADDR, host=self.lkp_hostname)
duration = timeit.default_timer() - start
if duration < self.FLOOD_TIME:
log.info("EEE was disabled after {} second".format(duration))
else:
log.debug("EEE didn't disabled during {} seconds".format(duration))
self.eee.disable(EEE.DUT)
times_eee_disable.append(duration)
time.sleep(5)
if all(i > self.FLOOD_TIME for i in times_eee_disable):
log.debug("EEE was stable {} seconds".format(times_eee_disable))
assert all(i > self.FLOOD_TIME for i in times_eee_disable), \
"EEE was disaled unexpectedly {}".format(times_eee_disable)
# There are no EEE on 100M and 1G
def test_2_5G_eee_on_DUT_tx(self):
"""
@description: This subtest performs 2.5G EEE stability check on DUT host.
@steps:
1. Enable 2.5G EEE on DUT.
2. Disable 2.5G EEE on LKP.
3. Run ping flood from DUT to LKP.
@result: 2.5G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_2_5G, DIRECTION_TX)
def test_5G_eee_on_DUT_tx(self):
"""
@description: This subtest performs 5G EEE stability check on DUT host.
@steps:
1. Enable 5G EEE on DUT.
2. Disable 5G EEE on LKP.
3. Run ping flood from DUT to LKP.
@result: 5G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_5G, DIRECTION_TX)
def test_10G_eee_on_DUT_tx(self):
"""
@description: This subtest performs 10G EEE stability check on DUT host.
@steps:
1. Enable 10G EEE on DUT.
2. Disable 10G EEE on LKP.
3. Run ping flood from DUT to LKP.
@result: 10G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_10G, DIRECTION_TX)
def test_2_5G_eee_on_DUT_rx(self):
"""
@description: This subtest performs 2.5G EEE stability check on DUT host.
@steps:
1. Enable 2.5G EEE on DUT.
2. Disable 2.5G EEE on LKP.
3. Run ping flood from LKP to DUT.
@result: 2.5G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_2_5G, DIRECTION_RX)
def test_5G_eee_on_DUT_rx(self):
"""
@description: This subtest performs 5G EEE stability check on DUT host.
@steps:
1. Enable 5G EEE on DUT.
2. Disable 5G EEE on LKP.
3. Run ping flood from LKP to DUT.
@result: 5G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_5G, DIRECTION_RX)
def test_10G_eee_on_DUT_rx(self):
"""
@description: This subtest performs 10G EEE stability check on DUT host.
@steps:
1. Enable 10G EEE on DUT.
2. Disable 10G EEE on LKP.
3. Run ping flood from LKP to DUT.
@result: 10G EEE link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_with_eee_and_run_ping_flood(LINK_SPEED_10G, DIRECTION_RX)
def test_100M_on_DUT_tx(self):
"""
@description: This subtest performs 100M link stability check on DUT host.
@steps:
1. Setup 100M link on DUT.
2. Setup 100M link on LKP.
3. Run ping flood from DUT to LKP.
@result: 100M link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_100M, DIRECTION_TX)
def test_1G_on_DUT_tx(self):
"""
@description: This subtest performs 1G link stability check on DUT host.
@steps:
1. Setup 1G link on DUT.
2. Setup 1G link on LKP.
3. Run ping flood from DUT to LKP.
@result: 1G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_1G, DIRECTION_TX)
def test_2_5G_on_DUT_tx(self):
"""
@description: This subtest performs 2.5G link stability check on DUT host.
@steps:
1. Setup 2.5G link on DUT.
2. Setup 2.5G link on LKP.
3. Run ping flood from DUT to LKP.
@result: 2.5G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_2_5G, DIRECTION_TX)
def test_5G_on_DUT_tx(self):
"""
@description: This subtest performs 5G link stability check on DUT host.
@steps:
1. Setup 5G link on DUT.
2. Setup 5G link on LKP.
3. Run ping flood from DUT to LKP.
@result: 5G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_5G, DIRECTION_TX)
def test_10G_on_DUT_tx(self):
"""
@description: This subtest performs 10G link stability check on DUT host.
@steps:
1. Setup 10G link on DUT.
2. Setup 10G link on LKP.
3. Run ping flood from DUT to LKP.
@result: 10G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_10G, DIRECTION_TX)
def test_100M_on_DUT_rx(self):
"""
@description: This subtest performs 100M link stability check on DUT host.
@steps:
1. Setup 100M link on DUT.
2. Setup 100M link on LKP.
3. Run ping flood from LKP to DUT.
@result: 100M link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_100M, DIRECTION_RX)
def test_1G_on_DUT_rx(self):
"""
@description: This subtest performs 1G link stability check on DUT host.
@steps:
1. Setup 1G link on DUT.
2. Setup 1G link on LKP.
3. Run ping flood from LKP to DUT.
@result: 1G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_1G, DIRECTION_RX)
def test_2_5G_on_DUT_rx(self):
"""
@description: This subtest performs 2.5G link stability check on DUT host.
@steps:
1. Setup 2.5G link on DUT.
2. Setup 2.5G link on LKP.
3. Run ping flood from LKP to DUT.
@result: 2.5G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_2_5G, DIRECTION_RX)
def test_5G_on_DUT_rx(self):
"""
@description: This subtest performs 5G link stability check on DUT host.
@steps:
1. Setup 5G link on DUT.
2. Setup 5G link on LKP.
3. Run ping flood from LKP to DUT.
@result: 5G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_5G, DIRECTION_RX)
def test_10G_on_DUT_rx(self):
"""
@description: This subtest performs 10G link stability check on DUT host.
@steps:
1. Setup 10G link on DUT.
2. Setup 10G link on LKP.
3. Run ping flood from LKP to DUT.
@result: 10G link on DUT doesn't dropped.
@duration: 50 minutes.
"""
self.cfg_hosts_and_run_ping_flood(LINK_SPEED_10G, DIRECTION_RX)
if __name__ == "__main__":
pytest.main([__file__, "-s", "-v"])