summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-05-10 15:00:14 +0000
committerGerrit Code Review <review@openstack.org>2021-05-10 15:00:14 +0000
commit5c01ec4f6f9268ea2a53907913f4cc510fa8d629 (patch)
tree03cf943906a41c3864226230add5274a7546f2d4 /ironic_python_agent/tests
parent6fb4cec7aa0a3edc76b0e07cc9e7cc0b1d4a4e99 (diff)
parent6702fcaa43fda3384415f8e6c2848b8abc6ff15e (diff)
downloadironic-python-agent-5c01ec4f6f9268ea2a53907913f4cc510fa8d629.tar.gz
Merge "Burn-in: Add CPU step"
Diffstat (limited to 'ironic_python_agent/tests')
-rw-r--r--ironic_python_agent/tests/unit/test_burnin.py56
-rw-r--r--ironic_python_agent/tests/unit/test_hardware.py7
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 ad3a8f65..b7b9423f 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, [])