diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-07-17 19:42:41 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-07-17 19:42:41 +0200 |
commit | a06b0051ff3643fdf532db71cceb3a5c9cc40dea (patch) | |
tree | d520f4f59a1bb61ad315056fcac60146f8704205 | |
parent | 01d7ff6ad2919775e6813eeafdcf2f5bb860a1b0 (diff) | |
download | vyos-1x-a06b0051ff3643fdf532db71cceb3a5c9cc40dea.tar.gz vyos-1x-a06b0051ff3643fdf532db71cceb3a5c9cc40dea.zip |
ethernet: support testing via SSH
Instead of running the smoketest on all available interfaces it is now possible
to specify a whitespace separated list as environment variable where the test
is performed. This is especially usefull when developing/testing via SSH and
to limit the test to an interface you are not connected to.
Test only with interface eth1:
$ TEST_ETH='eth1' /usr/libexec/vyos/tests/smoke/cli/test_interfaces_ethernet.py
-rw-r--r-- | scripts/cli/base_interfaces_test.py | 5 | ||||
-rwxr-xr-x | scripts/cli/test_interfaces_ethernet.py | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/scripts/cli/base_interfaces_test.py b/scripts/cli/base_interfaces_test.py index 53fe553bc..00a6f16e4 100644 --- a/scripts/cli/base_interfaces_test.py +++ b/scripts/cli/base_interfaces_test.py @@ -38,8 +38,11 @@ class BasicInterfaceTest: def tearDown(self): # we should not remove ethernet from the overall CLI if 'ethernet' in self._base_path: - self.session.delete(self._base_path) for intf in self._interfaces: + # when using a dedicated interface to test via TEST_ETH environment + # variable only this one will be cleared in the end - usable to test + # ethernet interfaces via SSH + self.session.delete(self._base_path + [intf]) self.session.set(self._base_path + [intf]) else: self.session.delete(self._base_path) diff --git a/scripts/cli/test_interfaces_ethernet.py b/scripts/cli/test_interfaces_ethernet.py index 373c81680..919caab8c 100755 --- a/scripts/cli/test_interfaces_ethernet.py +++ b/scripts/cli/test_interfaces_ethernet.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import os import unittest from base_interfaces_test import BasicInterfaceTest @@ -29,10 +30,13 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest): # we need to filter out VLAN interfaces identified by a dot (.) # in their name - just in case! - for tmp in Section.interfaces("ethernet"): - if not '.' in tmp: - self._interfaces.append(tmp) - + if 'TEST_ETH' in os.environ: + tmp = os.environ['TEST_ETH'].split() + self._interfaces = tmp + else: + for tmp in Section.interfaces("ethernet"): + if not '.' in tmp: + self._interfaces.append(tmp) if __name__ == '__main__': unittest.main() |