1 ##############################################################################
2 # Copyright (c) 2016 Huan Li and others
3 # lihuansse@tongji.edu.cn
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 ##############################################################################
13 from yardstick.benchmark.scenarios.availability.operation import baseoperation
16 class OperationMgrTestCase(unittest.TestCase):
20 'operation_type': 'general-operation',
21 'key': 'service-status'
24 self.operation_configs = []
25 self.operation_configs.append(config)
27 @mock.patch.object(baseoperation, 'BaseOperation')
28 def test_all_successful(self, *args):
29 mgr_ins = baseoperation.OperationMgr()
30 mgr_ins.init_operations(self.operation_configs, None)
31 _ = mgr_ins["service-status"]
34 @mock.patch.object(baseoperation, 'BaseOperation')
35 def test_getitem_fail(self, *args):
36 mgr_ins = baseoperation.OperationMgr()
37 mgr_ins.init_operations(self.operation_configs, None)
38 with self.assertRaises(KeyError):
39 _ = mgr_ins["operation-not-exist"]
42 class TestOperation(baseoperation.BaseOperation):
43 __operation__type__ = "test-operation"
55 class BaseOperationTestCase(unittest.TestCase):
59 'operation_type': 'general-operation',
60 'key': 'service-status'
62 self.base_ins = baseoperation.BaseOperation(self.config, None)
64 def test_all_successful(self):
67 self.base_ins.rollback()
69 def test_get_script_fullpath(self):
70 self.base_ins.get_script_fullpath("ha_tools/test.bash")
72 # TODO(elfoley): Fix test to check on expected outputs
73 # pylint: disable=unused-variable
74 def test_get_operation_cls_successful(self):
75 operation_ins = self.base_ins.get_operation_cls("test-operation")
77 def test_get_operation_cls_fail(self):
78 with self.assertRaises(RuntimeError):
79 self.base_ins.get_operation_cls("operation-not-exist")