Commit ed14e260 authored by Martín Ferrari's avatar Martín Ferrari

Some more tests. Fix for the bug found after those :)

parent de652f18
...@@ -351,7 +351,7 @@ class Link(ExternalInterface): ...@@ -351,7 +351,7 @@ class Link(ExternalInterface):
def disconnect(self, iface): def disconnect(self, iface):
assert iface.control.index in self._ports assert iface.control.index in self._ports
netns.iproute.del_bridge_port(self.index, iface.control.index) netns.iproute.del_bridge_port(self.index, iface.control.index)
netns.iproute.clear_tc(self.index) self._apply_parameters({}, iface.control)
del self._ports[iface.control.index] del self._ports[iface.control.index]
def set_parameters(self, bandwidth = None, def set_parameters(self, bandwidth = None,
...@@ -375,6 +375,6 @@ class Link(ExternalInterface): ...@@ -375,6 +375,6 @@ class Link(ExternalInterface):
self._parameters = parameters self._parameters = parameters
def _apply_parameters(self, parameters, port = None): def _apply_parameters(self, parameters, port = None):
for i in [port] if port else self._ports: for i in [port] if port else self._ports.values():
netns.iproute.set_tc(self.index, **parameters) netns.iproute.set_tc(i.index, **parameters)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import os, unittest import os, unittest
import netns, test_util import netns, test_util
class TestGlobal(unittest.TestCase): class TestLink(unittest.TestCase):
@test_util.skipUnless(os.getuid() == 0, "Test requires root privileges") @test_util.skipUnless(os.getuid() == 0, "Test requires root privileges")
def test_link(self): def test_link(self):
n1 = netns.Node() n1 = netns.Node()
...@@ -30,6 +30,14 @@ class TestGlobal(unittest.TestCase): ...@@ -30,6 +30,14 @@ class TestGlobal(unittest.TestCase):
ifdata = netns.iproute.get_if_data()[0] ifdata = netns.iproute.get_if_data()[0]
self.assertEquals(ifdata[i1.control.index].up, True, "UP propagation") self.assertEquals(ifdata[i1.control.index].up, True, "UP propagation")
self.assertEquals(ifdata[i2.control.index].up, True, "UP propagation") self.assertEquals(ifdata[i2.control.index].up, True, "UP propagation")
# None => tbf
l.set_parameters(bandwidth = 100*1024*1024/8) # 100 mbits
tcdata = netns.iproute.get_tc_data()[0]
self.assertEquals(tcdata[i1.control.index],
{'bandwidth': 104858000, 'qdiscs': {'tbf': '1'}})
self.assertEquals(tcdata[i2.control.index],
{'bandwidth': 104858000, 'qdiscs': {'tbf': '1'}})
#bandwidth = 100*1024*1024/8, loss=10, loss_correlation=1,delay=0.001,dup_correlation=0.1); #bandwidth = 100*1024*1024/8, loss=10, loss_correlation=1,delay=0.001,dup_correlation=0.1);
# FIXME: more cases # FIXME: more cases
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment