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

Proposed by Joshua Powers on 2017-05-17
Status: Merged
Approved by: Scott Moser on 2017-05-17
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 2017-05-17 Approve on 2017-05-17
Server Team CI bot continuous-integration Approve on 2017-05-17
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.
Scott Moser (smoser) wrote :

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

~powersj/cloud-init:fix-test-mkfs updated on 2017-05-17
1789f96... by Joshua Powers on 2017-05-17

using mock versus which

Joshua Powers (powersj) wrote :

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

Scott Moser (smoser) :
review: Approve

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