From 95b3ed3fed0169f3c98593807465caabbe0dcdf9 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Wed, 28 Feb 2024 11:24:20 +0100 Subject: [PATCH] Fix unit tests after ironic-lib changes Updating tests after change [1] and [2] in ironic-lib. [1] https://opendev.org/openstack/ironic-lib/commit/ae53e8e4b386992ed2c6cfc1648f3b2f3062e156 [2] https://opendev.org/openstack/ironic-lib/commit/7644196e7d4f7307bab917ed2adf381b8187f774 Change-Id: I880b4f82beb117d8812e60c13040e19476cec32b --- .../tests/unit/test_partition_utils.py | 33 +++++++++++-------- zuul.d/project.yaml | 7 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ironic_python_agent/tests/unit/test_partition_utils.py b/ironic_python_agent/tests/unit/test_partition_utils.py index 2da66dac9..28fc817a1 100644 --- a/ironic_python_agent/tests/unit/test_partition_utils.py +++ b/ironic_python_agent/tests/unit/test_partition_utils.py @@ -18,6 +18,7 @@ from unittest import mock from ironic_lib import disk_partitioner from ironic_lib import disk_utils from ironic_lib import exception +from ironic_lib import qemu_img from ironic_lib import utils from oslo_concurrency import processutils from oslo_config import cfg @@ -700,9 +701,9 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): self.dev), mock.call('sync'), mock.call('udevadm', 'settle'), - mock.call('partprobe', self.dev, attempts=10, run_as_root=True), + mock.call('partprobe', self.dev, run_as_root=True, attempts=10), + mock.call('udevadm', 'settle'), mock.call('sgdisk', '-v', self.dev, run_as_root=True), - mock.call('udevadm', 'settle'), mock.call('test', '-e', expected_part, attempts=15, delay_on_retry=True) @@ -761,7 +762,8 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): self.dev), mock.call('sync'), mock.call('udevadm', 'settle'), - mock.call('partprobe', self.dev, attempts=10, run_as_root=True), + mock.call('partprobe', self.dev, run_as_root=True, attempts=10), + mock.call('udevadm', 'settle'), mock.call('sgdisk', '-v', self.dev, run_as_root=True), mock.call('udevadm', 'settle'), @@ -826,9 +828,9 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): self.dev), mock.call('sync'), mock.call('udevadm', 'settle'), - mock.call('partprobe', self.dev, attempts=10, run_as_root=True), + mock.call('partprobe', self.dev, run_as_root=True, attempts=10), + mock.call('udevadm', 'settle'), mock.call('sgdisk', '-v', self.dev, run_as_root=True), - mock.call('udevadm', 'settle'), mock.call('test', '-e', expected_part, attempts=15, delay_on_retry=True) @@ -929,7 +931,8 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): parted_call, mock.call('sync'), mock.call('udevadm', 'settle'), - mock.call('partprobe', self.dev, attempts=10, run_as_root=True), + mock.call('partprobe', self.dev, run_as_root=True, attempts=10), + mock.call('udevadm', 'settle'), mock.call('sgdisk', '-v', self.dev, run_as_root=True), mock.call('udevadm', 'settle'), mock.call('test', '-e', expected_part, attempts=15, @@ -1028,7 +1031,8 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): 'fat32', '-64MiB', '-0'), mock.call('sync'), mock.call('udevadm', 'settle'), - mock.call('partprobe', self.dev, attempts=10, run_as_root=True), + mock.call('partprobe', self.dev, run_as_root=True, attempts=10), + mock.call('udevadm', 'settle'), mock.call('sgdisk', '-v', self.dev, run_as_root=True), ]) @@ -1226,8 +1230,9 @@ class CreateConfigDriveTestCases(base.IronicAgentTest): @mock.patch.object(disk_utils, 'is_block_device', autospec=True) @mock.patch.object(disk_utils, 'block_uuid', autospec=True) @mock.patch.object(disk_utils, 'dd', autospec=True) -@mock.patch.object(disk_utils, 'convert_image', autospec=True) +@mock.patch.object(qemu_img, 'convert_image', autospec=True) @mock.patch.object(utils, 'mkfs', autospec=True) +@mock.patch.object(disk_utils, 'populate_image', autospec=True) # NOTE(dtantsur): destroy_disk_metadata resets file size, disabling it @mock.patch.object(disk_utils, 'destroy_disk_metadata', autospec=True) class RealFilePartitioningTestCase(base.IronicAgentTest): @@ -1267,9 +1272,9 @@ class RealFilePartitioningTestCase(base.IronicAgentTest): with mock.patch.object(utils, 'execute', fake_execute): return func(*args, **kwargs) - def test_different_sizes(self, mock_destroy, mock_mkfs, mock_convert, - mock_dd, mock_block_uuid, mock_is_block, - mock_wait, mock_trigger_rescan): + def test_different_sizes(self, mock_destroy, mock_populate, mock_mkfs, + mock_convert, mock_dd, mock_block_uuid, + mock_is_block, mock_wait, mock_trigger_rescan): # NOTE(dtantsur): Keep this list in order with expected partitioning fields = ['ephemeral_mb', 'swap_mb', 'root_mb'] variants = ((0, 0, 12), (4, 2, 8), (0, 4, 10), (5, 0, 10)) @@ -1284,9 +1289,9 @@ class RealFilePartitioningTestCase(base.IronicAgentTest): self.assertEqual(expected_size, part['size'], "comparison failed for %s" % list(variant)) - def test_whole_disk(self, mock_destroy, mock_mkfs, mock_convert, mock_dd, - mock_block_uuid, mock_is_block, mock_wait, - mock_trigger_rescan): + def test_whole_disk(self, mock_destroy, mock_populate, mock_mkfs, + mock_convert, mock_dd, mock_block_uuid, + mock_is_block, mock_wait, mock_trigger_rescan): # 6 MiB ephemeral + 3 MiB swap + 9 MiB root + 1 MiB for MBR # + 1 MiB MAGIC == 20 MiB whole disk # TODO(dtantsur): figure out why we need 'magic' 1 more MiB diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 68ee81a5a..50753219b 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -16,7 +16,9 @@ - ipa-tempest-bios-ipmi-direct-src - ipa-tempest-uefi-redfish-vmedia-src - metalsmith-integration-ipa-src-uefi - - metalsmith-integration-ipa-src-legacy + # NOTE(rpittau): Currently broken because of an issue with parted + - metalsmith-integration-ipa-src-legacy: + voting: false - ironic-standalone-ipa-src # NOTE(dtantsur): non-voting because IPA source code is very unlikely # to break them. They rather serve as a canary for broken POST jobs. @@ -37,7 +39,8 @@ - ipa-tempest-bios-ipmi-direct-src - ipa-tempest-uefi-redfish-vmedia-src - metalsmith-integration-ipa-src-uefi - - metalsmith-integration-ipa-src-legacy + # NOTE(rpittau): Currently broken because of an issue with parted + #- metalsmith-integration-ipa-src-legacy - ironic-standalone-ipa-src post: jobs: