import pytest
import pyroute2
import struct
+import time
from .namespaces import Namespace
def __call__(self, *args):
return self.veth(*args)
- def veth(self, ns1, ns2):
+ def veth(self, ns1, ns2, sleep=0):
"""Create a veth pair between two namespaces."""
with self.ns:
# First, create a link
with ns1:
ipr = pyroute2.IPRoute()
ipr.link('set', index=idx[0], state='up')
+ time.sleep(sleep)
with ns2:
ipr = pyroute2.IPRoute()
ipr.link('set', index=idx[1], state='up')
def test_new_interface(lldpd1, lldpd, lldpcli, namespaces, links):
with namespaces(2):
lldpd()
- links(namespaces(1), namespaces(2))
- time.sleep(10)
+ links(namespaces(1), namespaces(2), 4)
+ time.sleep(6)
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
assert out['lldp.eth0.port.descr'] == 'eth1'
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
assert out['lldp.eth0.port.descr'] == 'eth1'
assert out['lldp.eth0.port.power.device-type'] == 'PSE'
- links(namespaces(1), namespaces(2))
- time.sleep(10)
+ links(namespaces(1), namespaces(2), 4)
+ time.sleep(6)
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
assert out['lldp.eth2.port.descr'] == 'eth3'