Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 28 additions & 16 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)
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 @@ -242,21 +253,22 @@ def runTest(self):
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.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")

test_port_thr.join()

uptime_after = self.req_dut('uptime')
if uptime_after.startswith('error'):
Expand Down
6 changes: 3 additions & 3 deletions tests/arp/test_wr_arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setupFerret(self, duthost, ptfhost):
ptfhost.copy(src="arp/files/ferret.py", dest="/opt")

result = duthost.shell(
cmd='''ip route show proto zebra type unicast |
cmd='''ip route show proto 186 type unicast |
sed -e '/default/d' -ne '/0\//p' |
head -n 1 |
sed -ne 's/0\/.*$/1/p'
Expand Down Expand Up @@ -144,7 +144,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 +157,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