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 ##############################################################################
13 # yardstick.benchmark.scenarios.availability.operation.baseoperation
15 from __future__ import absolute_import
19 from yardstick.benchmark.scenarios.availability.operation import baseoperation
23 'yardstick.benchmark.scenarios.availability.operation.baseoperation'
25 class OperationMgrTestCase(unittest.TestCase):
29 'operation_type': 'general-operation',
30 'key': 'service-status'
33 self.operation_configs = []
34 self.operation_configs.append(config)
36 def test_all_successful(self, mock_operation):
37 mgr_ins = baseoperation.OperationMgr()
38 mgr_ins.init_operations(self.operation_configs, None)
39 operation_ins = mgr_ins["service-status"]
42 def test_getitem_fail(self, mock_operation):
43 mgr_ins = baseoperation.OperationMgr()
44 mgr_ins.init_operations(self.operation_configs, None)
45 with self.assertRaises(KeyError):
46 operation_ins = mgr_ins["operation-not-exist"]
49 class TestOperation(baseoperation.BaseOperation):
50 __operation__type__ = "test-operation"
62 class BaseOperationTestCase(unittest.TestCase):
66 'operation_type': 'general-operation',
67 'key': 'service-status'
70 def test_all_successful(self):
71 base_ins = baseoperation.BaseOperation(self.config, None)
76 def test_get_script_fullpath(self):
77 base_ins = baseoperation.BaseOperation(self.config, None)
78 base_ins.get_script_fullpath("ha_tools/test.bash")
80 def test_get_operation_cls_successful(self):
81 base_ins = baseoperation.BaseOperation(self.config, None)
82 operation_ins = base_ins.get_operation_cls("test-operation")
84 def test_get_operation_cls_fail(self):
85 base_ins = baseoperation.BaseOperation(self.config, None)
86 with self.assertRaises(RuntimeError):
87 operation_ins = base_ins.get_operation_cls("operation-not-exist")