#2 CI: Add CI tests using the standard test interface
Opened 5 years ago by ssahani. Modified 5 years ago
rpms/ ssahani/libteam tests  into  rawhide

@@ -0,0 +1,19 @@ 

+ {

+   "device": "team-ci",

+     "runner": {"name": "activebackup"},

+     "link_watch": {

+     "name": "nsna_ping",

+     "interval": 200,

+     "missed_max": 15,

+     "target_host": "fe80::210:18ff:feaa:bbcc"

+     },

+       "ports": {

+         "port1": {

+           "prio": -10,

+           "sticky": true

+         },

+         "port2": {

+           "prio": 100

+         }

+       }

+ }

@@ -0,0 +1,36 @@ 

+ #!/bin/bash

+ 

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ LIBTEAM="libteam"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $LIBTEAM

+         rlRun "setenforce 0" 0,1

+         rlRun "mkdir -p /var/run/teamd-ci"

+ 

+         rlRun "cp teamd-ci.service /var/run/systemd/system"

+         rlRun "cp teamd-tests.py /usr/bin/"

+         rlRun "cp *.conf /var/run/teamd-ci"

+         rlRun "cp teamd-ci-ifcfg team-ci-port-ifcfg /etc/sysconfig/network-scripts/"

+ 

+         rlRun "systemctl daemon-reload"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlLog "Starting teamd tests ..."

+         rlRun "/usr/bin/python3 /usr/bin/teamd-tests.py"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "rm -rf /usr/bin/teamd-tests.py /var/run/teamd-ci /var/run/systemd/system/teamd-ci.service /etc/sysconfig/network-scripts/teamd-ci-ifcfg /etc/sysconfig/network-scripts/team-ci-port-ifcfg"

+         rlRun "systemctl daemon-reload"

+ 

+         rlRun "setenforce 1" 0,1

+         rlLog "teamd tests done"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

+ rlGetTestState

@@ -0,0 +1,6 @@ 

+ DEVICE=port1

+ HWADDR=00:11:22:33:44:55

+ DEVICETYPE=TeamPort

+ ONBOOT=yes

+ TEAM_MASTER=team-ci

+ TEAM_PORT_CONFIG='{"prio": 100}'

@@ -0,0 +1,18 @@ 

+ {

+    "device": "team-ci",

+    "runner": {

+       "name": "activebackup"

+    },

+    "link_watch": {

+       "name": "ethtool"

+    },

+    "ports": {

+       "port1": {

+          "prio": -10,

+          "sticky": true

+       },

+       "port2": {

+          "prio": 100

+       }

+    }

+ }

@@ -0,0 +1,20 @@ 

+ {

+        "device": "team-ci",

+        "runner": {"name": "activebackup"},

+        "link_watch":{

+            "name": "arp_ping",

+            "interval": 100,

+            "missed_max": 30,

+            "source_host": "192.168.23.2",

+            "target_host": "192.168.23.1"

+        },

+          "ports": {

+              "port1": {

+                "prio": -10,

+                "sticky": true

+              },

+              "port2": {

+                "prio": 100

+              }

+          }

+ }

@@ -0,0 +1,5 @@ 

+ {

+  "device": "team-ci",

+  "runner": {"name": "broadcast"},

+  "ports": {"port1": {}, "port2": {}}

+ }

@@ -0,0 +1,7 @@ 

+ DEVICE=team-ci

+ DEVICETYPE=Team

+ ONBOOT=yes

+ BOOTPROTO=none

+ IPADDR=192.168.11.1

+ PREFIX=24

+ TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

@@ -0,0 +1,5 @@ 

+ {

+ "device": "team-ci",

+ "runner": {"name": "roundrobin"},

+ "ports": {"port1": {}, "port2": {}}

+ }

@@ -0,0 +1,11 @@ 

+ [Unit]

+ Description=Teamd CI tests

+ 

+ [Service]

+ Type=oneshot

+ ExecStart=/usr/bin/teamd -d -f /var/run/teamd-ci/teamd-ci.conf

