Skip to content

Commit 6d0076e

Browse files
committed
[tests]: Add tests to verify Path Tracing Midpoint show CLI
Signed-off-by: Carmine Scarpitta <[email protected]>
1 parent 4fde76f commit 6d0076e

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

tests/intfutil_test.py

+45
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@
127127
Ethernet124 rs auto
128128
"""
129129

130+
show_interfaces_path_tracing_output = """\
131+
Interface Alias Oper Admin PT Interface ID PT Timestamp Template
132+
----------- --------- ------ ------- ----------------- -----------------------
133+
Ethernet0 Ethernet0 down up 129 template3
134+
Ethernet16 etp5 up up 130 template1
135+
Ethernet24 etp6 up up 131 template2
136+
Ethernet28 etp8 up up 132 template3
137+
Ethernet32 etp9 up up 133 template4
138+
Ethernet36 etp10 up up N/A N/A
139+
Ethernet112 etp29 up up N/A N/A
140+
Ethernet116 etp30 up up N/A N/A
141+
Ethernet120 etp31 up up N/A N/A
142+
Ethernet124 etp32 up up N/A N/A
143+
"""
144+
145+
show_interfaces_path_tracing_Ethernet0_output = """\
146+
Interface Alias Oper Admin PT Interface ID PT Timestamp Template
147+
----------- --------- ------ ------- ----------------- -----------------------
148+
Ethernet0 Ethernet0 down up 129 template3
149+
"""
150+
130151
class TestIntfutil(TestCase):
131152
@classmethod
132153
def setup_class(cls):
@@ -360,6 +381,30 @@ def test_show_interfaces_fec_status(self):
360381
assert result.exit_code == 0
361382
assert result.output == show_interface_fec_status_output
362383

384+
def test_show_interfaces_path_tracing_status(self):
385+
result = self.runner.invoke(show.cli.commands["interfaces"].commands["path-tracing"], [])
386+
print(result.exit_code)
387+
print(result.output)
388+
assert result.exit_code == 0
389+
assert result.output == show_interfaces_path_tracing_output
390+
391+
# Test 'intfutil -c path-tracing'
392+
output = subprocess.check_output(['intfutil', '-c', 'path-tracing'], stderr=subprocess.STDOUT, text=True)
393+
print(output)
394+
assert result.output == show_interfaces_path_tracing_output
395+
396+
def test_show_interfaces_path_tracing_Ethernet0_status(self):
397+
result = self.runner.invoke(show.cli.commands["interfaces"].commands["path-tracing"], ["Ethernet0"])
398+
print(result.exit_code)
399+
print(result.output)
400+
assert result.exit_code == 0
401+
assert result.output == show_interfaces_path_tracing_Ethernet0_output
402+
403+
# Test 'intfutil -c path-tracing'
404+
output = subprocess.check_output(['intfutil', '-c', 'path-tracing', '-i', 'Ethernet0'], stderr=subprocess.STDOUT, text=True)
405+
print(output)
406+
assert result.output == show_interfaces_path_tracing_Ethernet0_output
407+
363408
@classmethod
364409
def teardown_class(cls):
365410
print("TEARDOWN")

tests/mock_tables/appl_db.json

+15-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"interface_type": "CR4",
4545
"adv_interface_types": "CR4,CR2",
4646
"autoneg": "on",
47-
"link_training": "on"
47+
"link_training": "on",
48+
"pt_interface_id": "129",
49+
"pt_timestamp_template": "template3"
4850
},
4951
"PORT_TABLE:Ethernet16": {
5052
"index": "4",
@@ -55,7 +57,9 @@
5557
"oper_status": "up",
5658
"pfc_asym": "off",
5759
"mtu": "9100",
58-
"admin_status": "up"
60+
"admin_status": "up",
61+
"pt_interface_id": "130",
62+
"pt_timestamp_template": "template1"
5963
},
6064
"PORT_TABLE:Ethernet36": {
6165
"index": "9",
@@ -80,7 +84,9 @@
8084
"mtu": "9100",
8185
"tpid": "0x8100",
8286
"admin_status": "up",
83-
"role": "Dpc"
87+
"role": "Dpc",
88+
"pt_interface_id": "131",
89+
"pt_timestamp_template": "template2"
8490
},
8591
"PORT_TABLE:Ethernet28": {
8692
"index": "7",
@@ -91,7 +97,9 @@
9197
"oper_status": "up",
9298
"pfc_asym": "off",
9399
"mtu": "9100",
94-
"admin_status": "up"
100+
"admin_status": "up",
101+
"pt_interface_id": "132",
102+
"pt_timestamp_template": "template3"
95103
},
96104
"PORT_TABLE:Ethernet32": {
97105
"index": "8",
@@ -108,7 +116,9 @@
108116
"autoneg": "off",
109117
"adv_speeds": "all",
110118
"adv_interface_types": "all",
111-
"link_training": "on"
119+
"link_training": "on",
120+
"pt_interface_id": "133",
121+
"pt_timestamp_template": "template4"
112122
},
113123
"PORT_TABLE:Ethernet112": {
114124
"index": "28",

0 commit comments

Comments
 (0)