Ido Barkan has uploaded a new change for review.
Change subject: net: tests: test tc upper limit using iperf
......................................................................
net: tests: test tc upper limit using iperf
The test uses iperf to verify that the upper limit set by traffic
control is imposed over the generated client.
Change-Id: I9348a09e331195695c16862ef986df3b4abfa991
Signed-off-by: Ido Barkan <ibarkan(a)redhat.com>
---
M tests/tcTests.py
1 file changed, 49 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/46449/1
diff --git a/tests/tcTests.py b/tests/tcTests.py
index 4ce6cd4..05d7b62 100644
--- a/tests/tcTests.py
+++ b/tests/tcTests.py
@@ -31,12 +31,16 @@
from testlib import (VdsmTestCase as TestCaseBase, permutations,
expandPermutations)
-from testValidation import ValidateRunningAsRoot
-from nettestlib import Bridge, Dummy, Tap, vlan_device, requires_tc
+from testValidation import ValidateRunningAsRoot, slowtest
+from nettestlib import (Bridge, Dummy, Tap, vlan_device, requires_tc, veth_pair,
+ IperfServer, IperfClient, requires_iperf3,
+ bridge_device, network_namespace)
from vdsm.constants import EXT_TC
from network import tc
from network.configurators import qos
+from vdsm.ipwrapper import addrAdd, linkSet, netns_exec, netns_assign
+from vdsm.utils import running
class TestQdisc(TestCaseBase):
@@ -441,6 +445,49 @@
self.assertEqual(current_tagged_filters_flow_id,
expected_flow_ids)
+ @requires_iperf3
+ @requires_tc
+ @slowtest
+ def test_iperf_upper_limit(self):
+ # Upper limit is not an accurate measure. This is because it converges
+ # over time and depends on current machine hardware (CPU).
+ # Hence, it is hard to make hard assertions on it. The test should run
+ # at least 60 seconds (the longer the better) and the user should
+ # inspect the computed average rate and optionally the additional
+ # traffic data that was collected in client.out in order to be
+ # convinced QOS is working properly.
+ limit_kbps = 1000 # 1 Mbps (in kbps)
+ limit_bps = limit_kbps * 2 ** 10
+ server_ip = '192.0.2.1'
+ client_ip = '192.0.2.10'
+ qos_out = {'ul': {'m2': limit_kbps}, 'ls': {'m2':
limit_kbps}}
+ # using a network namespace is essential since otherwise the kernel
+ # short-circuits the traffic and bypasses the veth devices and the
+ # classfull qdisc.
+ with network_namespace('server_ns') as ns, bridge_device() as bridge, \
+ veth_pair() as (server_peer, server_dev), \
+ veth_pair() as (client_dev, client_peer):
+ linkSet(server_peer, ['up'])
+ linkSet(client_peer, ['up'])
+ # iperf server and its veth peer lie in a separate network
+ # namespace
+ netns_assign(server_dev, ns)
+ bridge.addIf(server_peer)
+ bridge.addIf(client_peer)
+ linkSet(client_dev, ['up'])
+ netns_exec(ns, ['ip', 'link', 'set', 'dev',
server_dev, 'up'])
+ addrAdd(client_dev, client_ip, 24)
+ netns_exec(ns, ['ip', '-4', 'addr', 'add',
'dev', server_dev,
+ '%s/24' % server_ip])
+ qos.configure_outbound(qos_out, client_peer, None)
+ with running(IperfServer(server_ip, network_ns=ns)),\
+ running(IperfClient(server_ip, client_ip, test_time=60)) \
+ as client:
+ max_rate = max([float(
+ interval['streams'][0]['bits_per_second'])/(2**10)
+ for interval in client.out['intervals']])
+ self.assertTrue(0 < max_rate < limit_kbps * 1.5)
+
def _analise_qos_and_general_assertions(self):
tc_classes = self._analise_classes()
tc_qdiscs = self._analise_qdiscs()
--
To view, visit
https://gerrit.ovirt.org/46449
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9348a09e331195695c16862ef986df3b4abfa991
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan(a)redhat.com>