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

```
This commit is contained in:
Susant Sahani 2018-07-24 16:56:27 +05:30
parent d4c9cc3ea7
commit 1abbe5eb83
5 changed files with 144 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-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)

View File

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

View File

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

View File

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

View File

@ -14,6 +14,7 @@
- ip-address-sanity-test - ip-address-sanity-test
- ip-address-label-sanity-test - ip-address-label-sanity-test
- ip-fou-sanity-test - ip-fou-sanity-test
- ip-token-sanity-test
required_packages: required_packages:
- iproute - iproute
- bridge-utils - bridge-utils