-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ceph-volume: fix and clean up unit tests
- update unit test devices/raw/test_list.py: e5e4296 missed the corresponding unit test update. This commit updates it. - fix unit tests when run as non-root user: When unit tests are run as non-root user, it fails for many reasons such as 'permission denied' etc... This commit addresses that by adding missing fixture `is_root` and using pyfakefs when it's needed. - drop test_writer_uses_log_on_unicodeerror test: This test is broken for a while. Since we don't make test against py2, let's drop it. - test_arg_validators cleanup: This makes use of `self.validator` defined in `setup_method()` rather than redefining a new object in each tests. Also, this migrates test_files_are_missing to pyfakefs - test_migrate cleanup: This makes use of `is_root` fixture insead of using mock.patch on `os.getuid` - test_activate cleanup: - removes the fixture monkeypatch from test_no_data_uuid() given that it's not used in this test. - remove the fixture is_root from test_activate_all() - simple.TestActivate.test_no_data_uuid fix: This fixes the following issue: ``` ________________________ TestActivate.test_no_data_uuid ________________________ self = <test_activate.TestActivate object at 0x7f6b1885f1c0> factory = <class 'ceph_volume.tests.conftest.Factory'>, is_root = None capture = <ceph_volume.tests.conftest.Capture object at 0x7f6b17f59340> fake_filesystem = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7f6b17125190> def test_no_data_uuid(self, factory, is_root, capture, fake_filesystem): fake_filesystem.create_file('/tmp/json-config', contents='{}') args = factory(osd_id='0', osd_fsid='1234', json_config='/tmp/json-config') with pytest.raises(RuntimeError): > activate.Activate([]).activate(args) /home/jenkins-build/build/workspace/ceph-volume-pr/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py:12: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = (<ceph_volume.devices.simple.activate.Activate object at 0x7f6b16fcd8b0>, <ceph_volume.tests.conftest.Factory object at 0x7f6b16fcd160>) kw = {} @wraps(func) def is_root(*a, **kw): if not os.getuid() == 0 and not os.environ.get('CEPH_VOLUME_SKIP_NEEDS_ROOT', False): > raise exceptions.SuperUserError() E ceph_volume.exceptions.SuperUserError: This command needs to be executed with sudo or as root /home/jenkins-build/build/workspace/ceph-volume-pr/src/ceph-volume/ceph_volume/decorators.py:15: SuperUserError ``` Even though we use the fixture `is_root`, it doesn't seem to work. Using @patch() instead fixes this issue. - address 'PytestRemovedIn8Warning' messages: pretty self-explanatory: ``` PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release. ``` ``` To remove this warning, rename it to `setup_method(self)` ``` so this commit renames some `def setup(self)` to `def setup_method(self)` as suggested. - add missing unit tests: This adds some unit test updates missed by commits 0985e20 and bd5e1a8 Signed-off-by: Guillaume Abrioux <[email protected]>
- Loading branch information
Showing
16 changed files
with
150 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.