Skip to content

Commit

Permalink
[PTF python3 migration] Modify test_arpall PTF script
Browse files Browse the repository at this point in the history
Summary:
Migrate test_arpall PTF script to Python3

What is the motivation for this PR?
This is part of Python3 migration project.
This PR migrate test_arpall PTF script to Python3.

How did you do it?
2to3 and manually code change

How did you verify/test it?
Run with physical testbed
  • Loading branch information
wsycqyz authored and mssonicbld committed Aug 28, 2023
1 parent 5ee6e3c commit a8e3ed9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/arp/test_arpall.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_arp_unicast_reply(common_setup_teardown, intfs_for_test, enum_frontend_
'port': intf1_indice
}
log_file = "/tmp/arptest.VerifyUnicastARPReply.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.VerifyUnicastARPReply", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.VerifyUnicastARPReply", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

# Get DUT arp table
switch_arptable = asichost.switch_arptable()['ansible_facts']
Expand All @@ -50,7 +51,8 @@ def test_arp_expect_reply(common_setup_teardown, intfs_for_test, enum_frontend_a
# Start PTF runner and send correct arp packets
clear_dut_arp_cache(duthost, asichost.cli_ns_option)
log_file = "/tmp/arptest.ExpectReply.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.ExpectReply", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.ExpectReply", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
pytest_assert(switch_arptable['arptable']['v4']['10.10.1.3']['macaddress'] == '00:06:07:08:09:0a')
Expand All @@ -71,7 +73,7 @@ def test_arp_no_reply_other_intf(common_setup_teardown, intfs_for_test, enum_fro
}
log_file = "/tmp/arptest.SrcOutRangeNoReply.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.SrcOutRangeNoReply", '/root/ptftests',
params=intf2_params, log_file=log_file)
params=intf2_params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
for ip in list(switch_arptable['arptable']['v4'].keys()):
Expand All @@ -91,7 +93,8 @@ def test_arp_no_reply_src_out_range(common_setup_teardown, intfs_for_test, enum_
# Check DUT won't reply ARP and install ARP entry when src address is not in interface subnet range
clear_dut_arp_cache(duthost, asichost.cli_ns_option)
log_file = "/tmp/arptest.SrcOutRangeNoReply.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.SrcOutRangeNoReply", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.SrcOutRangeNoReply", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
for ip in list(switch_arptable['arptable']['v4'].keys()):
Expand All @@ -111,15 +114,17 @@ def test_arp_garp_no_update(common_setup_teardown, intfs_for_test, enum_frontend
# Test Gratuitous ARP behavior, no Gratuitous ARP installed when arp was not resolved before
clear_dut_arp_cache(duthost, asichost.cli_ns_option)
log_file = "/tmp/arptest.GarpNoUpdate.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.GarpNoUpdate", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.GarpNoUpdate", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
for ip in list(switch_arptable['arptable']['v4'].keys()):
pytest_assert(ip != '10.10.1.7')

# Test Gratuitous ARP update case, when received garp, no arp reply, update arp table if it was solved before
log_file = "/tmp/arptest.ExpectReply.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.ExpectReply", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.ExpectReply", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
pytest_assert(switch_arptable['arptable']['v4']['10.10.1.3']['macaddress'] == '00:06:07:08:09:0a')
Expand All @@ -128,7 +133,8 @@ def test_arp_garp_no_update(common_setup_teardown, intfs_for_test, enum_frontend
time.sleep(2)

log_file = "/tmp/arptest.GarpUpdate.{0}.log".format(datetime.now().strftime("%Y-%m-%d-%H:%M:%S"))
ptf_runner(ptfhost, 'ptftests', "arptest.GarpUpdate", '/root/ptftests', params=params, log_file=log_file)
ptf_runner(ptfhost, 'ptftests', "arptest.GarpUpdate", '/root/ptftests',
params=params, log_file=log_file, is_python3=True)

switch_arptable = asichost.switch_arptable()['ansible_facts']
pytest_assert(switch_arptable['arptable']['v4']['10.10.1.3']['macaddress'] == '00:00:07:08:09:0a')
Expand Down

0 comments on commit a8e3ed9

Please sign in to comment.