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

```
This commit is contained in:
Susant Sahani 2018-07-24 17:41:29 +05:30
parent 5c4250bd81
commit 73cd43c0ee
5 changed files with 189 additions and 0 deletions

View File

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

View File

@ -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>

View File

@ -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')
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))

View File

@ -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 <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-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

View File

@ -16,6 +16,7 @@
- ip-fou-sanity-test - ip-fou-sanity-test
- ip-token-sanity-test - ip-token-sanity-test
- ip-tuntap-sanity-test - ip-tuntap-sanity-test
- ip-tunnel-sanity-test
required_packages: required_packages:
- iproute - iproute
- bridge-utils - bridge-utils