Commit d401ef2
committed
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]>1 parent f06dad9 commit d401ef2
File tree
16 files changed
+150
-113
lines changed- src/ceph-volume/ceph_volume/tests
- devices
- lvm
- raw
- simple
- objectstore
- systemd
- util
16 files changed
+150
-113
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
259 | 266 | | |
260 | 267 | | |
261 | 268 | | |
| |||
380 | 387 | | |
381 | 388 | | |
382 | 389 | | |
| 390 | + | |
| 391 | + | |
383 | 392 | | |
384 | 393 | | |
385 | 394 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
Lines changed: 11 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
528 | | - | |
| 527 | + | |
529 | 528 | | |
530 | 529 | | |
531 | 530 | | |
| |||
534 | 533 | | |
535 | 534 | | |
536 | 535 | | |
537 | | - | |
538 | | - | |
539 | | - | |
| 536 | + | |
540 | 537 | | |
541 | 538 | | |
542 | 539 | | |
| |||
549 | 546 | | |
550 | 547 | | |
551 | 548 | | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 549 | + | |
556 | 550 | | |
557 | 551 | | |
558 | 552 | | |
| |||
571 | 565 | | |
572 | 566 | | |
573 | 567 | | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
| 568 | + | |
578 | 569 | | |
579 | 570 | | |
580 | 571 | | |
| |||
819 | 810 | | |
820 | 811 | | |
821 | 812 | | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
| 813 | + | |
826 | 814 | | |
827 | 815 | | |
828 | 816 | | |
| |||
1226 | 1214 | | |
1227 | 1215 | | |
1228 | 1216 | | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
| 1217 | + | |
1232 | 1218 | | |
1233 | 1219 | | |
1234 | 1220 | | |
| |||
1600 | 1586 | | |
1601 | 1587 | | |
1602 | 1588 | | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
| 1589 | + | |
1607 | 1590 | | |
1608 | 1591 | | |
1609 | 1592 | | |
| |||
1722 | 1705 | | |
1723 | 1706 | | |
1724 | 1707 | | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
| 1708 | + | |
1729 | 1709 | | |
1730 | 1710 | | |
1731 | 1711 | | |
| |||
1996 | 1976 | | |
1997 | 1977 | | |
1998 | 1978 | | |
1999 | | - | |
2000 | 1979 | | |
2001 | 1980 | | |
2002 | 1981 | | |
| |||
2058 | 2037 | | |
2059 | 2038 | | |
2060 | 2039 | | |
2061 | | - | |
2062 | 2040 | | |
2063 | | - | |
| 2041 | + | |
2064 | 2042 | | |
2065 | 2043 | | |
2066 | | - | |
2067 | | - | |
2068 | 2044 | | |
2069 | 2045 | | |
2070 | 2046 | | |
| |||
2134 | 2110 | | |
2135 | 2111 | | |
2136 | 2112 | | |
2137 | | - | |
2138 | 2113 | | |
2139 | | - | |
| 2114 | + | |
2140 | 2115 | | |
2141 | 2116 | | |
2142 | | - | |
2143 | | - | |
2144 | 2117 | | |
2145 | 2118 | | |
2146 | 2119 | | |
| |||
2361 | 2334 | | |
2362 | 2335 | | |
2363 | 2336 | | |
2364 | | - | |
2365 | 2337 | | |
2366 | | - | |
| 2338 | + | |
2367 | 2339 | | |
2368 | 2340 | | |
2369 | | - | |
2370 | | - | |
2371 | 2341 | | |
2372 | 2342 | | |
2373 | 2343 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
Lines changed: 53 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
119 | 146 | | |
120 | 147 | | |
121 | 148 | | |
| |||
149 | 176 | | |
150 | 177 | | |
151 | 178 | | |
| 179 | + | |
| 180 | + | |
152 | 181 | | |
153 | 182 | | |
154 | 183 | | |
| |||
163 | 192 | | |
164 | 193 | | |
165 | 194 | | |
| 195 | + | |
| 196 | + | |
166 | 197 | | |
167 | 198 | | |
168 | 199 | | |
| |||
181 | 212 | | |
182 | 213 | | |
183 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
184 | 219 | | |
185 | 220 | | |
186 | 221 | | |
| |||
209 | 244 | | |
210 | 245 | | |
211 | 246 | | |
212 | | - | |
213 | 247 | | |
214 | 248 | | |
215 | 249 | | |
216 | 250 | | |
217 | 251 | | |
218 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
219 | 259 | | |
220 | 260 | | |
221 | 261 | | |
| |||
234 | 274 | | |
235 | 275 | | |
236 | 276 | | |
237 | | - | |
| 277 | + | |
238 | 278 | | |
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
0 commit comments