3 ##############################################################################
4 # Copyright (c) 2016 Huan Li and others
5 # lihuansse@tongji.edu.cn
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 ##############################################################################
12 # Unittest for yardstick.benchmark.scenarios.availability.operation
15 from __future__ import absolute_import
18 from yardstick.benchmark.scenarios.availability.operation import \
22 # pylint: disable=unused-argument
23 # disable this for now because I keep forgetting mock patch arg ordering
26 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
27 'operation_general.ssh')
28 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
29 'operation_general.open')
30 class GeneralOperaionTestCase(unittest.TestCase):
36 "key_filename": "/root/.ssh/id_rsa"
38 self.context = {"node1": host}
39 self.operation_cfg = {
40 'operation_type': 'general-operation',
41 'action_parameter': {'ins_cup': 2},
42 'rollback_parameter': {'ins_id': 'id123456'},
43 'key': 'nova-create-instance',
44 'operation_key': 'nova-create-instance',
47 self.operation_cfg_noparam = {
48 'operation_type': 'general-operation',
49 'key': 'nova-create-instance',
50 'operation_key': 'nova-create-instance',
54 def test__operation_successful(self, mock_open, mock_ssh):
55 ins = operation_general.GeneralOperaion(self.operation_cfg,
57 mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
62 def test__operation_successful_noparam(self, mock_open, mock_ssh):
63 ins = operation_general.GeneralOperaion(self.operation_cfg_noparam,
65 mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
70 def test__operation_fail(self, mock_open, mock_ssh):
71 ins = operation_general.GeneralOperaion(self.operation_cfg,
73 mock_ssh.SSH.from_node().execute.return_value = (1, "failed", '')