From 6175d493f0b07b96b34b1290822efd1adfe61fd2 Mon Sep 17 00:00:00 2001 From: wym_libra Date: Wed, 23 Sep 2015 11:56:15 +0800 Subject: 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 --- .../benchmark/scenarios/networking/test_iperf3.py | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'tests/unit/benchmark/scenarios/networking/test_iperf3.py') 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 -- cgit 1.2.3-korg