diff options
Diffstat (limited to 'tests/unit/benchmark/scenarios/networking')
3 files changed, 83 insertions, 66 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py b/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py index e3a096446..e42832f1b 100644 --- a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py +++ b/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py @@ -1,56 +1,56 @@ -#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity
-
-import mock
-import unittest
-import os
-import json
-
-from yardstick.benchmark.scenarios.networking import networkcapacity
-
-SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}'
-
-@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')
-class NetworkCapacityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'password': "root"
- },
- }
-
- self.result = {}
-
- def test_capacity_successful_setup(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_capacity_successful(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = json.loads(SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_unsuccessful_script_error(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, self.result)
+#!/usr/bin/env python + +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity + +import mock +import unittest +import os +import json + +from yardstick.benchmark.scenarios.networking import networkcapacity + +SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}' + +@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh') +class NetworkCapacityTestCase(unittest.TestCase): + + def setUp(self): + self.ctx = { + 'host': { + 'ip': '172.16.0.137', + 'user': 'cirros', + 'password': "root" + }, + } + + self.result = {} + + def test_capacity_successful_setup(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + c.setup() + self.assertIsNotNone(c.client) + self.assertTrue(c.setup_done) + + def test_capacity_successful(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + + mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '') + c.run(self.result) + expected_result = json.loads(SAMPLE_OUTPUT) + self.assertEqual(self.result, expected_result) + + def test_capacity_unsuccessful_script_error(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + + mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') + self.assertRaises(RuntimeError, c.run, self.result) diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py index b600e4103..0b8fba268 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping6.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py @@ -25,16 +25,33 @@ class PingTestCase(unittest.TestCase): 'host1': { 'ip': '172.16.0.137', 'user': 'cirros', + 'role': "Controller", 'key_filename': "mykey.key", 'password': "root" }, + 'host2': { + "ip": "172.16.0.138", + "key_filename": "/root/.ssh/id_rsa", + "role": "Compute", + "name": "node3.IPV6", + "user": "root" + }, } } + def test_get_controller_node(self): + args = { + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, + 'sla': {'max_rtt': 50} + } + p = ping6.Ping6(args, self.ctx) + controller_node = p._get_controller_node(['host1','host2']) + self.assertEqual(controller_node, 'host1') + @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_setup(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 50} } p = ping6.Ping6(args, self.ctx) @@ -46,7 +63,7 @@ class PingTestCase(unittest.TestCase): @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_no_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, } result = {} @@ -61,7 +78,7 @@ class PingTestCase(unittest.TestCase): def test_ping_successful_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 150} } result = {} @@ -76,7 +93,7 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 50} } result = {} @@ -90,7 +107,7 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_script_error(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 150} } result = {} diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/tests/unit/benchmark/scenarios/networking/test_vsperf.py index cb5c09ab3..25d52212b 100644 --- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py +++ b/tests/unit/benchmark/scenarios/networking/test_vsperf.py @@ -39,17 +39,17 @@ class VsperfTestCase(unittest.TestCase): } self.args = { 'options': { - 'testname': 'rfc2544_p2p_continuous', + 'testname': 'p2p_rfc2544_continuous', 'traffic_type': 'continuous', - 'pkt_sizes': '64', + 'frame_size': '64', 'bidirectional': 'True', 'iload': 100, - 'duration': 29, 'trafficgen_port1': 'eth1', 'trafficgen_port2': 'eth3', 'external_bridge': 'br-ex', - 'conf-file': 'vsperf-yardstick.conf', - 'setup-script': 'setup_yardstick.sh', + 'conf_file': 'vsperf-yardstick.conf', + 'setup_script': 'setup_yardstick.sh', + 'test_params': 'TRAFFICGEN_DURATION=30;', }, 'sla': { 'metrics': 'throughput_rx_fps', |