1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB 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 ##############################################################################
10 # Unittest for yardstick.benchmark.scenarios.networking.sfc
12 from __future__ import absolute_import
16 from yardstick.benchmark.scenarios.networking import sfc
19 class SfcTestCase(unittest.TestCase):
39 self.sfc = sfc.Sfc(scenario_cfg=scenario_cfg, context_cfg=context_cfg)
41 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.ssh')
42 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.sfc_openstack')
43 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.subprocess')
44 def test_run_for_success(self, mock_subprocess, mock_openstack, mock_ssh):
45 # Mock a successfull SSH in Sfc.setup() and Sfc.run()
46 mock_ssh.SSH.from_node().execute.return_value = (0, '100', '')
47 mock_openstack.get_an_IP.return_value = "127.0.0.1"
48 mock_subprocess.call.return_value = 'mocked!'
55 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.ssh')
56 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.sfc_openstack')
57 @mock.patch('yardstick.benchmark.scenarios.networking.sfc.subprocess')
58 def test2_run_for_success(self, mock_subprocess, mock_openstack, mock_ssh):
59 # Mock a successfull SSH in Sfc.setup() and Sfc.run()
60 mock_ssh.SSH.from_node().execute.return_value = (
61 0, 'vxlan_tool.py', 'succeeded timed out')
62 mock_openstack.get_an_IP.return_value = "127.0.0.1"
63 mock_subprocess.call.return_value = 'mocked!'