Merge ~powersj/cloud-init:fix-test-mkfs into cloud-init:master

Proposed by Joshua Powers
Status: Merged
Approved by: Scott Moser
Approved revision: 1789f964cbdac52973d0ca075c538ddd7aff0d9e
Merged at revision: 66e46d8ec290737fd74f50eb8c7672d627d9b516
Proposed branch: ~powersj/cloud-init:fix-test-mkfs
Merge into: cloud-init:master
Diff against target: 17 lines (+3/-1)
1 file modified
tests/unittests/test_handler/test_handler_disk_setup.py (+3/-1)
Reviewer Review Type Date Requested Status
Scott Moser Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+324201@code.launchpad.net

Commit message

tests: fix hardcoded path to mkfs.ext4

A recent merge that added a mkfs.ext4 tests has a hard coded location
for the binary of mkfs.ext4. On CentOS 7 the test failed because the
command in a different location than Ubuntu.

LP: #1691517

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Can we instead mock the which ?
As the test is now, this will fail if there is no mkfs.ext4.

Revision history for this message
Joshua Powers (powersj) wrote :

With mock method per smoser and tested on zesty and centos 7.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) :
review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_handler/test_handler_disk_setup.py b/tests/unittests/test_handler/test_handler_disk_setup.py
2index 68fc6aa..35dff3e 100644
3--- a/tests/unittests/test_handler/test_handler_disk_setup.py
4+++ b/tests/unittests/test_handler/test_handler_disk_setup.py
5@@ -202,9 +202,11 @@ class TestMkfsCommandHandling(TestCase):
6 subp.assert_called_once_with(
7 'mkfs -t ext4 -L with_cmd /dev/xdb1', shell=True)
8
9- def test_overwrite_and_extra_opts_without_cmd(self, subp, *args):
10+ @mock.patch('cloudinit.config.cc_disk_setup.util.which')
11+ def test_overwrite_and_extra_opts_without_cmd(self, m_which, subp, *args):
12 """mkfs observes extra_opts and overwrite settings when cmd is not
13 present."""
14+ m_which.side_effect = lambda p: {'mkfs.ext4': '/sbin/mkfs.ext4'}[p]
15 cc_disk_setup.mkfs({
16 'filesystem': 'ext4',
17 'device': '/dev/xdb1',

Subscribers

People subscribed via source and target branches