From a95592f3a1d5bd4232632499bea19de479da1835 Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 20 Jul 2016 11:56:41 +0100 Subject: [PATCH] Ensure that oslo_utils.fileutils is mocked During unit test execution, container spawn will attempt to ensure that the instances directory exists using fileutils.ensure_tree. This breaks when the tests are run on a read-only filesystem. Generally mock fileutils in the driver module to ensure that this does not happen. Change-Id: If2c6010136bd8c7b2ccd59418084a55445aa4e08 --- nova/tests/unit/virt/lxd/test_driver.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/tests/unit/virt/lxd/test_driver.py b/nova/tests/unit/virt/lxd/test_driver.py index 0f57821d..c41dbebd 100644 --- a/nova/tests/unit/virt/lxd/test_driver.py +++ b/nova/tests/unit/virt/lxd/test_driver.py @@ -144,6 +144,10 @@ class LXDDriverTest(test.NoDBTestCase): network_info = [mock.Mock()] block_device_info = mock.Mock() + # NOTE: mock out fileutils to ensure that unit tests don't try + # to manipulate the filesystem (breaks in package builds). + driver.fileutils = mock.Mock() + lxd_driver = driver.LXDDriver(None) lxd_driver.init_host(None) # XXX: rockstar (6 Jul 2016) - There are a number of XXX comments