+ ExecStop=/usr/bin/teamd -k -f /var/run/teamd-ci/teamd-ci.conf

+ RemainAfterExit=yes

+ 

+ [Install]

+ WantedBy=multi-user.target

@@ -0,0 +1,11 @@ 

+ {

+    "device": "team-ci",

+    "runner": {

+        "name": "lacp",

+        "active": true,

+        "fast_rate": true,

+        "tx_hash": ["eth", "ipv4", "ipv6"]

+    },

+      "link_watch": {"name": "ethtool"},

+      "ports": {"port1": {}, "port2": {}}

+ }

@@ -0,0 +1,8 @@ 

+ {

+  "device": "team-ci",

+  "runner": {

+    "name": "loadbalance",

+    "tx_hash": ["eth", "ipv4", "ipv6"]

+  },

+  "ports": {"port1": {}, "port2": {}}

+ }

@@ -0,0 +1,192 @@ 

+ #!/usr/bin/env python3

+ 

+ import errno

+ import os

+ import sys

+ import time

+ import unittest

+ import subprocess

+ import signal

+ import socket

+ import shutil

+ from pyroute2 import IPRoute

+ 

+ def setUpModule():

+ 

+     if shutil.which('teamd') is None:

+         raise OSError(errno.ENOENT, 'libteam not found')

+ 

+ class GenericUtilities():

+ 

+     def StartTeamd(self):

+         subprocess.check_output(['systemctl', 'start', 'teamd-ci'])

+ 

+     def StopTeamd(self):

+         subprocess.check_output(['systemctl', 'stop', 'teamd-ci'])

+ 

+     def SetupDummy(self, name, addr):

+ 

+         ip = IPRoute()

+ 

+         ip.link('add', ifname=name, kind='dummy')

+         dev = ip.link_lookup(ifname=name)[0]

+         ip.link('set', index=dev, address=addr, ifname=name)

+ 

+         ip.close()

+ 

+     def TearDownDummy(self, name):

+ 

+         ip = IPRoute()

+         ip.link('del', index=ip.link_lookup(ifname=name)[0])

+         ip.close()

+ 

+ class TeamdTests(unittest.TestCase, GenericUtilities):

+ 

+     def setUp(self):

+         self.SetupDummy('port1', '00:11:22:33:44:55')

+         self.SetupDummy('port2', '00:11:22:33:44:56')

+ 

+     def tearDown(self):

+         self.TearDownDummy('port1')

+         self.TearDownDummy('port2')

+ 

+     def test_teamd_two_ports_conf(self):

+ 

+         self.StartTeamd()

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'mode roundrobin')

+ 

+         self.StopTeamd()

+ 

+     def test_teamd_broadcast_runner_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/teamd-broadcast-runner.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'mode broadcast')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/teamd-broadcast-runner.conf'])

+ 

+     def test_teamd_active_backup_runner_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/teamd-active-backup-runner.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'mode activebackup')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/teamd-active-backup-runner.conf'])

+ 

+     def test_teamd_loadbalance_runner_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/teamd-loadbalance-runner.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'mode loadbalance')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/teamd-loadbalance-runner.conf'])

+ 

+     def test_teamd_lacp_runner_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/teamd-lacp-runner.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'cast_rejoin_interval')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/teamd-lacp-runner.conf'])

+ 

+     def test_teamd_arping_link_state_monitoring_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/teamd-arping-link-state.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         print(output)

+         self.assertRegex(output, 'activebackup')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/teamd-arping-link-state.conf'])

+ 

+     def test_teamd_ipv6_na_ns_link_state_monitoring_conf(self):

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-d','-f', '/var/run/teamd-ci/ipv6-na-ns-link-state-monitoring.conf'])

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port1']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['ip','link', 'show', 'port2']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'activebackup')

+ 

+         output=subprocess.check_output(['teamdctl', 'team-ci', 'config', 'dump', 'actual']).rstrip().decode('utf-8')

+         self.assertRegex(output, '\"interval\": 200')

+         self.assertRegex(output, 'fe80::210:18ff:feaa:bbcc')

