Skip to content

Commit 2d58d93

Browse files
committed
[tests]: Add tests to verify PT Midpoint show CLI
Signed-off-by: Carmine Scarpitta <[email protected]>
1 parent 9aea73d commit 2d58d93

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
@@ -112,6 +112,27 @@
112112
Ethernet124 N/A N/A up up
113113
"""
114114

115+
show_interfaces_path_tracing_output = """\
116+
Interface Alias Oper Admin PT Interface ID PT Timestamp Template
117+
----------- --------- ------ ------- ----------------- -----------------------
118+
Ethernet0 Ethernet0 down up 129 template3
119+
Ethernet16 etp5 up up 130 template1
120+
Ethernet24 etp6 up up 131 template2
121+
Ethernet28 etp8 up up 132 template3
122+
Ethernet32 etp9 up up 133 template4
123+
Ethernet36 etp10 up up N/A N/A
124+
Ethernet112 etp29 up up N/A N/A
125+
Ethernet116 etp30 up up N/A N/A
126+
Ethernet120 etp31 up up N/A N/A
127+
Ethernet124 etp32 up up N/A N/A
128+
"""
129+
130+
show_interfaces_path_tracing_Ethernet0_output = """\
131+
Interface Alias Oper Admin PT Interface ID PT Timestamp Template
132+
----------- --------- ------ ------- ----------------- -----------------------
133+
Ethernet0 Ethernet0 down up 129 template3
134+
"""
135+
115136
class TestIntfutil(TestCase):
116137
@classmethod
117138
def setup_class(cls):
@@ -338,6 +359,30 @@ def test_show_interfaces_link_training_status(self):
338359
assert result.exit_code == 0
339360
assert result.output == show_interface_link_training_status_output
340361

362+
def test_show_interfaces_path_tracing_status(self):
363+
result = self.runner.invoke(show.cli.commands["interfaces"].commands["path-tracing"], [])
364+
print(result.exit_code)
365+
print(result.output)
366+
assert result.exit_code == 0
367+
assert result.output == show_interfaces_path_tracing_output
368+
369+
# Test 'intfutil -c path-tracing'
370+
output = subprocess.check_output(['intfutil', '-c', 'path-tracing'], stderr=subprocess.STDOUT, text=True)
371+
print(output)
372+
assert result.output == show_interfaces_path_tracing_output
373+
374+
def test_show_interfaces_path_tracing_Ethernet0_status(self):
375+
result = self.runner.invoke(show.cli.commands["interfaces"].commands["path-tracing"], ["Ethernet0"])
376+
print(result.exit_code)
377+
print(result.output)
378+
assert result.exit_code == 0
379+
assert result.output == show_interfaces_path_tracing_Ethernet0_output
380+
381+
# Test 'intfutil -c path-tracing'
382+
output = subprocess.check_output(['intfutil', '-c', 'path-tracing', '-i', 'Ethernet0'], stderr=subprocess.STDOUT, text=True)
383+
print(output)
384+
assert result.output == show_interfaces_path_tracing_Ethernet0_output
385+
341386
@classmethod
342387
def teardown_class(cls):
343388
print("TEARDOWN")

tests/mock_tables/appl_db.json

+15-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
"interface_type": "CR4",
4141
"adv_interface_types": "CR4,CR2",
4242
"autoneg": "on",
43-
"link_training": "on"
43+
"link_training": "on",
44+
"pt_interface_id": "129",
45+
"pt_timestamp_template": "template3"
4446
},
4547
"PORT_TABLE:Ethernet16": {
4648
"index": "4",
@@ -51,7 +53,9 @@
5153
"oper_status": "up",
5254
"pfc_asym": "off",
5355
"mtu": "9100",
54-
"admin_status": "up"
56+
"admin_status": "up",
57+
"pt_interface_id": "130",
58+
"pt_timestamp_template": "template1"
5559
},
5660
"PORT_TABLE:Ethernet36": {
5761
"index": "9",
@@ -75,7 +79,9 @@
7579
"pfc_asym": "off",
7680
"mtu": "9100",
7781
"tpid": "0x8100",
78-
"admin_status": "up"
82+
"admin_status": "up",
83+
"pt_interface_id": "131",
84+
"pt_timestamp_template": "template2"
7985
},
8086
"PORT_TABLE:Ethernet28": {
8187
"index": "7",
@@ -86,7 +92,9 @@
8692
"oper_status": "up",
8793
"pfc_asym": "off",
8894
"mtu": "9100",
89-
"admin_status": "up"
95+
"admin_status": "up",
96+
"pt_interface_id": "132",
97+
"pt_timestamp_template": "template3"
9098
},
9199
"PORT_TABLE:Ethernet32": {
92100
"index": "8",
@@ -103,7 +111,9 @@
103111
"autoneg": "off",
104112
"adv_speeds": "all",
105113
"adv_interface_types": "all",
106-
"link_training": "on"
114+
"link_training": "on",
115+
"pt_interface_id": "133",
116+
"pt_timestamp_template": "template4"
107117
},
108118
"PORT_TABLE:Ethernet112": {
109119
"index": "28",

0 commit comments

Comments
 (0)