summaryrefslogtreecommitdiff
path: root/ironic/tests/unit
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-04-15 10:29:43 +0000
committerGerrit Code Review <review@openstack.org>2021-04-15 10:29:43 +0000
commit342c43aaf89d48a24a122b5b9b3f37ae0a127aa0 (patch)
treeab815326f8d092d246b29e3658e1f844b55064f5 /ironic/tests/unit
parent550c4e0753963d347f5e475e4e7b11555e4b96bd (diff)
parentb205a32ca801c1cc95472cc82c87a95416836a19 (diff)
downloadironic-342c43aaf89d48a24a122b5b9b3f37ae0a127aa0.tar.gz
Merge "Fix ipmitool timing argument calculation" into stable/victoria
Diffstat (limited to 'ironic/tests/unit')
-rw-r--r--ironic/tests/unit/drivers/modules/test_ipmitool.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/ironic/tests/unit/drivers/modules/test_ipmitool.py b/ironic/tests/unit/drivers/modules/test_ipmitool.py
index 7236ef399..7a172ec2d 100644
--- a/ironic/tests/unit/drivers/modules/test_ipmitool.py
+++ b/ironic/tests/unit/drivers/modules/test_ipmitool.py
@@ -1075,7 +1075,7 @@ class IPMIToolPrivateMethodTestCase(
'-L', self.info['priv_level'],
'-U', self.info['username'],
'-v',
- '-R', '12',
+ '-R', '7',
'-N', '5',
'-f', awesome_password_filename,
'A', 'B', 'C',
@@ -1131,7 +1131,7 @@ class IPMIToolPrivateMethodTestCase(
'-L', self.info['priv_level'],
'-U', self.info['username'],
'-v',
- '-R', '12',
+ '-R', '7',
'-N', '5',
'-f', awesome_password_filename,
'A', 'B', 'C',
@@ -1598,6 +1598,40 @@ class IPMIToolPrivateMethodTestCase(
self.info)
self.assertFalse(mock_status.called)
+ @mock.patch.object(ipmi, '_is_option_supported', autospec=True)
+ def test__ipmitool_timing_args(self, mock_support):
+ # timing arguments not supported
+ mock_support.return_value = False
+ self.assertEqual([], ipmi._ipmitool_timing_args())
+
+ # handle retries by calling ipmitool repeatedly
+ mock_support.return_value = True
+ self.config(use_ipmitool_retries=False, group='ipmi')
+ self.config(min_command_interval=5, group='ipmi')
+ self.assertEqual(['-R', '1', '-N', '5'], ipmi._ipmitool_timing_args())
+
+ # confirm that different combinations of min_command_interval and
+ # command_retry_timeout result in the command finishing before
+ # command_retry_timeout
+ self.config(use_ipmitool_retries=True, group='ipmi')
+
+ # 7 retries, first interval is 5s
+ # 5 + 6 + 7 + 8 + 9 + 10 + 11 = 56s
+ self.config(command_retry_timeout=60, group='ipmi')
+ self.assertEqual(['-R', '7', '-N', '5'], ipmi._ipmitool_timing_args())
+
+ # 11 retries, first interval is 5s
+ # 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 = 110s
+ self.config(command_retry_timeout=120, group='ipmi')
+ self.config(min_command_interval=5, group='ipmi')
+ self.assertEqual(['-R', '11', '-N', '5'], ipmi._ipmitool_timing_args())
+
+ # 7 retries, first interval is 1s
+ # 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28s
+ self.config(command_retry_timeout=30, group='ipmi')
+ self.config(min_command_interval=1, group='ipmi')
+ self.assertEqual(['-R', '7', '-N', '1'], ipmi._ipmitool_timing_args())
+
class IPMIToolDriverTestCase(Base):