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 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
23 'operation_general.ssh')
24 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
25 'operation_general.open')
26 class GeneralOperaionTestCase(unittest.TestCase):
32 "key_filename": "/root/.ssh/id_rsa"
34 self.context = {"node1": host}
35 self.operation_cfg = {
36 'operation_type': 'general-operation',
37 'action_parameter': {'ins_cup': 2},
38 'rollback_parameter': {'ins_id': 'id123456'},
39 'key': 'nova-create-instance',
40 'operation_key': 'nova-create-instance',
43 self.operation_cfg_noparam = {
44 'operation_type': 'general-operation',
45 'key': 'nova-create-instance',
46 'operation_key': 'nova-create-instance',
50 def test__operation_successful(self, mock_open, mock_ssh):
51 ins = operation_general.GeneralOperaion(self.operation_cfg,
53 mock_ssh.SSH().execute.return_value = (0, "success", '')
58 def test__operation_successful_noparam(self, mock_open, mock_ssh):
59 ins = operation_general.GeneralOperaion(self.operation_cfg_noparam,
61 mock_ssh.SSH().execute.return_value = (0, "success", '')
66 def test__operation_fail(self, mock_open, mock_ssh):
67 ins = operation_general.GeneralOperaion(self.operation_cfg,
69 mock_ssh.SSH().execute.return_value = (1, "failed", '')