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 ```
This commit is contained in:
parent
c0b9f8a2e0
commit
fd68e09fe1
47
tests/ip-address-label-sanity-test/Makefile
Normal file
47
tests/ip-address-label-sanity-test/Makefile
Normal file
@ -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)
|
3
tests/ip-address-label-sanity-test/PURPOSE
Normal file
3
tests/ip-address-label-sanity-test/PURPOSE
Normal file
@ -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>
|
89
tests/ip-address-label-sanity-test/ip-address-label-tests.py
Executable file
89
tests/ip-address-label-sanity-test/ip-address-label-tests.py
Executable file
@ -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))
|
34
tests/ip-address-label-sanity-test/runtest.sh
Executable file
34
tests/ip-address-label-sanity-test/runtest.sh
Executable file
@ -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
|
@ -12,6 +12,7 @@
|
|||||||
- bridge-utility
|
- bridge-utility
|
||||||
- ip-link-sanity-test
|
- ip-link-sanity-test
|
||||||
- ip-address-sanity-test
|
- ip-address-sanity-test
|
||||||
|
- ip-address-label-sanity-test
|
||||||
required_packages:
|
required_packages:
|
||||||
- iproute
|
- iproute
|
||||||
- bridge-utils
|
- bridge-utils
|
||||||
|
Loading…
Reference in New Issue
Block a user