#4 CI: Add ip addrlabel to test
Merged a year ago by psutter. Opened a year ago by ssahani.
rpms/ ssahani/iproute tests  into  master

CI: Add ip neighbour to test
Susant Sahani • a year ago  
CI: Add ip route to test
Susant Sahani • a year ago  
CI: Add netns to test
Susant Sahani • a year ago  
CI: Add l2tp to test
Susant Sahani • a year ago  
CI: Add ip tunnel to test
Susant Sahani • a year ago  
CI: Add tuntap to test
Susant Sahani • a year ago  
CI: Add ip token to test
Susant Sahani • a year ago  
CI: Add FOU to test.
Susant Sahani • a year ago  
CI: Add ip addrlabel to test
Susant Sahani • a year ago  

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-address-label-sanity-test

+ Description: Test basic ip address label funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-fou-sanity-test

+ Description: Test basic ip fou funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test

+ Description: Test basic ip l2tp funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test

+ Description: Test basic ip neighbor funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-netns-sanity-test

+ Description: Test basic ip netns funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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: <LOOPBACK,UP,LOWER_UP>")

+         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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-route-sanity-test

+ Description: Test basic ip route funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-token-sanity-test

+ Description: Test basic ip token funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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))

@@ -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 <susant@redhat.com>

+ #   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

@@ -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 <susant@redhat.com>

+ #   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 <susant@redhat.com>" > $(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)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test

+ Description: Test basic ip tunnel funcionality

+ Author: Susant Sahani <susant@redhat.com>

@@ -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 <susant@redhat.com>

+ #   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')