aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/networking/test_iperf3.py
diff options
context:
space:
mode:
authorwym_libra <yimin.wang@huawei.com>2015-09-23 11:56:15 +0800
committerwym_libra <yimin.wang@huawei.com>2015-10-08 10:02:13 +0800
commit6175d493f0b07b96b34b1290822efd1adfe61fd2 (patch)
tree451c045bc00a1e5a39514dbda85da20dc8553a92 /tests/unit/benchmark/scenarios/networking/test_iperf3.py
parent882af7878ab8119fede93a215c9e402023f817be (diff)
Add testing packet delay variation between VMs
1)create test case("iperfs-jitter") for measuring packet delay variation 2)and modify "iperf3.py" to support it JIRA:YARDSTICK-131 Change-Id: Ic3416a713b69dc7687f6f85ecc0b79da8dfb7ed9 Signed-off-by: wym_libra <yimin.wang@huawei.com>
Diffstat (limited to 'tests/unit/benchmark/scenarios/networking/test_iperf3.py')
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_iperf3.py46
1 files changed, 41 insertions, 5 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_iperf3.py b/tests/unit/benchmark/scenarios/networking/test_iperf3.py
index 239e46a1c..8b0da655b 100644
--- a/tests/unit/benchmark/scenarios/networking/test_iperf3.py
+++ b/tests/unit/benchmark/scenarios/networking/test_iperf3.py
@@ -21,6 +21,8 @@ from yardstick.benchmark.scenarios.networking import iperf3
@mock.patch('yardstick.benchmark.scenarios.networking.iperf3.ssh')
class IperfTestCase(unittest.TestCase):
+ output_name_tcp = 'iperf3_sample_output.json'
+ output_name_udp = 'iperf3_sample_output_udp.json'
def setUp(self):
self.ctx = {
@@ -66,7 +68,7 @@ class IperfTestCase(unittest.TestCase):
options = {}
args = {'options': options}
- sample_output = self._read_sample_output()
+ sample_output = self._read_sample_output(self.output_name_tcp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
result = p.run(args)
@@ -84,7 +86,7 @@ class IperfTestCase(unittest.TestCase):
'sla': {'bytes_per_second': 15000000}
}
- sample_output = self._read_sample_output()
+ sample_output = self._read_sample_output(self.output_name_tcp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
expected_result = json.loads(sample_output)
result = p.run(args)
@@ -102,7 +104,41 @@ class IperfTestCase(unittest.TestCase):
'sla': {'bytes_per_second': 25000000}
}
- sample_output = self._read_sample_output()
+ sample_output = self._read_sample_output(self.output_name_tcp)
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ self.assertRaises(AssertionError, p.run, args)
+
+ def test_iperf_successful_sla_jitter(self, mock_ssh):
+
+ p = iperf3.Iperf(self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
+ options = {"udp":"udp","bandwidth":"20m"}
+ args = {
+ 'options': options,
+ 'sla': {'jitter': 10}
+ }
+
+ sample_output = self._read_sample_output(self.output_name_udp)
+ mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ expected_result = json.loads(sample_output)
+ result = p.run(args)
+ self.assertEqual(result, expected_result)
+
+ def test_iperf_unsuccessful_sla_jitter(self, mock_ssh):
+
+ p = iperf3.Iperf(self.ctx)
+ mock_ssh.SSH().execute.return_value = (0, '', '')
+ p.host = mock_ssh.SSH()
+
+ options = {"udp":"udp","bandwidth":"20m"}
+ args = {
+ 'options': options,
+ 'sla': {'jitter': 0.0001}
+ }
+
+ sample_output = self._read_sample_output(self.output_name_udp)
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, args)
@@ -118,9 +154,9 @@ class IperfTestCase(unittest.TestCase):
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, args)
- def _read_sample_output(self):
+ def _read_sample_output(self,filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, 'iperf3_sample_output.json')
+ output = os.path.join(curr_path, filename)
with open(output) as f:
sample_output = f.read()
return sample_output