From 543bf18afd71a6449b5aa4713251b7f2fb951499 Mon Sep 17 00:00:00 2001 From: Diana Clarke Date: Fri, 16 Dec 2016 09:01:56 -0500 Subject: [PATCH] Failing test (mac osx) - test_cache_ephemeral Test test_cache_ephemeral fails on mac osx with the following traceback. Traceback (most recent call last): File "mock/mock.py", line 1305, in patched return func(*args, **keywargs) File "test_imagebackend.py", line 773, in test_cache_ephemeral ephemeral_size=size_gb, size=size) File "imagebackend.py", line 206, in cache fileutils.ensure_tree(base_dir) File "oslo_utils/fileutils.py", line 40, in ensure_tree os.makedirs(path, mode) File "python2.7/os.py", line 150, in makedirs makedirs(head, mode) OSError: [Errno 21] Is a directory: '/' Change-Id: I695ccae534d2f53fdace3f7bb4bc1df953d712d3 --- nova/tests/unit/virt/libvirt/test_imagebackend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/virt/libvirt/test_imagebackend.py b/nova/tests/unit/virt/libvirt/test_imagebackend.py index 56619c440e4..124d303512c 100644 --- a/nova/tests/unit/virt/libvirt/test_imagebackend.py +++ b/nova/tests/unit/virt/libvirt/test_imagebackend.py @@ -735,7 +735,9 @@ def test_cache_base_dir_exists(self): @mock.patch('os.path.exists', autospec=True) @mock.patch('nova.utils.synchronized', autospec=True) @mock.patch.object(imagebackend, 'lvm', autospec=True) - def test_cache_ephemeral(self, mock_lvm, mock_synchronized, mock_exists): + @mock.patch.object(imagebackend.fileutils, 'ensure_tree', autospec=True) + def test_cache_ephemeral(self, mock_ensure, mock_lvm, mock_synchronized, + mock_exists): # Ignores its arguments and returns the wrapped function unmodified def fake_synchronized(*args, **kwargs): def outer(fn): @@ -772,6 +774,7 @@ def fake_create_volume(vg, lv, size, sparse=False): image.cache(fetch_func, self.TEMPLATE, ephemeral_size=size_gb, size=size) + mock_ensure.assert_called_once_with(self.TEMPLATE_DIR) mock_lvm.create_volume.assert_called_once_with(self.VG, self.LV, size, sparse=False) fetch_func.assert_called_once_with(target=self.PATH,