summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-06 13:35:12 +0000
committerGerrit Code Review <review@openstack.org>2015-09-06 13:35:12 +0000
commita417baf25c6b9a656b63300f8dca9e5a76ee578e (patch)
tree03f870000fd10089db69b2a4dfc82ea5581f6a43 /ironic_python_agent/tests/unit
parent8165e189494cca2a7bb6ef651b5ba78b5ff6ac82 (diff)
parent19575d026a62d09ba0cb09591a08b353c27cdbc5 (diff)
downloadironic-python-agent-a417baf25c6b9a656b63300f8dca9e5a76ee578e.tar.gz
Merge "Fix get_os_install_device()"
Diffstat (limited to 'ironic_python_agent/tests/unit')
-rw-r--r--ironic_python_agent/tests/unit/test_hardware.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py
index ceac031f..ab167967 100644
--- a/ironic_python_agent/tests/unit/test_hardware.py
+++ b/ironic_python_agent/tests/unit/test_hardware.py
@@ -16,6 +16,7 @@ import mock
import netifaces
import os
from oslo_concurrency import processutils
+from oslo_utils import units
from oslotest import base as test_base
import pyudev
import six
@@ -132,6 +133,14 @@ BLK_DEVICE_TEMPLATE = (
'KNAME="loop0" MODEL="" SIZE="109109248" ROTA="1" TYPE="loop"'
)
+# NOTE(pas-ha) largest device is 1 byte smaller than 4GiB
+BLK_DEVICE_TEMPLATE_SMALL = (
+ 'KNAME="sda" MODEL="TinyUSB Drive" SIZE="3116853504" '
+ 'ROTA="0" TYPE="disk"\n'
+ 'KNAME="sdb" MODEL="AlmostBigEnough Drive" SIZE="4294967295" '
+ 'ROTA="0" TYPE="disk"'
+)
+
SHRED_OUTPUT = (
'shred: /dev/sda: pass 1/2 (random)...\n'
'shred: /dev/sda: pass 1/2 (random)...4.9GiB/29GiB 17%\n'
@@ -271,6 +280,16 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
'lsblk', '-PbdioKNAME,MODEL,SIZE,ROTA,TYPE',
check_exit_code=[0])
+ @mock.patch.object(utils, 'execute')
+ def test_get_os_install_device_fails(self, mocked_execute):
+ """Fail to find device >=4GB w/o root device hints"""
+ mocked_execute.return_value = (BLK_DEVICE_TEMPLATE_SMALL, '')
+ ex = self.assertRaises(errors.DeviceNotFound,
+ self.hardware.get_os_install_device)
+ mocked_execute.assert_called_once_with(
+ 'lsblk', '-PbdioKNAME,MODEL,SIZE,ROTA,TYPE', check_exit_code=[0])
+ self.assertIn(str(4 * units.Gi), ex.details)
+
@mock.patch.object(hardware.GenericHardwareManager, '_get_device_vendor')
@mock.patch.object(pyudev.Device, 'from_device_file')
@mock.patch.object(utils, 'parse_root_device_hints')