+ 

+         subprocess.check_output(['/usr/bin/teamd', '-k', '-f', '/var/run/teamd-ci/ipv6-na-ns-link-state-monitoring.conf'])

+ 

+     def test_teamd_ifcfg(self):

+ 

+         subprocess.check_output(['ifup', 'teamd-ci-ifcfg'])

+         subprocess.check_output(['ifup', 'team-ci-port-ifcfg'])

+ 

+         output=subprocess.check_output(['ip','link', 'show']).rstrip().decode('utf-8')

+         print(output)

+         self.assertRegex(output, 'master team-ci')

+ 

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'activebackup')

+ 

+         ip = IPRoute()

+         ip.link('del', index=ip.link_lookup(ifname='team-ci')[0])

+         ip.close()

+ 

+     def test_teamd_mode_conf(self):

+         ip = IPRoute()

+ 

+         ip.link("add", ifname="team-ci", kind="team")

+ 

+         subprocess.check_output(['teamnl', 'team-ci', 'setoption', 'mode', 'loadbalance'])

+         output=subprocess.check_output(['teamnl','team-ci', 'options']).rstrip().decode('utf-8')

+         self.assertRegex(output, 'mode loadbalance')

+ 

+         ip.link('del', index=ip.link_lookup(ifname='team-ci')[0])

+         ip.close()

+ 

+ if __name__ == '__main__':

+     unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=3))

file added
+13
@@ -0,0 +1,13 @@ 

+ - hosts: localhost

+   roles:

+     - role: standard-test-beakerlib

+       tags:

+         - classic

+       tests:

+         - sanity

+       required_packages:

+         - libteam

+         - python3

+         - systemd

+         - python3-pyroute2

+         - iproute

Justification
Adds tests according to the CI wiki specifically the standard test interface in the spec.
The playbook includes Tier1 level test cases that have been tested in the following contexts
and is passing reliably: Classic and Container. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:

Test environment
Make sure you have installed packages from the spec

$ rpm -q ansible python2-dnf libselinux-python standard-test-roles
ansible-2.3.2.0-1.fc26.noarch
python2-dnf-2.6.3-11.fc26.noarch
libselinux-python-2.6-7.fc26.x86_64
standard-test-roles-2.4-1.fc26.noarch
Install all necessary packages from Standard_Test_Roles
$ sudo dnf install fedpkg libselinux-python standard-test-roles

Sample-run:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 15:25:40 ] :: [   LOG    ] :: Starting teamd tests ...
:: [ 15:25:40 ] :: [   LOG    ] :: Starting teamd tests ...
:: [ 15:25:40 ] :: [  BEGIN   ] :: Running '/usr/bin/python3 /usr/bin/teamd-tests.py'
test_teamd_active_backup_runner_conf (__main__.TeamdTests) ... This program is not intended to be run as root.
ok
test_teamd_arping_link_state_monitoring_conf (__main__.TeamdTests) ... This program is not intended to be run as root.
ok
test_teamd_broadcast_runner_conf (__main__.TeamdTests) ... This program is not intended to be run as root.
ok
test_teamd_lacp_runner_conf (__main__.TeamdTests) ... This program is not intended to be run as root.
ok
test_teamd_loadbalance_runner_conf (__main__.TeamdTests) ... This program is not intended to be run as root.
ok
test_teamd_mode_conf (__main__.TeamdTests) ... ok
test_teamd_two_ports_conf (__main__.TeamdTests) ... ok
---------------------------------------------------------------------
Ran 7 tests in 1.299s

OK
:: [ 15:25:41 ] :: [   PASS   ] :: Command '/usr/bin/python3 /usr/bin/teamd-tests.py' (Expected 0, got 0)
:: [ 15:25:41 ] :: [   PASS   ] :: Command '/usr/bin/python3 /usr/bin/teamd-tests.py' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 2s
::   Duration: 2s
::   Assertions: 1 good, 0 bad
::   Assertions: 1 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

rebased onto c1aecdb

5 years ago