X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_vtr.py;h=c3704f1e7b6def2a4199588e61559a5e34884243;hb=7c0eb56f4;hp=63e1cc7ae05a2c5d4aedc444919e1705456fa8a3;hpb=95c0ca42f2d02e7562775f7c1e6535a586a26186;p=vpp.git diff --git a/test/test_vtr.py b/test/test_vtr.py index 63e1cc7ae05..c3704f1e7b6 100644 --- a/test/test_vtr.py +++ b/test/test_vtr.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest import random @@ -67,6 +67,10 @@ class TestVtr(VppTestCase): super(TestVtr, cls).tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestVtr, cls).tearDownClass() + def setUp(self): """ Clear trace and packet infos before running each test. @@ -79,10 +83,11 @@ class TestVtr(VppTestCase): Show various debug prints after each test. """ super(TestVtr, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2fib verbose")) - self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % - self.bd_id)) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" % + self.bd_id)) @classmethod def create_hosts_and_learn(cls, count): @@ -326,6 +331,56 @@ class TestVtr(VppTestCase): self.vtr_test(self.pg2, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=300)]) + def test_if_vtr_disable(self): + """ Disable VTR on non-sub-interfaces + """ + # First set the VTR fields to junk + self.vapi.l2_interface_vlan_tag_rewrite( + sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_2, + push_dot1q=1, tag1=19, tag2=630) + + if_state = self.vapi.sw_interface_dump( + sw_if_index=self.pg0.sw_if_index) + self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index) + self.assertNotEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED) + + # Then ensure that a request to disable VTR is honored. + self.vapi.l2_interface_vlan_tag_rewrite( + sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_DISABLED) + + if_state = self.vapi.sw_interface_dump( + sw_if_index=self.pg0.sw_if_index) + self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index) + self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_DISABLED) + + def test_if_vtr_push_1q(self): + """ 1Q VTR push 1 on non-sub-interfaces + """ + self.vapi.l2_interface_vlan_tag_rewrite( + sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_1, + push_dot1q=1, tag1=150) + + if_state = self.vapi.sw_interface_dump( + sw_if_index=self.pg0.sw_if_index) + self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index) + self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_1) + self.assertEqual(if_state[0].vtr_tag1, 150) + self.assertNotEqual(if_state[0].vtr_push_dot1q, 0) + + def test_if_vtr_push_2ad(self): + """ 1AD VTR push 2 on non-sub-interfaces + """ + self.vapi.l2_interface_vlan_tag_rewrite( + sw_if_index=self.pg0.sw_if_index, vtr_op=L2_VTR_OP.L2_PUSH_2, + push_dot1q=0, tag1=450, tag2=350) + + if_state = self.vapi.sw_interface_dump( + sw_if_index=self.pg0.sw_if_index) + self.assertEqual(if_state[0].sw_if_index, self.pg0.sw_if_index) + self.assertEqual(if_state[0].vtr_op, L2_VTR_OP.L2_PUSH_2) + self.assertEqual(if_state[0].vtr_tag1, 450) # outer + self.assertEqual(if_state[0].vtr_tag2, 350) # inner + self.assertEqual(if_state[0].vtr_push_dot1q, 0) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)