3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
13 # yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity
15 from __future__ import absolute_import
20 from oslo_serialization import jsonutils
22 from yardstick.benchmark.scenarios.networking import networkcapacity
25 '{"Number of connections":"308","Number of frames received": "166503"}'
28 @mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')
29 class NetworkCapacityTestCase(unittest.TestCase):
42 def test_capacity_successful_setup(self, mock_ssh):
43 c = networkcapacity.NetworkCapacity({}, self.ctx)
44 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
46 self.assertIsNotNone(c.client)
47 self.assertTrue(c.setup_done)
49 def test_capacity_successful(self, mock_ssh):
50 c = networkcapacity.NetworkCapacity({}, self.ctx)
52 mock_ssh.SSH.from_node().execute.return_value = (0, SAMPLE_OUTPUT, '')
54 expected_result = jsonutils.loads(SAMPLE_OUTPUT)
55 self.assertEqual(self.result, expected_result)
57 def test_capacity_unsuccessful_script_error(self, mock_ssh):
58 c = networkcapacity.NetworkCapacity({}, self.ctx)
60 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
61 self.assertRaises(RuntimeError, c.run, self.result)