diff options
author | Neale Ranns <neale@graphiant.com> | 2022-02-17 09:22:16 +0000 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2022-02-18 09:20:40 +0000 |
commit | 699bea24944907fed5f7516e339aa2eca7c2dd17 (patch) | |
tree | 2088543dfa2900a09313501df65aefcd971420db | |
parent | aacd3ed6d5c9c32b646795583a634ca5925603d2 (diff) |
tests: Consolidate the implementations of send_and_expect_X
Type: test
there were multiple instances of send_and_expect_load_balancing
and a send_and_expect_one_itf which has the same functionality as send_and_expect_one.
Put one implementation of both in framework.py (where the other send_and_X functions reside).
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I7f629d440220bee29368067f475059322e1134f7
-rw-r--r-- | test/framework.py | 12 | ||||
-rw-r--r-- | test/test_ip4.py | 24 | ||||
-rw-r--r-- | test/test_ip6.py | 25 | ||||
-rw-r--r-- | test/test_l3xc.py | 10 |
4 files changed, 18 insertions, 53 deletions
diff --git a/test/framework.py b/test/framework.py index 572207db3f8..7d03eebef9a 100644 --- a/test/framework.py +++ b/test/framework.py @@ -1275,6 +1275,18 @@ class VppTestCase(CPUInterface, unittest.TestCase): self.logger.debug(self.vapi.cli("show trace")) return rx + def send_and_expect_load_balancing(self, input, pkts, outputs, + worker=None, trace=True): + self.pg_send(input, pkts, worker=worker, trace=trace) + rxs = [] + for oo in outputs: + rx = oo._get_capture(1) + self.assertNotEqual(0, len(rx)) + rxs.append(rx) + if trace: + self.logger.debug(self.vapi.cli("show trace")) + return rxs + def send_and_expect_only(self, intf, pkts, output, timeout=None): self.pg_send(intf, pkts) rx = output.get_capture(len(pkts)) diff --git a/test/test_ip4.py b/test/test_ip4.py index 373505293f4..de2cac0619e 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -1118,24 +1118,6 @@ class TestIPLoadBalance(VppTestCase): i.admin_down() super(TestIPLoadBalance, self).tearDown() - def send_and_expect_load_balancing(self, input, pkts, outputs): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rxs = [] - for oo in outputs: - rx = oo._get_capture(1) - self.assertNotEqual(0, len(rx)) - rxs.append(rx) - return rxs - - def send_and_expect_one_itf(self, input, pkts, itf): - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = itf.get_capture(len(pkts)) - def total_len(self, rxs): n = 0 for rx in rxs: @@ -1243,7 +1225,7 @@ class TestIPLoadBalance(VppTestCase): self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts, [self.pg1, self.pg2]) - self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2) + self.send_and_expect_only(self.pg0, port_ip_pkts, self.pg2) # # change the flow hash config back to defaults @@ -1367,7 +1349,7 @@ class TestIPLoadBalance(VppTestCase): # inject the packet on pg0 - rx only on via routes output interface # self.vapi.cli("clear trace") - self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3) + self.send_and_expect_only(self.pg0, port_pkts, self.pg3) # # Add a LB route in the presence of a down link - expect no @@ -1390,7 +1372,7 @@ class TestIPLoadBalance(VppTestCase): UDP(sport=1234, dport=1234 + ii) / Raw(b'\xa5' * 100)) - self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg4) + self.send_and_expect_only(self.pg0, port_pkts, self.pg4) # bring the link back up self.pg3.link_up() diff --git a/test/test_ip6.py b/test/test_ip6.py index d1fb86d91e3..2c318cdaf99 100644 --- a/test/test_ip6.py +++ b/test/test_ip6.py @@ -1965,25 +1965,6 @@ class TestIP6LoadBalance(VppTestCase): i.disable_mpls() super(TestIP6LoadBalance, self).tearDown() - def pg_send(self, input, pkts): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - - def send_and_expect_load_balancing(self, input, pkts, outputs): - self.pg_send(input, pkts) - rxs = [] - for oo in outputs: - rx = oo._get_capture(1) - self.assertNotEqual(0, len(rx)) - rxs.append(rx) - return rxs - - def send_and_expect_one_itf(self, input, pkts, itf): - self.pg_send(input, pkts) - rx = itf.get_capture(len(pkts)) - def test_ip6_load_balance(self): """ IPv6 Load-Balancing """ @@ -2107,7 +2088,7 @@ class TestIP6LoadBalance(VppTestCase): # The packets with Entropy label in should not load-balance, # since the Entropy value is fixed. # - self.send_and_expect_one_itf(self.pg0, port_ent_pkts, self.pg1) + self.send_and_expect_only(self.pg0, port_ent_pkts, self.pg1) # # change the flow hash config so it's only IP src,dst @@ -2121,7 +2102,7 @@ class TestIP6LoadBalance(VppTestCase): [self.pg1, self.pg2]) self.send_and_expect_load_balancing(self.pg0, src_mpls_pkts, [self.pg1, self.pg2]) - self.send_and_expect_one_itf(self.pg0, port_ip_pkts, self.pg2) + self.send_and_expect_only(self.pg0, port_ip_pkts, self.pg2) # # change the flow hash config back to defaults @@ -2206,7 +2187,7 @@ class TestIP6LoadBalance(VppTestCase): # inject the packet on pg0 - expect load-balancing across all 4 paths # self.vapi.cli("clear trace") - self.send_and_expect_one_itf(self.pg0, port_pkts, self.pg3) + self.send_and_expect_only(self.pg0, port_pkts, self.pg3) class IP6PuntSetup(object): diff --git a/test/test_l3xc.py b/test/test_l3xc.py index d7a82976cf5..2bcb6d5ae23 100644 --- a/test/test_l3xc.py +++ b/test/test_l3xc.py @@ -90,16 +90,6 @@ class TestL3xc(VppTestCase): i.admin_down() super(TestL3xc, self).tearDown() - def send_and_expect_load_balancing(self, input, pkts, outputs): - self.pg_send(input, pkts) - rxs = [] - for oo in outputs: - rx = oo._get_capture(1) - self.assertNotEqual(0, len(rx)) - for r in rx: - rxs.append(r) - return rxs - def test_l3xc4(self): """ IPv4 X-Connect """ |