Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions ansible/roles/test/files/ptftests/wr_arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ArpTest(BaseTest):
def __init__(self):
BaseTest.__init__(self)

log_file_name = '/root/wr_arp_test.log'
log_file_name = '/tmp/wr_arp_test.log'
self.log_fp = open(log_file_name, 'a')
self.log_fp.write("\nNew test:\n")

Expand All @@ -46,6 +46,7 @@ def log(self, message):
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print "%s : %s" % (current_time, message)
self.log_fp.write("%s : %s\n" % (current_time, message))
self.log_fp.flush()

return

Expand Down Expand Up @@ -102,6 +103,16 @@ def dut_thr(self, q_from, q_to):
self.log("Quiting from dut_thr")
return

def test_port_thr(self):
self.log("test_port_thr started")
while time.time() < self.stop_at:
for test in self.tests:
for port in test['acc_ports']:
nr_rcvd = self.testPort(port)
self.records[port][time.time()] = nr_rcvd
self.log("Quiting from test_port_thr")
return

def readMacs(self):
addrs = {}
for intf in os.listdir('/sys/class/net'):
Expand Down Expand Up @@ -241,22 +252,25 @@ def runTest(self):
self.req_dut('quit')
self.assertTrue(False, "DUT returned error for first uptime request")

records = defaultdict(dict)
stop_at = time.time() + self.how_long
rebooted = False
while time.time() < stop_at:
for test in self.tests:
for port in test['acc_ports']:
nr_rcvd = self.testPort(port)
records[port][time.time()] = nr_rcvd
if not rebooted:
result = self.req_dut('WR')
if result.startswith('ok'):
rebooted = True
else:
self.log("Error in WR")
self.req_dut('quit')
self.assertTrue(False, "Error in WR")
self.records = defaultdict(dict)
self.stop_at = time.time() + self.how_long

test_port_thr = threading.Thread(target=self.test_port_thr)
test_port_thr.setDaemon(True)
test_port_thr.start()

self.log("Issuing WR command")
result = self.req_dut('WR')
if result.startswith('ok'):
self.log("WR OK!")
else:
self.log("Error in WR")
self.req_dut('quit')
self.assertTrue(False, "Error in WR")

self.assertTrue(time.time() < self.stop_at, "warm-reboot took to long")

test_port_thr.join()

uptime_after = self.req_dut('uptime')
if uptime_after.startswith('error'):
Expand All @@ -272,7 +286,7 @@ def runTest(self):

# check that every port didn't have pauses more than 25 seconds
pauses = defaultdict(list)
for port, data in records.items():
for port, data in self.records.items():
was_active = True
last_inactive = None
for t in sorted(data.keys()):
Expand Down
36 changes: 32 additions & 4 deletions tests/arp/test_wr_arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,37 @@ def setupFerret(self, duthost, ptfhost):
'''
ptfhost.copy(src="arp/files/ferret.py", dest="/opt")

'''
Get the IP which will be used by ferret script from the "ip route show type unicast"
command output. The output looks as follows:

default proto 186 src 10.1.0.32 metric 20
nexthop via 10.0.0.57 dev PortChannel0001 weight 1
nexthop via 10.0.0.59 dev PortChannel0002 weight 1
nexthop via 10.0.0.61 dev PortChannel0003 weight 1
nexthop via 10.0.0.63 dev PortChannel0004 weight 1
10.0.0.56/31 dev PortChannel0001 proto kernel scope link src 10.0.0.56
10.232.24.0/23 dev eth0 proto kernel scope link src 10.232.24.122
100.1.0.29 via 10.0.0.57 dev PortChannel0001 proto 186 src 10.1.0.32 metric 20
192.168.0.0/21 dev Vlan1000 proto kernel scope link src 192.168.0.1
192.168.8.0/25 proto 186 src 10.1.0.32 metric 20
nexthop via 10.0.0.57 dev PortChannel0001 weight 1
nexthop via 10.0.0.59 dev PortChannel0002 weight 1
nexthop via 10.0.0.61 dev PortChannel0003 weight 1
nexthop via 10.0.0.63 dev PortChannel0004 weight 1
192.168.16.0/25 proto 186 src 10.1.0.32 metric 20
...

We'll use the first subnet IP taken from zebra protocol as the base for the host IP.
As in the new SONiC image the proto will look as '186'(201911) or bgp (master)
instead of 'zebra' (like it looks in 201811)the filtering output command below will pick
the first line containing either 'proto zebra' (or 'proto 186' or 'proto bgp')
(except the one for the deafult route) and take host IP from the subnet IP. For the output
above 192.168.8.0/25 subnet will be taken and host IP given to ferret script will be 192.168.8.1
'''
result = duthost.shell(
cmd='''ip route show proto zebra type unicast |
sed -e '/default/d' -ne '/0\//p' |
cmd='''ip route show type unicast |
sed -e '/proto 186\|proto zebra\|proto bgp/!d' -e '/default/d' -ne '/0\//p' |
head -n 1 |
sed -ne 's/0\/.*$/1/p'
'''
Expand Down Expand Up @@ -144,7 +172,7 @@ def removePtfhostIp(self, ptfhost):
Returns:
None
'''
ptfhost.script(src='scripts/remove_ip.sh')
ptfhost.script('./scripts/remove_ip.sh')

@pytest.fixture(scope='class', autouse=True)
def changePtfhostMacAddresses(self, ptfhost):
Expand All @@ -157,7 +185,7 @@ def changePtfhostMacAddresses(self, ptfhost):
Returns:
None
'''
ptfhost.script(src="scripts/change_mac.sh")
ptfhost.script("./scripts/change_mac.sh")

@pytest.fixture(scope='class', autouse=True)
def prepareSshKeys(self, duthost, ptfhost):
Expand Down