diff options
| author | Arne Wiebalck <Arne.Wiebalck@cern.ch> | 2021-04-26 12:00:44 +0200 |
|---|---|---|
| committer | Arne Wiebalck <Arne.Wiebalck@cern.ch> | 2021-05-01 10:36:20 +0200 |
| commit | 6702fcaa43fda3384415f8e6c2848b8abc6ff15e (patch) | |
| tree | 067ddc65dfdb0f6b2a0c9e5c1f176bc2c42efba6 /ironic_python_agent/tests | |
| parent | 9edb13d891de658124d11099e2287163a76f1050 (diff) | |
| download | ironic-python-agent-6702fcaa43fda3384415f8e6c2848b8abc6ff15e.tar.gz | |
Burn-in: Add CPU step
Add a clean step for CPU burn-in via stress-ng. Get basic
run parameters from the node's driver_info.
Story: #2007523
Task: #42382
Change-Id: I14fd4164991fb94263757244f716b6bfe8edf875
Diffstat (limited to 'ironic_python_agent/tests')
| -rw-r--r-- | ironic_python_agent/tests/unit/test_burnin.py | 56 | ||||
| -rw-r--r-- | ironic_python_agent/tests/unit/test_hardware.py | 7 |
2 files changed, 63 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_burnin.py b/ironic_python_agent/tests/unit/test_burnin.py new file mode 100644 index 00000000..d8339b6c --- /dev/null +++ b/ironic_python_agent/tests/unit/test_burnin.py @@ -0,0 +1,56 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from unittest import mock + +from ironic_lib import utils +from oslo_concurrency import processutils + +from ironic_python_agent import burnin +from ironic_python_agent import errors +from ironic_python_agent.tests.unit import base + + +@mock.patch.object(utils, 'execute', autospec=True) +class TestBurnin(base.IronicAgentTest): + + def test_stress_ng_cpu_default(self, mock_execute): + + node = {'driver_info': {}} + mock_execute.return_value = (['out', 'err']) + + burnin.stress_ng_cpu(node) + + mock_execute.assert_called_once_with( + 'stress-ng', '--cpu', 0, '--timeout', 86400, '--metrics-brief') + + def test_stress_ng_cpu_non_default(self, mock_execute): + + node = {'driver_info': {'agent_burnin_cpu_cpu': 3, + 'agent_burnin_cpu_timeout': 2911}} + mock_execute.return_value = (['out', 'err']) + + burnin.stress_ng_cpu(node) + + mock_execute.assert_called_once_with( + 'stress-ng', '--cpu', 3, '--timeout', 2911, '--metrics-brief') + + def test_stress_ng_cpu_no_stress_ng(self, mock_execute): + + node = {'driver_info': {}} + mock_execute.side_effect = (['out', 'err'], + processutils.ProcessExecutionError()) + + burnin.stress_ng_cpu(node) + + self.assertRaises(errors.CommandExecutionError, + burnin.stress_ng_cpu, node) diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index 4135985e..019a14c0 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -149,6 +149,13 @@ class TestGenericHardwareManager(base.IronicAgentTest): 'interface': 'raid', 'reboot_requested': False, 'abortable': True + }, + { + 'step': 'burnin_cpu', + 'priority': 0, + 'interface': 'deploy', + 'reboot_requested': False, + 'abortable': True } ] clean_steps = self.hardware.get_clean_steps(self.node, []) |
