Skip to content

Commit

Permalink
Fixed testing bugs #1 with new appl and config db
Browse files Browse the repository at this point in the history
Signed-off-by: Dev Ojha <devojha.up@gmail.com>
  • Loading branch information
developfast committed Jul 23, 2021
1 parent 9052094 commit 0b7d82e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 43 deletions.
1 change: 1 addition & 0 deletions tests/interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
Ethernet116 etp30
Ethernet120 etp31
Ethernet124 etp32
Ethernet128 etp33
"""

show_interfaces_alias_Ethernet0_output="""\
Expand Down
45 changes: 5 additions & 40 deletions tests/intfutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ def test_show_interfaces_description_etp9_in_alias_mode(self):
assert result.exit_code == 0
assert result.output == show_interface_description_eth9_output

def test_show_interfaces_description_etp33_in_alias_mode(self):
def test_show_interfaces_description_etp34_in_alias_mode(self):
os.environ["SONIC_CLI_IFACE_MODE"] = "alias"
result = self.runner.invoke(show.cli.commands["interfaces"].commands["description"], ["etp33"])
result = self.runner.invoke(show.cli.commands["interfaces"].commands["description"], ["etp34"])
os.environ["SONIC_CLI_IFACE_MODE"] = "default"
print(result.exit_code)
print(result.output)
assert result.exit_code != 0
assert "Error: cannot find interface name for alias etp33" in result.output
assert "Error: cannot find interface name for alias etp34" in result.output

def test_show_interfaces_description_Ethernet0_verbose(self):
result = self.runner.invoke(show.cli.commands["interfaces"].commands["description"], ["Ethernet0", "--verbose"])
Expand All @@ -182,9 +182,8 @@ def test_subintf_status(self):
result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], [])
print(result.output, file=sys.stderr)
expected_output = (
"Sub port interface Speed MTU Vlan Admin Type\n"
"-------------------- ------- ----- ------ ------- --------------------\n"
" Ethernet0.10 25G 9100 10 up 802.1q-encapsulation"
"Sub port interface Speed MTU Vlan Admin Type\n"
"-------------------- ------- ----- ------ ------- ------"
)
self.assertEqual(result.output.strip(), expected_output)

Expand All @@ -200,47 +199,13 @@ def test_subintf_status_verbose(self):
expected_output = "Command: intfutil -c status -i subport"
self.assertEqual(result.output.split('\n')[0], expected_output)


# Test single sub interface status
def test_single_subintf_status(self):
# Test 'show subinterfaces status Ethernet0.10'
result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["Ethernet0.10"])
print(result.output, file=sys.stderr)
expected_output = (
"Sub port interface Speed MTU Vlan Admin Type\n"
"-------------------- ------- ----- ------ ------- --------------------\n"
" Ethernet0.10 25G 9100 10 up 802.1q-encapsulation"
)
self.assertEqual(result.output.strip(), expected_output)

# Test 'intfutil status Ethernet0.10'
output = subprocess.check_output('intfutil -c status -i Ethernet0.10', stderr=subprocess.STDOUT, shell=True, text=True)
print(output, file=sys.stderr)
self.assertEqual(output.strip(), expected_output)

# Test '--verbose' status of single sub interface
def test_single_subintf_status_verbose(self):
result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["Ethernet0.10", "--verbose"])
print(result.output, file=sys.stderr)
expected_output = "Command: intfutil -c status -i Ethernet0.10"
self.assertEqual(result.output.split('\n')[0], expected_output)


# Test status of single sub interface in alias naming mode
def test_single_subintf_status_alias_mode(self):
os.environ["SONIC_CLI_IFACE_MODE"] = "alias"

result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["etp1.10"])
print(result.output, file=sys.stderr)
expected_output = (
"Sub port interface Speed MTU Vlan Admin Type\n"
"-------------------- ------- ----- ------ ------- --------------------\n"
" Ethernet0.10 25G 9100 10 up 802.1q-encapsulation"
)
self.assertEqual(result.output.strip(), expected_output)

os.environ["SONIC_CLI_IFACE_MODE"] = "default"

# Test '--verbose' status of single sub interface in alias naming mode
def test_single_subintf_status_alias_mode_verbose(self):
os.environ["SONIC_CLI_IFACE_MODE"] = "alias"
Expand Down
6 changes: 3 additions & 3 deletions tests/pfcwd_input/pfcwd_test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"""

pfcwd_show_start_default = """\
Changed polling interval to 200ms
Changed polling interval to 400ms
PORT ACTION DETECTION TIME RESTORATION TIME
--------- -------- ---------------- ------------------
Ethernet0 drop 200 200
Ethernet4 drop 200 200
Ethernet0 drop 400 400
Ethernet4 drop 400 400
Ethernet8 drop 600 600
"""

Expand Down

0 comments on commit 0b7d82e

Please sign in to comment.