diff options
Diffstat (limited to 'smoketest/scripts/cli/base_interfaces_test.py')
| -rw-r--r-- | smoketest/scripts/cli/base_interfaces_test.py | 203 | 
1 files changed, 194 insertions, 9 deletions
| diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py index 29087ff18..7f69b8444 100644 --- a/smoketest/scripts/cli/base_interfaces_test.py +++ b/smoketest/scripts/cli/base_interfaces_test.py @@ -25,6 +25,7 @@ from netifaces import interfaces  from base_vyostest_shim import VyOSUnitTestSHIM  from vyos.configsession import ConfigSession +from vyos.configsession import ConfigSessionError  from vyos.ifconfig import Interface  from vyos.ifconfig import Section  from vyos.util import read_file @@ -230,8 +231,8 @@ class BasicInterfaceTest:              # verify changed MTU              for intf in self._interfaces: -                tmp = read_file(f'/sys/class/net/{intf}/mtu') -                self.assertEqual(tmp, self._mtu) +                tmp = get_interface_config(intf) +                self.assertEqual(tmp['mtu'], int(self._mtu))          def test_mtu_1200_no_ipv6_interface(self):              # Testcase if MTU can be changed to 1200 on non IPv6 @@ -255,8 +256,8 @@ class BasicInterfaceTest:              # verify changed MTU              for intf in self._interfaces: -                tmp = read_file(f'/sys/class/net/{intf}/mtu') -                self.assertEqual(tmp, self._mtu) +                tmp = get_interface_config(intf) +                self.assertEqual(tmp['mtu'], int(self._mtu))              self._mtu = old_mtu @@ -275,22 +276,164 @@ class BasicInterfaceTest:                  for vlan in self._vlan_range:                      base = self._base_path + [interface, 'vif', vlan] -                    self.cli_set(base + ['mtu', self._mtu])                      for address in self._test_addr:                          self.cli_set(base + ['address', address]) +                    self.cli_set(base + ['ingress-qos', '0:1']) +                    self.cli_set(base + ['egress-qos', '1:6'])              self.cli_commit()              for intf in self._interfaces:                  for vlan in self._vlan_range:                      vif = f'{intf}.{vlan}' +                    tmp = get_interface_config(f'{vif}') + +                    tmp2 = dict_search('linkinfo.info_data.ingress_qos', tmp) +                    for item in tmp2 if tmp2 else []: +                        from_key = item['from'] +                        to_key = item['to'] +                        self.assertEqual(from_key, 0) +                        self.assertEqual(to_key, 1) + +                    tmp2 = dict_search('linkinfo.info_data.egress_qos', tmp) +                    for item in tmp2 if tmp2 else []: +                        from_key = item['from'] +                        to_key = item['to'] +                        self.assertEqual(from_key, 1) +                        self.assertEqual(to_key, 6) + +                    for address in self._test_addr: +                        self.assertTrue(is_intf_addr_assigned(vif, address)) + +                    self.assertEqual(Interface(vif).get_admin_state(), 'up') + +        def test_vif_8021q_mtu_limits(self): +            # XXX: This testcase is not allowed to run as first testcase, reason +            # is the Wireless test will first load the wifi kernel hwsim module +            # which creates a wlan0 and wlan1 interface which will fail the +            # tearDown() test in the end that no interface is allowed to survive! +            if not self._test_vlan: +                self.skipTest('not supported') + +            mtu_1500 = '1500' +            mtu_9000 = '9000' + +            for interface in self._interfaces: +                base = self._base_path + [interface] +                self.cli_set(base + ['mtu', mtu_1500]) +                for option in self._options.get(interface, []): +                    self.cli_set(base + option.split()) +                    if 'source-interface' in option: +                        iface = option.split()[-1] +                        iface_type = Section.section(iface) +                        self.cli_set(['interfaces', iface_type, iface, 'mtu', mtu_9000]) + +                for vlan in self._vlan_range: +                    base = self._base_path + [interface, 'vif', vlan] +                    self.cli_set(base + ['mtu', mtu_9000]) + +            # check validate() - VIF MTU must not be larger the parent interface +            # MTU size. +            with self.assertRaises(ConfigSessionError): +                self.cli_commit() + +            # Change MTU on base interface to be the same as on the VIF interface +            for interface in self._interfaces: +                base = self._base_path + [interface] +                self.cli_set(base + ['mtu', mtu_9000]) + +            self.cli_commit() + +            # Verify MTU on base and VIF interfaces +            for interface in self._interfaces: +                tmp = get_interface_config(interface) +                self.assertEqual(tmp['mtu'], int(mtu_9000)) + +                for vlan in self._vlan_range: +                    tmp = get_interface_config(f'{interface}.{vlan}') +                    self.assertEqual(tmp['mtu'], int(mtu_9000)) + + +        def test_vif_8021q_qos_change(self): +            # XXX: This testcase is not allowed to run as first testcase, reason +            # is the Wireless test will first load the wifi kernel hwsim module +            # which creates a wlan0 and wlan1 interface which will fail the +            # tearDown() test in the end that no interface is allowed to survive! +            if not self._test_vlan: +                self.skipTest('not supported') + +            for interface in self._interfaces: +                base = self._base_path + [interface] +                for option in self._options.get(interface, []): +                    self.cli_set(base + option.split()) + +                for vlan in self._vlan_range: +                    base = self._base_path + [interface, 'vif', vlan] +                    for address in self._test_addr: +                        self.cli_set(base + ['address', address]) +                    self.cli_set(base + ['ingress-qos', '0:1']) +                    self.cli_set(base + ['egress-qos', '1:6']) + +            self.cli_commit() + +            for intf in self._interfaces: +                for vlan in self._vlan_range: +                    vif = f'{intf}.{vlan}' +                    tmp = get_interface_config(f'{vif}') + +                    tmp2 = dict_search('linkinfo.info_data.ingress_qos', tmp) +                    for item in tmp2 if tmp2 else []: +                        from_key = item['from'] +                        to_key = item['to'] +                        self.assertEqual(from_key, 0) +                        self.assertEqual(to_key, 1) + +                    tmp2 = dict_search('linkinfo.info_data.egress_qos', tmp) +                    for item in tmp2 if tmp2 else []: +                        from_key = item['from'] +                        to_key = item['to'] +                        self.assertEqual(from_key, 1) +                        self.assertEqual(to_key, 6) +                      for address in self._test_addr:                          self.assertTrue(is_intf_addr_assigned(vif, address)) -                    tmp = read_file(f'/sys/class/net/{vif}/mtu') -                    self.assertEqual(tmp, self._mtu)                      self.assertEqual(Interface(vif).get_admin_state(), 'up') +            new_ingress_qos_from = 1 +            new_ingress_qos_to = 6 +            new_egress_qos_from = 2 +            new_egress_qos_to = 7 +            for interface in self._interfaces: +                base = self._base_path + [interface] +                for vlan in self._vlan_range: +                    base = self._base_path + [interface, 'vif', vlan] +                    self.cli_delete(base + ['ingress-qos', '0:1']) +                    self.cli_delete(base + ['egress-qos', '1:6']) +                    self.cli_set(base + ['ingress-qos', f'{new_ingress_qos_from}:{new_ingress_qos_to}']) +                    self.cli_set(base + ['egress-qos', f'{new_egress_qos_from}:{new_egress_qos_to}']) + +            self.cli_commit() + +            for intf in self._interfaces: +                for vlan in self._vlan_range: +                    vif = f'{intf}.{vlan}' +                    tmp = get_interface_config(f'{vif}') + +                    tmp2 = dict_search('linkinfo.info_data.ingress_qos', tmp) +                    if tmp2: +                        from_key = tmp2[0]['from'] +                        to_key = tmp2[0]['to'] +                        self.assertEqual(from_key, new_ingress_qos_from) +                        self.assertEqual(to_key, new_ingress_qos_to) + +                    tmp2 = dict_search('linkinfo.info_data.egress_qos', tmp) +                    if tmp2: +                        from_key = tmp2[0]['from'] +                        to_key = tmp2[0]['to'] +                        self.assertEqual(from_key, new_egress_qos_from) +                        self.assertEqual(to_key, new_egress_qos_to) +          def test_vif_8021q_lower_up_down(self):              # Testcase for https://phabricator.vyos.net/T3349              if not self._test_vlan: @@ -364,8 +507,50 @@ class BasicInterfaceTest:  #                       for address in self._test_addr:  #                           self.assertTrue(is_intf_addr_assigned(vif, address)) -                        tmp = read_file(f'/sys/class/net/{vif}/mtu') -                        self.assertEqual(tmp, self._mtu) +                        tmp = get_interface_config(vif) +                        self.assertEqual(tmp['mtu'], int(self._mtu)) + +        def test_vif_s_protocol_change(self): +            # XXX: This testcase is not allowed to run as first testcase, reason +            # is the Wireless test will first load the wifi kernel hwsim module +            # which creates a wlan0 and wlan1 interface which will fail the +            # tearDown() test in the end that no interface is allowed to survive! +            if not self._test_qinq: +                self.skipTest('not supported') + +            for interface in self._interfaces: +                base = self._base_path + [interface] +                for option in self._options.get(interface, []): +                    self.cli_set(base + option.split()) + +                for vif_s in self._qinq_range: +                    for vif_c in self._vlan_range: +                        base = self._base_path + [interface, 'vif-s', vif_s, 'vif-c', vif_c] +                        for address in self._test_addr: +                            self.cli_set(base + ['address', address]) + +            self.cli_commit() + +            for interface in self._interfaces: +                for vif_s in self._qinq_range: +                    tmp = get_interface_config(f'{interface}.{vif_s}') +                    # check for the default value +                    self.assertEqual(tmp['linkinfo']['info_data']['protocol'], '802.1ad') + +            # T3532: now change ethertype +            new_protocol = '802.1q' +            for interface in self._interfaces: +                for vif_s in self._qinq_range: +                    base = self._base_path + [interface, 'vif-s', vif_s] +                    self.cli_set(base + ['protocol', new_protocol]) + +            self.cli_commit() + +            # Verify new ethertype configuration +            for interface in self._interfaces: +                for vif_s in self._qinq_range: +                    tmp = get_interface_config(f'{interface}.{vif_s}') +                    self.assertEqual(tmp['linkinfo']['info_data']['protocol'], new_protocol.upper())          def test_interface_ip_options(self):              if not self._test_ip: | 
