MCPcopy Create free account
hub / github.com/FDio/vpp / test_tracepath_multi_thread

Method test_tracepath_multi_thread

test/test_tracepath.py:108–157  ·  view source on GitHub ↗

Test that show trace paths aggregates paths across worker threads

(self)

Source from the content-addressed store, hash-verified

106 super().tearDownClass()
107
108 def test_tracepath_multi_thread(self):
109 """Test that show trace paths aggregates paths across worker threads"""
110 n_pkts = 5
111
112 fwd_pkt = (
113 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
114 / IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4)
115 / UDP(sport=1234, dport=5678)
116 )
117 drop_pkt = (
118 Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
119 / IP(src=self.pg0.remote_ip4, dst="192.0.2.1")
120 / UDP(sport=1234, dport=5678)
121 )
122
123 drop_route = VppIpRoute(
124 self,
125 "192.0.2.0",
126 24,
127 [VppRoutePath("0.0.0.0", 0xFFFFFFFF, type=FibPathType.FIB_PATH_TYPE_DROP)],
128 )
129 drop_route.add_vpp_config()
130
131 # Send traffic & do not clear traces after first send_and_expect call
132 # fwd path traffic (workers 0, 1)
133 self.send_and_expect(self.pg0, [fwd_pkt] * n_pkts, self.pg1, worker=0)
134 self.send_and_expect(
135 self.pg0, [fwd_pkt] * n_pkts, self.pg1, worker=1, trace=False
136 )
137
138 # drop path traffic (worker 0)
139 self.pg_send(self.pg0, [drop_pkt] * n_pkts, trace=False)
140 out = self.vapi.cli("show trace paths")
141
142 # Two unique paths: forwarding and drop
143 self.assertEqual(out.count("Count:"), 2)
144
145 # Fwd path seen on workers 0,1
146 self.assertIn(f"Count: {n_pkts * 2}", out)
147 fwd_line = next(l for l in out.splitlines() if f"Count: {n_pkts * 2}" in l)
148 # check comma is present, which is used
149 self.assertIn("Threads: [1, 2]", fwd_line)
150
151 # Drop path seen on worker 0 only
152 self.assertIn(f"Count: {n_pkts}", out)
153 drop_line = next(l for l in out.splitlines() if f"Count: {n_pkts}" in l)
154 # No comma, used to delimit between worker threads
155 self.assertIn("Threads: [1]", drop_line)
156
157 drop_route.remove_vpp_config()
158
159
160if __name__ == "__main__":

Callers

nothing calls this directly

Calls 8

add_vpp_configMethod · 0.95
remove_vpp_configMethod · 0.95
VppIpRouteClass · 0.90
VppRoutePathClass · 0.90
send_and_expectMethod · 0.80
pg_sendMethod · 0.80
cliMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected