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