From 7e0bcbbeee12ce93f317f52e7c27192d53f9c5d1 Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Thu, 17 May 2018 15:23:54 -0500 Subject: fall back to PARTUUID if UUID not found. Change-Id: Icbf1fd8179658bd8bcd15f99aaaee796288dbf6f Story: 2002052 Task: 19714 --- .../tests/unit/extensions/test_image.py | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'ironic_python_agent/tests/unit') diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index d23db27f..c061278c 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -263,7 +263,8 @@ class TestImageExtension(base.IronicAgentTest): expected = [mock.call('partx', '-u', self.fake_dev, attempts=3, delay_on_retry=True), mock.call('udevadm', 'settle'), - mock.call('lsblk', '-PbioKNAME,UUID,TYPE', self.fake_dev)] + mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', + self.fake_dev)] mock_execute.assert_has_calls(expected) self.assertFalse(mock_dispatch.called) @@ -280,7 +281,8 @@ class TestImageExtension(base.IronicAgentTest): expected = [mock.call('partx', '-u', self.fake_dev, attempts=3, delay_on_retry=True), mock.call('udevadm', 'settle'), - mock.call('lsblk', '-PbioKNAME,UUID,TYPE', self.fake_dev)] + mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', + self.fake_dev)] mock_execute.assert_has_calls(expected) self.assertFalse(mock_dispatch.called) @@ -295,6 +297,23 @@ class TestImageExtension(base.IronicAgentTest): expected = [mock.call('partx', '-u', self.fake_dev, attempts=3, delay_on_retry=True), mock.call('udevadm', 'settle'), - mock.call('lsblk', '-PbioKNAME,UUID,TYPE', self.fake_dev)] + mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', + self.fake_dev)] + mock_execute.assert_has_calls(expected) + self.assertFalse(mock_dispatch.called) + + def test__get_partition_partuuid(self, mock_execute, mock_dispatch): + lsblk_output = ('''KNAME="test" UUID="" TYPE="disk" + KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part" + KNAME="test2" PARTUUID="%s" TYPE="part"''' % self.fake_root_uuid) + mock_execute.side_effect = (None, None, [lsblk_output]) + + root_part = image._get_partition(self.fake_dev, self.fake_root_uuid) + self.assertEqual('/dev/test2', root_part) + expected = [mock.call('partx', '-u', self.fake_dev, attempts=3, + delay_on_retry=True), + mock.call('udevadm', 'settle'), + mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', + self.fake_dev)] mock_execute.assert_has_calls(expected) self.assertFalse(mock_dispatch.called) -- cgit v1.2.1