From fd68e09fe1809ea74e05bf019efec72b58897c2d Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 23 2018 15:42:47 +0000 Subject: [PATCH 1/9] CI: Add ip addrlabel to test Sample Run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 17:56:55 ] :: [ LOG ] :: ip address label tests :: [ 17:56:55 ] :: [ LOG ] :: ip address label tests :: [ 17:56:55 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-address-label-tests.py' test_add_address_label (__main__.IPAddressLabelTests) ... prefix ::1/128 label 0 prefix ::/96 label 3 prefix ::ffff:0.0.0.0/96 label 4 prefix 2001:6f8:12d8:2::/64 dev if14 label 200 prefix 2001:6f8:900:8cbc::/64 dev if14 label 300 prefix 2001:4dd0:ff00:834::/64 dev if14 label 200 prefix 2a01:238:423d:8800::/64 dev if14 label 300 prefix 2001:4dd0:ff00:834::/64 dev if14 label 200 prefix 2a01:238:423d:8800::/64 dev if14 label 300 prefix 2a01:238:423d:8800::/64 label 300 prefix 2001:4dd0:ff00:834::/64 label 200 prefix 2001:6f8:900:8cbc::/64 label 300 prefix 2001:6f8:12d8:2::/64 label 200 prefix 2001::/32 label 6 prefix 2001:10::/28 label 7 prefix 3ffe::/16 label 12 prefix 2002::/16 label 2 prefix fec0::/10 label 11 prefix fc00::/7 label 5 prefix ::/0 label 1 ok test_add_address_label_dev (__main__.IPAddressLabelTests) ... prefix ::1/128 label 0 prefix ::/96 label 3 prefix ::ffff:0.0.0.0/96 label 4 prefix 2001:6f8:12d8:2::/64 dev if14 label 200 prefix 2001:6f8:900:8cbc::/64 dev if14 label 300 prefix 2001:4dd0:ff00:834::/64 dev if14 label 200 prefix 2a01:238:423d:8800::/64 dev if14 label 300 prefix 2001:6f8:12d8:2::/64 dev dummy-test label 200 prefix 2001:6f8:900:8cbc::/64 dev dummy-test label 300 prefix 2001:4dd0:ff00:834::/64 dev dummy-test label 200 prefix 2a01:238:423d:8800::/64 dev dummy-test label 300 prefix 2001::/32 label 6 prefix 2001:10::/28 label 7 prefix 3ffe::/16 label 12 prefix 2002::/16 label 2 prefix fec0::/10 label 11 prefix fc00::/7 label 5 prefix ::/0 label 1 ok ---------------------------------------------------------------------- Ran 2 tests in 0.077s OK ``` --- diff --git a/tests/ip-address-label-sanity-test/Makefile b/tests/ip-address-label-sanity-test/Makefile new file mode 100644 index 0000000..612fadb --- /dev/null +++ b/tests/ip-address-label-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test +# Description: Test basic ip address label funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-address-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip address label funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-address-label-sanity-test/PURPOSE b/tests/ip-address-label-sanity-test/PURPOSE new file mode 100644 index 0000000..d6db326 --- /dev/null +++ b/tests/ip-address-label-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-address-label-sanity-test +Description: Test basic ip address label funcionality +Author: Susant Sahani diff --git a/tests/ip-address-label-sanity-test/ip-address-label-tests.py b/tests/ip-address-label-sanity-test/ip-address-label-tests.py new file mode 100755 index 0000000..69557f1 --- /dev/null +++ b/tests/ip-address-label-sanity-test/ip-address-label-tests.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test +# Description: Test basic ip addrlabel funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_dummy(self): + + subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy']) + self.link_exists('dummy-test') + + def del_dummy(self): + + subprocess.check_output(['ip', 'link', 'del', 'dummy-test']) + +class IPAddressLabelTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_dummy() + self.link_exists('dummy-test') + + def tearDown(self): + self.del_dummy() + + def test_add_address_label(self): + + subprocess.call("ip addrlabel add prefix 2001:6f8:12d8:2::/64 label 200", shell=True) + subprocess.call("ip addrlabel add prefix 2001:6f8:900:8cbc::/64 label 300", shell=True) + subprocess.call("ip addrlabel add prefix 2001:4dd0:ff00:834::/64 label 200", shell=True) + subprocess.call("ip addrlabel add prefix 2a01:238:423d:8800::/64 label 300", shell=True) + + output=subprocess.check_output(['ip', 'addrlabel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "prefix 2001:6f8:12d8:2::/64 label 200") + self.assertRegex(output, "prefix 2001:6f8:900:8cbc::/64 label 300") + self.assertRegex(output, "prefix 2001:4dd0:ff00:834::/64 label 200") + self.assertRegex(output, "prefix 2a01:238:423d:8800::/64 label 300") + + subprocess.call("ip addrlabel del prefix 2001:6f8:12d8:2::/64 label 200", shell=True) + subprocess.call("ip addrlabel del prefix 2001:6f8:900:8cbc::/64 label 300", shell=True) + subprocess.call("ip addrlabel del prefix 2001:4dd0:ff00:834::/64 label 200", shell=True) + subprocess.call("ip addrlabel del prefix 2a01:238:423d:8800::/64 label 300", shell=True) + + def test_add_address_label_dev(self): + + subprocess.call("ip addrlabel add prefix 2001:6f8:12d8:2::/64 label 200 dev dummy-test", shell=True) + subprocess.call("ip addrlabel add prefix 2001:6f8:900:8cbc::/64 label 300 dev dummy-test", shell=True) + subprocess.call("ip addrlabel add prefix 2001:4dd0:ff00:834::/64 label 200 dev dummy-test", shell=True) + subprocess.call("ip addrlabel add prefix 2a01:238:423d:8800::/64 label 300 dev dummy-test", shell=True) + + output=subprocess.check_output(['ip', 'addrlabel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "prefix 2001:6f8:12d8:2::/64 dev dummy-test label 200") + self.assertRegex(output, "prefix 2001:6f8:900:8cbc::/64 dev dummy-test label 300") + self.assertRegex(output, "prefix 2001:4dd0:ff00:834::/64 dev dummy-test label 200") + self.assertRegex(output, "prefix 2a01:238:423d:8800::/64 dev dummy-test label 300") + + subprocess.call("ip addrlabel del prefix 2001:6f8:12d8:2::/64 label 200 dev dummy-test", shell=True) + subprocess.call("ip addrlabel del prefix 2001:6f8:900:8cbc::/64 label 300 dev dummy-test", shell=True) + subprocess.call("ip addrlabel del prefix 2001:4dd0:ff00:834::/64 label 200 dev dummy-test", shell=True) + subprocess.call("ip addrlabel del prefix 2a01:238:423d:8800::/64 label 300 dev dummy-test", shell=True) + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-address-label-sanity-test/runtest.sh b/tests/ip-address-label-sanity-test/runtest.sh new file mode 100755 index 0000000..ee04d3c --- /dev/null +++ b/tests/ip-address-label-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test +# Description: Test basic ip address label funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-address-label-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip address label tests" + rlRun "/usr/bin/python3 /usr/bin/ip-address-label-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-address-label-tests.py" + rlLog "ip address label tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index d2cc96e..db17319 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -12,6 +12,7 @@ - bridge-utility - ip-link-sanity-test - ip-address-sanity-test + - ip-address-label-sanity-test required_packages: - iproute - bridge-utils From d4c9cc3ea7b948e53d89430c7bc97a779fc66d1c Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 24 2018 11:18:01 +0000 Subject: [PATCH 2/9] CI: Add FOU to test. Sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 21:17:51 ] :: [ LOG ] :: ip fou tests :: [ 21:17:51 ] :: [ LOG ] :: ip fou tests :: [ 21:17:51 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-fou-tests.py' test_configure_fou_receive_port_gre (__main__.IPFOUTests) Configure a FOU receive port for GRE bound to 7777 ... port 7777 ipproto 47 ok test_configure_fou_receive_port_gue (__main__.IPFOUTests) Configure a GUE receive port bound to 9999 ... port 9999 gue ok test_configure_fou_receive_port_ipip (__main__.IPFOUTests) Configure a FOU receive port for IPIP bound to 8888 ... port 8888 ipproto 4 ok test_configure_fou_with_ipip (__main__.IPFOUTests) IP over UDP tunnel ... port 9000 ipproto 4 ok ---------------------------------------------------------------------- Ran 4 tests in 0.048s OK ``` --- diff --git a/tests/ip-fou-sanity-test/Makefile b/tests/ip-fou-sanity-test/Makefile new file mode 100644 index 0000000..b5985b2 --- /dev/null +++ b/tests/ip-fou-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test +# Description: Test basic ip fou funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-address-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip fou funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-fou-sanity-test/PURPOSE b/tests/ip-fou-sanity-test/PURPOSE new file mode 100644 index 0000000..d62d2ff --- /dev/null +++ b/tests/ip-fou-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-fou-sanity-test +Description: Test basic ip fou funcionality +Author: Susant Sahani diff --git a/tests/ip-fou-sanity-test/ip-fou-tests.py b/tests/ip-fou-sanity-test/ip-fou-tests.py new file mode 100755 index 0000000..b72b45f --- /dev/null +++ b/tests/ip-fou-sanity-test/ip-fou-tests.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test +# Description: Test basic ip fou funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPFOUTests(unittest.TestCase): + + def test_configure_fou_receive_port_gre(self): + ''' Configure a FOU receive port for GRE bound to 7777''' + + subprocess.call(" ip fou add port 7777 ipproto 47", shell=True) + output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "port 7777 ipproto 47") + + subprocess.call("ip fou del port 7777", shell=True) + + def test_configure_fou_receive_port_ipip(self): + ''' Configure a FOU receive port for IPIP bound to 8888''' + + subprocess.call("ip fou add port 8888 ipproto 4", shell=True) + output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "port 8888 ipproto 4") + + subprocess.call("ip fou del port 8888", shell=True) + + def test_configure_fou_receive_port_gue(self): + ''' Configure a GUE receive port bound to 9999 ''' + + subprocess.call("ip fou add port 9999 gue", shell=True) + output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "port 9999 gue") + + subprocess.call("ip fou del port 9999", shell=True) + + def test_configure_fou_with_ipip(self): + ''' IP over UDP tunnel ''' + + subprocess.call("ip fou add port 9000 ipproto 4", shell=True) + output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "port 9000 ipproto 4") + + subprocess.call("ip link add name tunudp type ipip remote 192.168.2.2 local 192.168.2.1 ttl 225 encap fou encap-sport auto encap-dport 9000", shell=True) + output=subprocess.check_output(['ip', '-d', 'link', 'show', 'tunudp']).rstrip().decode('utf-8') + self.assertRegex(output, "encap fou") + + subprocess.call("ip link del tunudp", shell=True) + subprocess.call("ip fou del port 9000", shell=True) + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-fou-sanity-test/runtest.sh b/tests/ip-fou-sanity-test/runtest.sh new file mode 100755 index 0000000..77123b7 --- /dev/null +++ b/tests/ip-fou-sanity-test/runtest.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test +# Description: Test basic ip address label funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "modprobe fou" + rlRun "cp ip-fou-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip fou tests" + rlRun "/usr/bin/python3 /usr/bin/ip-fou-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-fou-tests.py" + rlLog "ip fou tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index db17319..2ccffac 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -13,6 +13,7 @@ - ip-link-sanity-test - ip-address-sanity-test - ip-address-label-sanity-test + - ip-fou-sanity-test required_packages: - iproute - bridge-utils From 1abbe5eb833cd624ea81ceb16ffb992a38a8648b Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 24 2018 11:26:27 +0000 Subject: [PATCH 3/9] CI: Add ip token to test Sample Run ``` ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: iproute-4.16.0-1.fc28.x86_64 :: [ 16:55:06 ] :: [ PASS ] :: Checking for the presence of iproute rpm :: [ 16:55:06 ] :: [ LOG ] :: Package versions: :: [ 16:55:06 ] :: [ LOG ] :: iproute-4.16.0-1.fc28.x86_64 :: [ 16:55:06 ] :: [ BEGIN ] :: Running 'cp ip-token-tests.py /usr/bin' :: [ 16:55:06 ] :: [ PASS ] :: Command 'cp ip-token-tests.py /usr/bin' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 2 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 16:55:07 ] :: [ LOG ] :: ip token tests :: [ 16:55:07 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-token-tests.py' test_add_token (__main__.IPTokenTests) ... token ::1a:2b:3c:4d dev veth-test ok ---------------------------------------------------------------------- Ran 1 test in 0.029s OK :: [ 16:55:07 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-token-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 1s :: Assertions: 1 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ``` --- diff --git a/tests/ip-token-sanity-test/Makefile b/tests/ip-token-sanity-test/Makefile new file mode 100644 index 0000000..ac08865 --- /dev/null +++ b/tests/ip-token-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test +# Description: Test basic ip token funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-token-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip token funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-token-sanity-test/PURPOSE b/tests/ip-token-sanity-test/PURPOSE new file mode 100644 index 0000000..21b7c1d --- /dev/null +++ b/tests/ip-token-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-token-sanity-test +Description: Test basic ip token funcionality +Author: Susant Sahani diff --git a/tests/ip-token-sanity-test/ip-token-tests.py b/tests/ip-token-sanity-test/ip-token-tests.py new file mode 100755 index 0000000..138168b --- /dev/null +++ b/tests/ip-token-sanity-test/ip-token-tests.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test +# Description: Test basic ip token funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_veth(self): + subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer']) + + def del_veth(self): + subprocess.check_output(['ip', 'link', 'del', 'veth-test']) + +class IPTokenTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_veth() + self.link_exists('veth-test') + + def tearDown(self): + self.del_veth() + + def test_add_token(self): + + r = subprocess.call("ip token set ::1a:2b:3c:4d/64 dev veth-test", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'token', 'get', 'dev', 'veth-test']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "token ::1a:2b:3c:4d dev veth-test") + + r = subprocess.call("ip token del ::1a:2b:3c:4d/64 dev veth-test", shell=True) + self.assertEqual(r, 0) + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-token-sanity-test/runtest.sh b/tests/ip-token-sanity-test/runtest.sh new file mode 100755 index 0000000..82a0ab5 --- /dev/null +++ b/tests/ip-token-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test +# Description: Test basic ip token funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-token-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip token tests" + rlRun "/usr/bin/python3 /usr/bin/ip-token-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-token-tests.py" + rlLog "ip token tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index 2ccffac..a18191f 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -14,6 +14,7 @@ - ip-address-sanity-test - ip-address-label-sanity-test - ip-fou-sanity-test + - ip-token-sanity-test required_packages: - iproute - bridge-utils From 5c4250bd81dde5d5ef160c70d034c5abd4f45528 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 24 2018 11:44:59 +0000 Subject: [PATCH 4/9] CI: Add tuntap to test Sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 17:14:21 ] :: [ LOG ] :: ip tuntap tests :: [ 17:14:21 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-tuntap-tests.py' test_add_tap (__main__.IPTuntapTests) ... fopen /sys/class/net/ip6gre0/tun_flags: No such file or directory fopen /sys/class/net/wlan0/tun_flags: No such file or directory ok ok test_add_tun_user_group (__main__.IPTuntapTests) ... fopen /sys/class/net/ip6gre0/tun_flags: No such file or directory ok ---------------------------------------------------------------------- Ran 3 tests in 0.049s OK :: [ 17:14:21 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-tuntap-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 1 good, 0 bad :: RESULT: PASS ``` --- diff --git a/tests/ip-tuntap-sanity-test/Makefile b/tests/ip-tuntap-sanity-test/Makefile new file mode 100644 index 0000000..5f35f52 --- /dev/null +++ b/tests/ip-tuntap-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test +# Description: Test basic ip tuntap funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-tuntap-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip tuntap funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-tuntap-sanity-test/PURPOSE b/tests/ip-tuntap-sanity-test/PURPOSE new file mode 100644 index 0000000..7c6223a --- /dev/null +++ b/tests/ip-tuntap-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test +Description: Test basic ip tuntap funcionality +Author: Susant Sahani diff --git a/tests/ip-tuntap-sanity-test/ip-tuntap-tests.py b/tests/ip-tuntap-sanity-test/ip-tuntap-tests.py new file mode 100755 index 0000000..9f59a9f --- /dev/null +++ b/tests/ip-tuntap-sanity-test/ip-tuntap-tests.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test +# Description: Test basic ip tuntap funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + +class IPTuntapTests(unittest.TestCase, IPLinkUtilities): + + def test_add_tap(self): + + subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tap-test', 'mode', 'tap']) + self.link_exists('tap-test') + + output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tap-test']).rstrip().decode('utf-8') + self.assertRegex(output, "tap-test: tap") + + subprocess.check_output(['ip', 'link', 'del', 'tap-test']) + + def test_add_tun(self): + + subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun']) + self.link_exists('tun-test') + + output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8') + self.assertRegex(output, "tun-test: tun") + + subprocess.check_output(['ip', 'link', 'del', 'tun-test']) + + def test_add_tun_user_group(self): + + subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun', 'user', 'root', 'group', 'root']) + self.link_exists('tun-test') + + output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8') + self.assertRegex(output, "tun-test: tun") + self.assertRegex(output, "user 0 group 0") + + subprocess.check_output(['ip', 'link', 'del', 'tun-test']) + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-tuntap-sanity-test/runtest.sh b/tests/ip-tuntap-sanity-test/runtest.sh new file mode 100755 index 0000000..00bfe05 --- /dev/null +++ b/tests/ip-tuntap-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test +# Description: Test basic ip tuntap funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-tuntap-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip tuntap tests" + rlRun "/usr/bin/python3 /usr/bin/ip-tuntap-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-tuntap-tests.py" + rlLog "ip tuntap tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index a18191f..8c27973 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -15,6 +15,7 @@ - ip-address-label-sanity-test - ip-fou-sanity-test - ip-token-sanity-test + - ip-tuntap-sanity-test required_packages: - iproute - bridge-utils From 73cd43c0ee2e7d65c401ebf53fcfe71f9013161c Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 24 2018 13:40:47 +0000 Subject: [PATCH 5/9] CI: Add ip tunnel to test Sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 17:39:52 ] :: [ LOG ] :: ip tunnel tests :: [ 17:39:52 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-tunnel-tests.py' test_add_gre (__main__.IPTunnelTests) ... sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 ip_vti0: ip/ip remote any local any ttl inherit nopmtudisc key 0 gre0: gre/ip remote any local any ttl inherit nopmtudisc tunl0: any/ip remote any local any ttl inherit nopmtudisc gretun-test: gre/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64 ok test_add_ipip (__main__.IPTunnelTests) ... sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 ip_vti0: ip/ip remote any local any ttl inherit nopmtudisc key 0 gre0: gre/ip remote any local any ttl inherit nopmtudisc tunl0: any/ip remote any local any ttl inherit nopmtudisc ipiptun-test: ip/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64 ok test_add_isatap (__main__.IPTunnelTests) ... sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 ip_vti0: ip/ip remote any local any ttl inherit nopmtudisc key 0 gre0: gre/ip remote any local any ttl inherit nopmtudisc tunl0: any/ip remote any local any ttl inherit nopmtudisc isatap-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64 6rd-prefix 2002::/16 ok test_add_sit (__main__.IPTunnelTests) ... sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 ip_vti0: ip/ip remote any local any ttl inherit nopmtudisc key 0 gre0: gre/ip remote any local any ttl inherit nopmtudisc tunl0: any/ip remote any local any ttl inherit nopmtudisc sittun-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64 6rd-prefix 2002::/16 ok test_add_vti (__main__.IPTunnelTests) ... sit0: ipv6/ip remote any local any ttl 64 nopmtudisc 6rd-prefix 2002::/16 ip_vti0: ip/ip remote any local any ttl inherit nopmtudisc key 0 gre0: gre/ip remote any local any ttl inherit nopmtudisc tunl0: any/ip remote any local any ttl inherit nopmtudisc vti-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64 6rd-prefix 2002::/16 ok ---------------------------------------------------------------------- Ran 5 tests in 0.197s OK ``` --- diff --git a/tests/ip-tunnel-sanity-test/Makefile b/tests/ip-tunnel-sanity-test/Makefile new file mode 100644 index 0000000..cffa119 --- /dev/null +++ b/tests/ip-tunnel-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test +# Description: Test basic ip tunnel funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-tunnel-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip tunnel funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-tunnel-sanity-test/PURPOSE b/tests/ip-tunnel-sanity-test/PURPOSE new file mode 100644 index 0000000..0b8f618 --- /dev/null +++ b/tests/ip-tunnel-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test +Description: Test basic ip tunnel funcionality +Author: Susant Sahani diff --git a/tests/ip-tunnel-sanity-test/ip-tunnel-tests.py b/tests/ip-tunnel-sanity-test/ip-tunnel-tests.py new file mode 100755 index 0000000..58b7641 --- /dev/null +++ b/tests/ip-tunnel-sanity-test/ip-tunnel-tests.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test +# Description: Test basic ip tunnel funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def add_dummy(self): + subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy']) + self.link_exists('dummy-test') + + def del_dummy(self): + subprocess.check_output(['ip', 'link', 'del', 'dummy-test']) + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + +class IPTunnelTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_dummy() + self.link_exists('dummy-test') + + def tearDown(self): + self.del_dummy() + + def test_add_ipip(self): + + subprocess.check_output(['ip', 'tunnel', 'add', 'ipiptun-test', 'mode', 'ipip', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test']) + self.link_exists('ipiptun-test') + + output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "ipiptun-test: ip/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64") + + subprocess.check_output(['ip', 'link', 'del', 'ipiptun-test']) + + def test_add_gre(self): + + subprocess.check_output(['ip', 'tunnel', 'add', 'gretun-test', 'mode', 'gre', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test']) + self.link_exists('gretun-test') + + output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "gretun-test: gre/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64") + + subprocess.check_output(['ip', 'link', 'del', 'gretun-test']) + + def test_add_sit(self): + + subprocess.check_output(['ip', 'tunnel', 'add', 'sittun-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test']) + self.link_exists('sittun-test') + + output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "sittun-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64") + + subprocess.check_output(['ip', 'link', 'del', 'sittun-test']) + + def test_add_isatap(self): + + subprocess.check_output(['ip', 'tunnel', 'add', 'isatap-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test']) + self.link_exists('isatap-test') + + output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "isatap-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64") + + subprocess.check_output(['ip', 'link', 'del', 'isatap-test']) + + def test_add_vti(self): + + subprocess.check_output(['ip', 'tunnel', 'add', 'vti-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test']) + self.link_exists('vti-test') + + output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "vti-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64") + + subprocess.check_output(['ip', 'link', 'del', 'vti-test']) + + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-tunnel-sanity-test/runtest.sh b/tests/ip-tunnel-sanity-test/runtest.sh new file mode 100755 index 0000000..58a154d --- /dev/null +++ b/tests/ip-tunnel-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test +# Description: Test basic ip tunnel funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-tunnel-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip tunnel tests" + rlRun "/usr/bin/python3 /usr/bin/ip-tunnel-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-tunnel-tests.py" + rlLog "ip tunnel tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index 8c27973..8e03214 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -16,6 +16,7 @@ - ip-fou-sanity-test - ip-token-sanity-test - ip-tuntap-sanity-test + - ip-tunnel-sanity-test required_packages: - iproute - bridge-utils From e3e7ca1187b3ccfaf85a8c3107902fdb6303c8ce Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 30 2018 09:52:04 +0000 Subject: [PATCH 6/9] CI: Add l2tp to test Sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 15:21:16 ] :: [ LOG ] :: ip l2tp tests :: [ 15:21:16 ] :: [ LOG ] :: ip l2tp tests :: [ 15:21:16 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-l2tp-tests.py' test_add_l2tp_add_tunnel (__main__.IPL2tpTests) ... Tunnel 3000, encap UDP From 192.168.11.12 to 192.168.11.13 Peer tunnel 4000 UDP source / dest ports: 5000/6000 UDP checksum: disabled ok test_add_l2tp_add_tunnel_session (__main__.IPL2tpTests) ... Tunnel 3000, encap UDP From 192.168.11.12 to 192.168.11.13 Peer tunnel 4000 UDP source / dest ports: 5000/6000 UDP checksum: disabled Session 1000 in tunnel 3000 Peer session 2000, tunnel 4000 interface name: l2tpeth0 offset 0, peer offset 0 ok test_setup_l2tp (__main__.IPL2tpTests) ... Tunnel 3000, encap UDP From 192.168.11.12 to 192.168.11.13 Peer tunnel 4000 UDP source / dest ports: 5000/6000 UDP checksum: disabled Session 1000 in tunnel 3000 Peer session 2000, tunnel 4000 interface name: l2tpeth0 offset 0, peer offset 0 Tunnel 4000, encap UDP From 192.168.11.13 to 192.168.11.12 Peer tunnel 3000 UDP source / dest ports: 6000/5000 UDP checksum: disabled Tunnel 3000, encap UDP From 192.168.11.12 to 192.168.11.13 Peer tunnel 4000 UDP source / dest ports: 5000/6000 UDP checksum: disabled Session 2000 in tunnel 4000 Peer session 1000, tunnel 3000 interface name: l2tpeth1 offset 0, peer offset 0 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s31f6: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether 8c:16:45:6c:83:b9 brd ff:ff:ff:ff:ff:ff 3: wlp4s0: mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 link/ether 7c:76:35:ea:89:90 brd ff:ff:ff:ff:ff:ff 4: tun0: mtu 1360 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 100 link/none 92: gre0@NONE: mtu 1476 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 93: gretap0@NONE: mtu 1462 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 94: erspan0@NONE: mtu 1446 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 100: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/tunnel6 :: brd :: 101: ip6gre0@NONE: mtu 1448 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre6 :: brd :: 104: tunl0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 117: sit0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 126: ip_vti0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 168: test-peer@veth-test: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 96:03:08:d2:65:40 brd ff:ff:ff:ff:ff:ff 169: veth-test@test-peer: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether c2:8c:3b:9f:ea:32 brd ff:ff:ff:ff:ff:ff 170: l2tpeth0: mtu 1488 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 76:41:ec:b9:d2:75 brd ff:ff:ff:ff:ff:ff 171: l2tpeth1: mtu 65481 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 8e:7f:ab:21:a2:ea brd ff:ff:ff:ff:ff:ff PING 10.42.1.2 (10.42.1.2) 56(84) bytes of data. 64 bytes from 10.42.1.2: icmp_seq=1 ttl=64 time=0.013 ms 64 bytes from 10.42.1.2: icmp_seq=2 ttl=64 time=0.043 ms 64 bytes from 10.42.1.2: icmp_seq=3 ttl=64 time=0.066 ms 64 bytes from 10.42.1.2: icmp_seq=4 ttl=64 time=0.045 ms 64 bytes from 10.42.1.2: icmp_seq=5 ttl=64 time=0.041 ms --- 10.42.1.2 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4126ms rtt min/avg/max/mdev = 0.013/0.041/0.066/0.018 ms ok ---------------------------------------------------------------------- Ran 3 tests in 4.322s OK :: [ 15:21:21 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-l2tp-tests.py' (Expected 0, got 0) :: [ 15:21:21 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-l2tp-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 5s :: Duration: 5s :: Assertions: 1 good, 0 bad :: Assertions: 1 good, 0 bad :: RESULT: PASS :: RESULT: PASS ``` --- diff --git a/tests/ip-l2tp-sanity-test/Makefile b/tests/ip-l2tp-sanity-test/Makefile new file mode 100644 index 0000000..7040c7c --- /dev/null +++ b/tests/ip-l2tp-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test +# Description: Test basic ip l2tp funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-l2tp-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip l2tp funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-l2tp-sanity-test/PURPOSE b/tests/ip-l2tp-sanity-test/PURPOSE new file mode 100644 index 0000000..4224b1d --- /dev/null +++ b/tests/ip-l2tp-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test +Description: Test basic ip l2tp funcionality +Author: Susant Sahani diff --git a/tests/ip-l2tp-sanity-test/ip-l2tp-tests.py b/tests/ip-l2tp-sanity-test/ip-l2tp-tests.py new file mode 100755 index 0000000..1f20a14 --- /dev/null +++ b/tests/ip-l2tp-sanity-test/ip-l2tp-tests.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test +# Description: Test basic ip l2tp funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_veth(self): + subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer']) + + def del_veth(self): + subprocess.check_output(['ip', 'link', 'del', 'veth-test']) + + def add_address(self, address, interface): + subprocess.check_output(['ip', 'address', 'add', address, 'dev', interface]) + +class IPL2tpTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_veth() + self.link_exists('veth-test') + + self.add_address('192.168.11.12/24', 'veth-test') + self.add_address('192.168.11.13/24', 'test-peer') + + def tearDown(self): + self.del_veth() + + def test_add_l2tp_add_tunnel(self): + + r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13") + self.assertRegex(output, "Peer tunnel 4000") + self.assertRegex(output, "UDP source / dest ports: 5000/6000") + + r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True) + self.assertEqual(r, 0) + + def test_add_l2tp_add_tunnel_session(self): + + r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13") + self.assertRegex(output, "Peer tunnel 4000") + self.assertRegex(output, "UDP source / dest ports: 5000/6000") + + r = subprocess.call(" ip l2tp add session tunnel_id 3000 session_id 1000 peer_session_id 2000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '3000', 'session_id' ,'1000']).rstrip().decode('utf-8') + print(output) + + r = subprocess.call("ip l2tp del session tunnel_id 3000 session_id 1000", shell=True) + self.assertEqual(r, 0) + + r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True) + self.assertEqual(r, 0) + + def test_setup_l2tp(self): + + r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13") + self.assertRegex(output, "Peer tunnel 4000") + self.assertRegex(output, "UDP source / dest ports: 5000/6000") + + r = subprocess.call(" ip l2tp add session tunnel_id 3000 session_id 1000 peer_session_id 2000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '3000', 'session_id' ,'1000']).rstrip().decode('utf-8') + print(output) + + r = subprocess.call("ip l2tp add tunnel tunnel_id 4000 peer_tunnel_id 3000 encap udp local 192.168.11.13 remote 192.168.11.12 udp_sport 6000 udp_dport 5000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "From 192.168.11.13 to 192.168.11.12") + self.assertRegex(output, "Peer tunnel 4000") + self.assertRegex(output, "UDP source / dest ports: 6000/5000") + + r = subprocess.call("ip l2tp add session tunnel_id 4000 session_id 2000 peer_session_id 1000", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '4000', 'session_id' ,'2000']).rstrip().decode('utf-8') + print(output) + + r = subprocess.call("ip link set l2tpeth0 up mtu 1488", shell=True) + self.assertEqual(r, 0) + r = subprocess.call("ip link set l2tpeth0 up mtu 1488", shell=True) + self.assertEqual(r, 0) + + r = subprocess.call("ip addr add 10.42.1.1 peer 10.42.1.2 dev l2tpeth0", shell=True) + self.assertEqual(r, 0) + r = subprocess.call("ip addr add 10.42.1.2 peer 10.42.1.1 dev l2tpeth1", shell=True) + self.assertEqual(r, 0) + + output=subprocess.check_output(['ip', 'link', 'show']).rstrip().decode('utf-8') + print(output) + + output=subprocess.check_output(['ping', '10.42.1.2','-c', '5']).rstrip().decode('utf-8') + print(output) + + r = subprocess.call("ip l2tp del session tunnel_id 3000 session_id 1000", shell=True) + self.assertEqual(r, 0) + r = subprocess.call("ip l2tp del session tunnel_id 4000 session_id 2000", shell=True) + self.assertEqual(r, 0) + + r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True) + self.assertEqual(r, 0) + r = subprocess.call("ip l2tp del tunnel tunnel_id 4000", shell=True) + self.assertEqual(r, 0) + + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-l2tp-sanity-test/runtest.sh b/tests/ip-l2tp-sanity-test/runtest.sh new file mode 100755 index 0000000..75b0589 --- /dev/null +++ b/tests/ip-l2tp-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test +# Description: Test basic ip l2tp funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-l2tp-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip l2tp tests" + rlRun "/usr/bin/python3 /usr/bin/ip-l2tp-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-l2tp-tests.py" + rlLog "ip l2tp tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index 8e03214..ff6adf8 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -17,6 +17,7 @@ - ip-token-sanity-test - ip-tuntap-sanity-test - ip-tunnel-sanity-test + - ip-l2tp-sanity-test required_packages: - iproute - bridge-utils From 0b5c720c9c3f171b73928a70267c3ecd154ef743 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 31 2018 10:06:29 +0000 Subject: [PATCH 7/9] CI: Add netns to test Sample run: ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 15:37:14 ] :: [ LOG ] :: ip netns tests :: [ 15:37:14 ] :: [ LOG ] :: ip netns tests :: [ 15:37:14 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-netns-tests.py' test_add_dummy_interface_to_ns (__main__.IPNsTests) ... 1: lo: mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: gre0@NONE: mtu 1476 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 3: gretap0@NONE: mtu 1462 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 4: erspan0@NONE: mtu 1446 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 4: erspan0@NONE: mtu 1446 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 5: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/tunnel6 :: brd :: 6: ip6gre0@NONE: mtu 1448 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre6 :: brd :: 7: tunl0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 8: sit0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 9: ip_vti0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 143: dummy-test: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 6e:d1:ba:73:59:c5 brd ff:ff:ff:ff:ff:ff ok test_add_ns (__main__.IPNsTests) ... ok test_add_veth_interface_to_ns (__main__.IPNsTests) ... 1: lo: mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: gre0@NONE: mtu 1476 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 3: gretap0@NONE: mtu 1462 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 4: erspan0@NONE: mtu 1446 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 5: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/tunnel6 :: brd :: 6: ip6gre0@NONE: mtu 1448 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/gre6 :: brd :: 7: tunl0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 8: sit0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 9: ip_vti0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 144: test-peer@if145: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 62:ce:d1:9f:bc:de brd ff:ff:ff:ff:ff:ff link-netnsid 0 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: gre0@NONE: mtu 1476 qdisc noop state DOWN group default qlen 1000 link/gre 0.0.0.0 brd 0.0.0.0 3: gretap0@NONE: mtu 1462 qdisc noop state DOWN group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 4: erspan0@NONE: mtu 1446 qdisc noop state DOWN group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 5: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN group default qlen 1000 link/tunnel6 :: brd :: 6: ip6gre0@NONE: mtu 1448 qdisc noop state DOWN group default qlen 1000 link/gre6 :: brd :: 7: tunl0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 8: sit0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 9: ip_vti0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 144: test-peer@if145: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 62:ce:d1:9f:bc:de brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 10.200.1.2/24 scope global test-peer valid_lft forever preferred_lft forever inet6 fe80::60ce:d1ff:fe9f:bcde/64 scope link tentative valid_lft forever preferred_lft forever PING 10.200.1.1 (10.200.1.1) 56(84) bytes of data. 64 bytes from 10.200.1.1: icmp_seq=1 ttl=64 time=0.063 ms 64 bytes from 10.200.1.1: icmp_seq=2 ttl=64 time=0.042 ms 64 bytes from 10.200.1.1: icmp_seq=3 ttl=64 time=0.054 ms 64 bytes from 10.200.1.1: icmp_seq=4 ttl=64 time=0.059 ms 64 bytes from 10.200.1.1: icmp_seq=5 ttl=64 time=0.064 ms --- 10.200.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4073ms rtt min/avg/max/mdev = 0.042/0.056/0.064/0.010 ms ok ---------------------------------------------------------------------- Ran 3 tests in 4.431s Ran 3 tests in 4.431s OK :: [ 15:37:18 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-netns-tests.py' (Expected 0, got 0) :: [ 15:37:18 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-netns-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 4s :: Duration: 4s :: Assertions: 1 good, 0 bad :: Assertions: 1 good, 0 bad :: RESULT: PASS :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :: Cleanup ``` --- diff --git a/tests/ip-netns-sanity-test/Makefile b/tests/ip-netns-sanity-test/Makefile new file mode 100644 index 0000000..f4cfc49 --- /dev/null +++ b/tests/ip-netns-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test +# Description: Test basic ip netns funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-ns-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip netns funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-netns-sanity-test/PURPOSE b/tests/ip-netns-sanity-test/PURPOSE new file mode 100644 index 0000000..169a84d --- /dev/null +++ b/tests/ip-netns-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-netns-sanity-test +Description: Test basic ip netns funcionality +Author: Susant Sahani diff --git a/tests/ip-netns-sanity-test/ip-netns-tests.py b/tests/ip-netns-sanity-test/ip-netns-tests.py new file mode 100755 index 0000000..78bcb8a --- /dev/null +++ b/tests/ip-netns-sanity-test/ip-netns-tests.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test +# Description: Test basic ip netns funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class GenericUtilities(): + + def path_exists(self, path): + self.assertTrue(os.path.exists(os.path.join('/var/run/netns', path))) + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_veth(self): + subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer']) + + def del_veth(self): + subprocess.check_output(['ip', 'link', 'del', 'veth-test']) + + def add_dummy(self): + subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy']) + + def del_dummy(self): + subprocess.check_output(['ip', 'link', 'del', 'dummy-test']) + +class IPNsTests(unittest.TestCase, GenericUtilities): + + def test_add_ns(self): + + subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test']) + self.path_exists('net-ns-test') + + output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8') + self.assertRegex(output, "net-ns-test") + + self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test']) + + def test_add_dummy_interface_to_ns(self): + + self.add_dummy() + self.link_exists('dummy-test') + + subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test']) + self.path_exists('net-ns-test') + + output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8') + self.assertRegex(output, "net-ns-test") + + subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'netns', 'net-ns-test']) + + output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "dummy-test") + + self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test']) + self.addCleanup(subprocess.call, ['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'del', 'dummy-test']) + + def test_add_veth_interface_to_ns(self): + + self.add_veth() + self.link_exists('veth-test') + + subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test']) + self.path_exists('net-ns-test') + + output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8') + self.assertRegex(output, "net-ns-test") + + subprocess.check_output(['ip', 'link', 'set', 'dev', 'test-peer', 'netns', 'net-ns-test']) + + output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "test-peer") + + # Setup IP address of veth-test. + subprocess.check_output(['ip', 'addr', 'add', '10.200.1.1/24', 'dev', 'veth-test']) + subprocess.check_output(['ip', 'link', 'set', 'veth-test', 'up']) + + # Setup IP address of v-peer1. + subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'addr', 'add',' 10.200.1.2/24', 'dev', 'test-peer']) + subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'set', 'test-peer', 'up']) + subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'set', 'lo', 'up']) + + output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'addr', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "test-peer") + self.assertRegex(output, "lo: ") + self.assertRegex(output, "inet 10.200.1.2/24") + + output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ping', '10.200.1.1', '-c', '5']).rstrip().decode('utf-8') + print(output) + + self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test']) + self.addCleanup(subprocess.call, ['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'del', 'test-peer']) + + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-netns-sanity-test/runtest.sh b/tests/ip-netns-sanity-test/runtest.sh new file mode 100755 index 0000000..c0276fd --- /dev/null +++ b/tests/ip-netns-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-Licenetnse-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test +# Description: Test basic ip netns funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-netns-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip netns tests" + rlRun "/usr/bin/python3 /usr/bin/ip-netns-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-netns-tests.py" + rlLog "ip netns tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index ff6adf8..9b58bad 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -18,6 +18,7 @@ - ip-tuntap-sanity-test - ip-tunnel-sanity-test - ip-l2tp-sanity-test + - ip-netns-sanity-test required_packages: - iproute - bridge-utils From 90c1f7753860f6c2f1a52d983003e1fbf872fe3c Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Jul 31 2018 12:52:25 +0000 Subject: [PATCH 8/9] CI: Add ip route to test Sample run ''' :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 18:23:29 ] :: [ LOG ] :: ip route tests :: [ 18:23:29 ] :: [ LOG ] :: ip route tests :: [ 18:23:29 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-route-tests.py' test_add_blackhole (__main__.IPRouteTests) ... default via 192.168.225.1 dev wlp4s0 proto dhcp metric 600 10.0.0.0/8 via 10.67.116.1 dev tun0 proto static metric 50 10.67.116.0/22 dev tun0 proto kernel scope link src 10.67.117.15 metric 50 blackhole 192.168.1.0/24 192.168.225.0/24 dev wlp4s0 proto kernel scope link src 192.168.225.101 metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 ok test_add_prohibit (__main__.IPRouteTests) ... default via 192.168.225.1 dev wlp4s0 proto dhcp metric 600 10.0.0.0/8 via 10.67.116.1 dev tun0 proto static metric 50 10.67.116.0/22 dev tun0 proto kernel scope link src 10.67.117.15 metric 50 prohibit 192.168.1.0/24 192.168.225.0/24 dev wlp4s0 proto kernel scope link src 192.168.225.101 metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 ok test_add_route (__main__.IPRouteTests) ... default via 192.168.225.1 dev wlp4s0 proto dhcp metric 600 10.0.0.0/8 via 10.67.116.1 dev tun0 proto static metric 50 10.67.116.0/22 dev tun0 proto kernel scope link src 10.67.117.15 metric 50 192.168.1.0/24 dev dummy-test scope link 192.168.225.0/24 dev wlp4s0 proto kernel scope link src 192.168.225.101 metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 ok test_add_route_table (__main__.IPRouteTests) ... 192.168.1.0/24 dev dummy-test scope link ok test_add_throw (__main__.IPRouteTests) ... default via 192.168.225.1 dev wlp4s0 proto dhcp metric 600 10.0.0.0/8 via 10.67.116.1 dev tun0 proto static metric 50 10.67.116.0/22 dev tun0 proto kernel scope link src 10.67.117.15 metric 50 throw 192.168.1.0/24 192.168.225.0/24 dev wlp4s0 proto kernel scope link src 192.168.225.101 metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 ok test_add_unreachable (__main__.IPRouteTests) ... default via 192.168.225.1 dev wlp4s0 proto dhcp metric 600 10.0.0.0/8 via 10.67.116.1 dev tun0 proto static metric 50 10.67.116.0/22 dev tun0 proto kernel scope link src 10.67.117.15 metric 50 unreachable 192.168.1.0/24 192.168.225.0/24 dev wlp4s0 proto kernel scope link src 192.168.225.101 metric 600 192.168.225.1 dev wlp4s0 proto static scope link metric 600 209.132.188.220 via 192.168.225.1 dev wlp4s0 proto static metric 600 ok ---------------------------------------------------------------------- Ran 6 tests in 0.155s OK :: [ 18:23:29 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-route-tests.py' (Expected 0, got 0) :: [ 18:23:29 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-route-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 1s :: Duration: 1s :: Assertions: 1 good, 0 bad :: Assertions: 1 good, 0 bad :: RESULT: PASS :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ''' --- diff --git a/tests/ip-route-sanity-test/Makefile b/tests/ip-route-sanity-test/Makefile new file mode 100644 index 0000000..0b21130 --- /dev/null +++ b/tests/ip-route-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test +# Description: Test basic ip route funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-route-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip route funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-route-sanity-test/PURPOSE b/tests/ip-route-sanity-test/PURPOSE new file mode 100644 index 0000000..792d9ba --- /dev/null +++ b/tests/ip-route-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-route-sanity-test +Description: Test basic ip route funcionality +Author: Susant Sahani diff --git a/tests/ip-route-sanity-test/ip-route-tests.py b/tests/ip-route-sanity-test/ip-route-tests.py new file mode 100755 index 0000000..2845cae --- /dev/null +++ b/tests/ip-route-sanity-test/ip-route-tests.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test +# Description: Test basic ip route funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_dummy(self): + """ Setup """ + subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy']) + self.link_exists('dummy-test') + subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'up']) + + def del_dummy(self): + subprocess.check_output(['ip', 'link', 'del', 'dummy-test']) + +class IPRouteTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_dummy() + + def tearDown(self): + self.del_dummy() + + def test_add_route(self): + + subprocess.check_output(['ip', 'route', 'add', '192.168.1.0/24', 'dev', 'dummy-test']) + + output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "192.168.1.0/24 dev dummy-test scope link") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24', 'dev', 'dummy-test']) + + def test_add_route_table(self): + + subprocess.check_output(['ip', 'route', 'add', 'table', '555', '192.168.1.0/24', 'dev', 'dummy-test']) + + output=subprocess.check_output(['ip', 'route', 'show', 'table', '555']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "192.168.1.0/24 dev dummy-test scope link") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24', 'dev', 'dummy-test', 'table', '555']) + + def test_add_blackhole(self): + + subprocess.check_output(['ip', 'route', 'add', 'blackhole', '192.168.1.0/24']) + + output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "blackhole 192.168.1.0/24") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24']) + + def test_add_unreachable(self): + + subprocess.check_output(['ip', 'route', 'add', 'unreachable', '192.168.1.0/24']) + + output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "unreachable 192.168.1.0/24") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24']) + + def test_add_prohibit(self): + + subprocess.check_output(['ip', 'route', 'add', 'prohibit', '192.168.1.0/24']) + + output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "prohibit 192.168.1.0/24") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24']) + + def test_add_throw(self): + + subprocess.check_output(['ip', 'route', 'add', 'throw', '192.168.1.0/24']) + + output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "throw 192.168.1.0/24") + + subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24']) + + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-route-sanity-test/runtest.sh b/tests/ip-route-sanity-test/runtest.sh new file mode 100755 index 0000000..13340fc --- /dev/null +++ b/tests/ip-route-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test +# Description: Test basic ip route funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-route-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip route tests" + rlRun "/usr/bin/python3 /usr/bin/ip-route-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-route-tests.py" + rlLog "ip route tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index 9b58bad..d1e3112 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -19,6 +19,7 @@ - ip-tunnel-sanity-test - ip-l2tp-sanity-test - ip-netns-sanity-test + - ip-route-sanity-test required_packages: - iproute - bridge-utils From 1418f9951af6a7851cef87eeba95017e70d24f1c Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Aug 02 2018 11:54:20 +0000 Subject: [PATCH 9/9] CI: Add ip neighbour to test sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 17:23:10 ] :: [ LOG ] :: ip neighbor tests :: [ 17:23:10 ] :: [ LOG ] :: ip neighbor tests :: [ 17:23:10 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-neighbor-tests.py' test_add_neighbor (__main__.IPNeighborTests) ... 192.168.100.1 lladdr 00:c0:7b:7d:00:c8 PERMANENT ok test_replace_neighbor (__main__.IPNeighborTests) ... 192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT 192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT ok ---------------------------------------------------------------------- Ran 2 tests in 0.053s OK :: [ 17:23:10 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-neighbor-tests.py' (Expected 0, got 0) :: [ 17:23:10 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-neighbor-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Duration: 0s :: Assertions: 1 good, 0 bad :: Assertions: 1 good, 0 bad :: RESULT: PASS :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ``` --- diff --git a/tests/ip-neighbor-sanity-test/Makefile b/tests/ip-neighbor-sanity-test/Makefile new file mode 100644 index 0000000..67178fd --- /dev/null +++ b/tests/ip-neighbor-sanity-test/Makefile @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test +# Description: Test basic ip neighbor funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +export TEST=/CoreOS/iproute/Sanity/ip-neighbor-sanity-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Susant Sahani " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic ip neighbor funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: iproute" >> $(METADATA) + @echo "Requires: iproute" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ip-neighbor-sanity-test/PURPOSE b/tests/ip-neighbor-sanity-test/PURPOSE new file mode 100644 index 0000000..cad9d8d --- /dev/null +++ b/tests/ip-neighbor-sanity-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test +Description: Test basic ip neighbor funcionality +Author: Susant Sahani diff --git a/tests/ip-neighbor-sanity-test/ip-neighbor-tests.py b/tests/ip-neighbor-sanity-test/ip-neighbor-tests.py new file mode 100755 index 0000000..940bdb0 --- /dev/null +++ b/tests/ip-neighbor-sanity-test/ip-neighbor-tests.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbour-sanity-test +# Description: Test basic ip neighbour funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +# ~~~ + +import errno +import os +import sys +import time +import unittest +import subprocess +import signal +import shutil + +def setUpModule(): + + if shutil.which('ip') is None: + raise OSError(errno.ENOENT, 'ip not found') + +class IPLinkUtilities(): + + def link_exists(self, link): + + self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link))) + + def add_dummy(self): + + subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy']) + self.link_exists('dummy-test') + + def del_dummy(self): + + subprocess.check_output(['ip', 'link', 'del', 'dummy-test']) + +class IPNeighborTests(unittest.TestCase, IPLinkUtilities): + + def setUp(self): + self.add_dummy() + self.link_exists('dummy-test') + + def tearDown(self): + self.del_dummy() + + def test_add_neighbor(self): + + subprocess.call("ip neighbor add 192.168.100.1 lladdr 00:c0:7b:7d:00:c8 dev dummy-test nud permanent", shell=True) + output=subprocess.check_output(['ip', 'neighbour', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "192.168.100.1 lladdr 00:c0:7b:7d:00:c8 PERMANENT") + + subprocess.call("ip neighbor del 192.168.100.1 dev dummy-test", shell=True) + + def test_replace_neighbor(self): + + subprocess.call("ip neighbor add 192.168.99.254 lladdr 00:80:c8:27:69:2d dev dummy-test", shell=True) + output=subprocess.check_output(['ip', 'neighbour', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, "192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT") + + subprocess.call("ip neighbor change 192.168.99.254 lladdr 00:80:c8:27:69:2d dev dummy-test", shell=True) + print(output) + self.assertRegex(output, "192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT") + + subprocess.call("ip neighbor del 192.168.99.254 dev dummy-test", shell=True) + + +if __name__ == '__main__': + unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, + verbosity=2)) diff --git a/tests/ip-neighbor-sanity-test/runtest.sh b/tests/ip-neighbor-sanity-test/runtest.sh new file mode 100755 index 0000000..dd5aba5 --- /dev/null +++ b/tests/ip-neighbor-sanity-test/runtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1+ +# ~~~ +# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test +# Description: Test basic ip neighbor funcionality +# +# Author: Susant Sahani +# Copyright (c) 2018 Red Hat, Inc. +#~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="iproute" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "cp ip-neighbor-tests.py /usr/bin" + rlPhaseEnd + + rlPhaseStartTest + rlLog "ip neighbor tests" + rlRun "/usr/bin/python3 /usr/bin/ip-neighbor-tests.py" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /usr/bin/ip-neighbor-tests.py" + rlLog "ip neighbor tests done" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + +rlGetTestState diff --git a/tests/tests.yml b/tests/tests.yml index d1e3112..ae233e0 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -20,6 +20,7 @@ - ip-l2tp-sanity-test - ip-netns-sanity-test - ip-route-sanity-test + - ip-neighbor-sanity-test required_packages: - iproute - bridge-utils