59e647f82c
When we call oslo.config.cfg.CONF(), it will do basic setup and search configuration files under certain directories, by default, they are [/etc, /etc/ceilometer, ~/, ~/.ceilometer]. However, we should avoid such behaviour when we run unit test code, because that if the system has run devstack or installed ceilometer services, then /etc/ceilometer/ceilometer.conf will exist, then unit test result can be different. So we should mock the default searching directories of cfg in the begining of all unit tests, which will call cfg.CONF() at somewhere during the test. The best place to mock the default directories can be ceilometer.test.base.BaseTestCase, which should be used as parent class of all other test classes. Note: since this patch sets default searching directory to {repo}/etc/ceilometer, you can run the unit test with different settings which are set in etc/ceilometer/ceilometer.conf (not tracked by git). Note: mock.patch.stopall has compatibility problem with oslo.fixture, so this patch slightly refactors the tests.compute.pollsters.base.TestPollsterBase.setUp method. Change-Id: I533ffb2ba2c9be0223cecbcf04176312e4a96369 Closes-Bug: #1328550 |
||
---|---|---|
.. | ||
__init__.py | ||
base.py | ||
test_cpu.py | ||
test_diskio.py | ||
test_instance.py | ||
test_location_metadata.py | ||
test_memory.py | ||
test_net.py |