]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/orchestrator_cli/test_orchestrator.py
update download target update for octopus release
[ceph.git] / ceph / src / pybind / mgr / orchestrator_cli / test_orchestrator.py
CommitLineData
11fdf7f2
TL
1from __future__ import absolute_import
2import pytest
3
4
5from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError, \
6 InventoryDevice, ReadCompletion, raise_if_exception
7
8
9def test_DriveGroup():
10 dg_json = {
11 'host_pattern': 'hostname',
12 'data_devices': {'paths': ['/dev/sda']}
13 }
14
15 dg = DriveGroupSpec.from_json(dg_json)
16 assert dg.hosts(['hostname']) == ['hostname']
17 assert dg.data_devices.paths == ['/dev/sda']
18
19
20def test_DriveGroup_fail():
21 with pytest.raises(TypeError):
22 DriveGroupSpec.from_json({})
23
24
25def test_drivegroup_pattern():
26 dg = DriveGroupSpec('node[1-3]', DeviceSelection())
27 assert dg.hosts(['node{}'.format(i) for i in range(10)]) == ['node1', 'node2', 'node3']
28
29
30def test_drive_selection():
31 devs = DeviceSelection(paths=['/dev/sda'])
32 spec = DriveGroupSpec('node_name', data_devices=devs)
33 assert spec.data_devices.paths == ['/dev/sda']
34
35 with pytest.raises(DriveGroupValidationError, match='exclusive'):
36 DeviceSelection(paths=['/dev/sda'], rotates=False)
37
38def test_inventory_device():
39 i_d = InventoryDevice()
40 s = i_d.pretty_print()
41 assert len(s)
42
43
44def test_raise():
45 c = ReadCompletion()
46 c.exception = ZeroDivisionError()
47 with pytest.raises(ZeroDivisionError):
48 raise_if_exception(c)