Coverage for watcher/decision_engine/strategy/strategies/dummy_strategy.py: 97%
32 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
1# -*- encoding: utf-8 -*-
2# Copyright (c) 2015 b<>com
3#
4# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15# implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19from oslo_log import log
21from watcher._i18n import _
22from watcher.decision_engine.strategy.strategies import base
24LOG = log.getLogger(__name__)
27class DummyStrategy(base.DummyBaseStrategy):
28 """Dummy strategy used for integration testing via Tempest
30 *Description*
32 This strategy does not provide any useful optimization. Its only purpose
33 is to be used by Tempest tests.
35 *Requirements*
37 <None>
39 *Limitations*
41 Do not use in production.
43 *Spec URL*
45 <None>
46 """
48 NOP = "nop"
49 SLEEP = "sleep"
51 def pre_execute(self):
52 self._pre_execute()
54 def do_execute(self, audit=None):
55 para1 = self.input_parameters.para1
56 para2 = self.input_parameters.para2
57 LOG.debug("Executing Dummy strategy with para1=%(p1)f, para2=%(p2)s",
58 {'p1': para1, 'p2': para2})
59 parameters = {'message': 'hello World'}
60 self.solution.add_action(action_type=self.NOP,
61 input_parameters=parameters)
63 parameters = {'message': para2}
64 self.solution.add_action(action_type=self.NOP,
65 input_parameters=parameters)
67 self.solution.add_action(action_type=self.SLEEP,
68 input_parameters={'duration': para1})
70 def post_execute(self):
71 pass
73 @classmethod
74 def get_name(cls):
75 return "dummy"
77 @classmethod
78 def get_display_name(cls):
79 return _("Dummy strategy")
81 @classmethod
82 def get_translatable_display_name(cls):
83 return "Dummy strategy"
85 @classmethod
86 def get_schema(cls):
87 # Mandatory default setting for each element
88 return {
89 "properties": {
90 "para1": {
91 "description": "number parameter example",
92 "type": "number",
93 "default": 3.2,
94 "minimum": 1.0,
95 "maximum": 10.2,
96 },
97 "para2": {
98 "description": "string parameter example",
99 "type": "string",
100 "default": "hello"
101 },
102 },
103 }