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
17 from yardstick.benchmark.scenarios.availability.operation import operation_general
19 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
20 'operation_general.ssh')
21 @mock.patch('yardstick.benchmark.scenarios.availability.operation.'
22 'operation_general.open')
23 class GeneralOperaionTestCase(unittest.TestCase):
29 "key_filename": "/root/.ssh/id_rsa"
31 self.context = {"node1": host}
32 self.operation_cfg = {
33 'operation_type': 'general-operation',
34 'action_parameter': {'ins_cup': 2},
35 'rollback_parameter': {'ins_id': 'id123456'},
36 'key': 'nova-create-instance',
39 self.operation_cfg_noparam = {
40 'operation_type': 'general-operation',
41 'key': 'nova-create-instance',
45 def test__operation_successful(self, mock_open, mock_ssh):
46 ins = operation_general.GeneralOperaion(self.operation_cfg,
48 mock_ssh.SSH().execute.return_value = (0, "success", '')
53 def test__operation_successful_noparam(self, mock_open, mock_ssh):
54 ins = operation_general.GeneralOperaion(self.operation_cfg_noparam,
56 mock_ssh.SSH().execute.return_value = (0, "success", '')
61 def test__operation_fail(self, mock_open, mock_ssh):
62 ins = operation_general.GeneralOperaion(self.operation_cfg,
64 mock_ssh.SSH().execute.return_value = (1, "failed", '')