Edward Haas has uploaded a new change for review.

Change subject: net tests: IPv6 autoconf with RA server
......................................................................

net tests: IPv6 autoconf with RA server

Adding an integration test that checks IPv6 address allocation through
slaac (autoconf).

The test used dnsmasq with enabled router advertisement.

Change-Id: I7c153adf7d27db0151a330f55719622a8f730a9b
Signed-off-by: Edward Haas <edwa...@redhat.com>
---
M tests/network/netinfo_test.py
M tests/network/nettestlib.py
2 files changed, 47 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/54668/1

diff --git a/tests/network/netinfo_test.py b/tests/network/netinfo_test.py
index fa5c441..2f06019 100644
--- a/tests/network/netinfo_test.py
+++ b/tests/network/netinfo_test.py
@@ -34,7 +34,7 @@
 from .ipwrapper_test import _fakeTypeDetection
 from modprobe import RequireBondingMod
 from monkeypatch import MonkeyPatch, MonkeyPatchScope
-from .nettestlib import dummy_device, veth_pair
+from .nettestlib import dnsmasq_run, dummy_device, veth_pair, wait_for_ipv6
 from testlib import VdsmTestCase as TestCaseBase, namedTemporaryDir
 from testValidation import ValidateRunningAsRoot
 from testValidation import brokentest
@@ -404,3 +404,24 @@
             self.assertEqual(1, len(ip_addrs))
             self.assertTrue(addresses.is_ipv6(ip_addrs[0]))
             self.assertTrue(not addresses.is_dynamic(ip_addrs[0]))
+
+    def test_local_auto_with_dynamic_address_from_ra(self):
+        with veth_pair() as (server, client):
+            with dnsmasq_run(server, ipv6_slaac_prefix='2001:0:0:1::'):
+                with wait_for_ipv6(client):
+                    ipwrapper.linkSet(client, ['up'])
+                    ipwrapper.linkSet(server, ['up'])
+                    ipwrapper.addrAdd(server, '2001:0:0:1::1', '64', family=6)
+
+                # Expecting link and global addresses on client iface
+                ip_addrs = addresses.getIpAddrs()[client]
+                self.assertEqual(2, len(ip_addrs))
+
+                # The global address is also the dynamic one
+                # The addresses are given randomly, so we check the order
+                if addresses.is_dynamic(ip_addrs[0]):
+                    self.assertEqual('2001::1', ip_addrs[0]['address'][:7])
+                    self.assertEqual('fe80', ip_addrs[1]['address'][:4])
+                else:
+                    self.assertEqual('2001::1', ip_addrs[1]['address'][:7])
+                    self.assertEqual('fe80', ip_addrs[0]['address'][:4])
diff --git a/tests/network/nettestlib.py b/tests/network/nettestlib.py
index f880cea..4c77f16 100644
--- a/tests/network/nettestlib.py
+++ b/tests/network/nettestlib.py
@@ -415,3 +415,28 @@
             raise SkipTest("This test requires tun device")
         return f(*a, **kw)
     return wrapper
+
+
+@contextmanager
+def wait_for_ipv6(iface, wait_for_scopes=None):
+    """Wait for iface to get their IPv6 addresses with netlink Monitor"""
+    if not wait_for_scopes:
+        wait_for_scopes = ['global', 'link']
+    try:
+        with monitor.Monitor(groups=('ipv6-ifaddr',), timeout=20) as mon:
+            yield
+            for event in mon:
+                dev_name = event.get('label')
+                if dev_name == iface and (event.get('event') == 'new_addr' and
+                   event.get('scope') in wait_for_scopes):
+
+                    wait_for_scopes.remove(event.get('scope'))
+                    if not wait_for_scopes:
+                        return
+
+    except monitor.MonitorError as e:
+        if e[0] == monitor.E_TIMEOUT:
+            raise Exception('IPv6 addresses has not been caught within the '
+                            'given timeout.\n')
+        else:
+            raise


-- 
To view, visit https://gerrit.ovirt.org/54668
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7c153adf7d27db0151a330f55719622a8f730a9b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwa...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to