Ejemplo n.º 1
0
 def test_json_report_valid_empty_unavailable_fast(self, format_, factory,
                                                   conf_ceph_stub,
                                                   mock_device_generator):
     # ensure json reports are valid when empty
     conf_ceph_stub('[global]\nfsid=asdf-lkjh')
     devs = [mock_device_generator() for _ in range(5)]
     fast_devs = [mock_device_generator()]
     fast_devs[0].available_lvm = False
     args = factory(
         data_slots=1,
         osds_per_device=1,
         osd_ids=[],
         report=True,
         format=format_,
         devices=devs,
         db_devices=fast_devs,
         wal_devices=[],
         bluestore=True,
         block_db_size="1G",
         dmcrypt=True,
         data_allocate_fraction=1.0,
     )
     b = batch.Batch([])
     plan = b.get_plan(args)
     b.args = args
     report = b._create_report(plan)
     json.loads(report)
Ejemplo n.º 2
0
 def test_batch_sort_mixed(self, factory, objectstore):
     device1 = factory(used_by_ceph=False,
                       available=True,
                       rotational=1,
                       abspath="/dev/sda")
     device2 = factory(used_by_ceph=False,
                       available=True,
                       rotational=1,
                       abspath="/dev/sdb")
     device3 = factory(used_by_ceph=False,
                       available=True,
                       rotational=0,
                       abspath="/dev/sdc")
     devices = [device1, device2, device3]
     args = factory(
         report=True,
         devices=devices,
         filestore=False if objectstore == 'bluestore' else True,
     )
     b = batch.Batch([])
     b.args = args
     b._sort_rotational_disks()
     assert len(b.args.devices) == 2
     if objectstore == 'bluestore':
         assert len(b.args.db_devices) == 1
     else:
         assert len(b.args.journal_devices) == 1
Ejemplo n.º 3
0
 def test_no_auto_prints_json_on_unavailable_device_and_report(
         self, factory, capsys):
     hdd1 = factory(
         used_by_ceph=False,
         abspath="/dev/sda",
         rotational=True,
         is_lvm_member=False,
         available=True,
     )
     ssd1 = factory(used_by_ceph=True,
                    abspath="/dev/nvme0n1",
                    rotational=False,
                    is_lvm_member=True,
                    available=False)
     captured = capsys.readouterr()
     args = factory(devices=[hdd1],
                    db_devices=[ssd1],
                    filtered_devices={},
                    yes=True,
                    format="json",
                    report=True)
     b = batch.Batch([])
     b.args = args
     with pytest.raises(SystemExit):
         b._filter_devices()
         result = json.loads(captured.out)
         assert not result["changed"]
Ejemplo n.º 4
0
 def test_no_auto_fails_on_unavailable_device(self, factory):
     hdd1 = factory(
         used_by_ceph=False,
         abspath="/dev/sda",
         rotational=True,
         is_lvm_member=False,
         available=True,
     )
     ssd1 = factory(used_by_ceph=True,
                    abspath="/dev/nvme0n1",
                    rotational=False,
                    is_lvm_member=True,
                    available=False)
     args = factory(devices=[hdd1],
                    db_devices=[ssd1],
                    filtered_devices={},
                    yes=True,
                    format="",
                    report=False)
     b = batch.Batch([])
     b.args = args
     with pytest.raises(RuntimeError) as ex:
         b._filter_devices()
         assert '1 devices were filtered in non-interactive mode, bailing out' in str(
             ex.value)
Ejemplo n.º 5
0
    def test_batch_fast_allocations_one_block_db_length(
            self, factory, conf_ceph_stub, mock_lv_device_generator):
        conf_ceph_stub('[global]\nfsid=asdf-lkjh')

        b = batch.Batch([])
        db_lv_devices = [mock_lv_device_generator()]
        fast = b.fast_allocations(db_lv_devices, 1, 0, 'block_db')
        assert len(fast) == 1
Ejemplo n.º 6
0
 def test_disjoint_device_lists(self, factory):
     device1 = factory(used_by_ceph=False, available=True, abspath="/dev/sda")
     device2 = factory(used_by_ceph=False, available=True, abspath="/dev/sdb")
     b = batch.Batch([])
     b.args.devices = [device1, device2]
     b.args.db_devices = [device2]
     b._filter_devices()
     with pytest.raises(Exception) as disjoint_ex:
         b._ensure_disjoint_device_lists()
     assert 'Device lists are not disjoint' in str(disjoint_ex.value)
Ejemplo n.º 7
0
 def test_batch_sort_full(self, factory, rota):
     device1 = factory(used_by_ceph=False, available=True, rotational=rota, abspath="/dev/sda")
     device2 = factory(used_by_ceph=False, available=True, rotational=rota, abspath="/dev/sdb")
     device3 = factory(used_by_ceph=False, available=True, rotational=rota, abspath="/dev/sdc")
     devices = [device1, device2, device3]
     args = factory(report=True,
                    devices=devices,
                    filestore=False,
                   )
     b = batch.Batch([])
     b.args = args
     b._sort_rotational_disks()
     assert len(b.args.devices) == 3
Ejemplo n.º 8
0
 def test_get_devices(self, monkeypatch):
     return_value = {
         '/dev/vdd': {
             'removable': '0',
             'vendor': '0x1af4',
             'model': '',
             'sas_address': '',
             'sas_device_handle': '',
             'sectors': 0,
             'size': 21474836480.0,
             'support_discard': '',
             'partitions': {
                 'vdd1': {
                     'start': '2048',
                     'sectors': '41940959',
                     'sectorsize': 512,
                     'size': '20.00 GB'
                 }
             },
             'rotational': '1',
             'scheduler_mode': 'mq-deadline',
             'sectorsize': '512',
             'human_readable_size': '20.00 GB',
             'path': '/dev/vdd'
         },
         '/dev/vdf': {
             'removable': '0',
             'vendor': '0x1af4',
             'model': '',
             'sas_address': '',
             'sas_device_handle': '',
             'sectors': 0,
             'size': 21474836480.0,
             'support_discard': '',
             'partitions': {},
             'rotational': '1',
             'scheduler_mode': 'mq-deadline',
             'sectorsize': '512',
             'human_readable_size': '20.00 GB',
             'path': '/dev/vdf'
         }
     }
     monkeypatch.setattr('ceph_volume.devices.lvm.batch.disk.get_devices',
                         lambda: return_value)
     b = batch.Batch([])
     result = b.get_devices().strip()
     assert result == '* /dev/vdf                  20.00 GB   rotational'
Ejemplo n.º 9
0
 def test_json_report(self, format_, factory, conf_ceph_stub, mock_device_generator):
     # just ensure reporting works
     conf_ceph_stub('[global]\nfsid=asdf-lkjh')
     devs = [mock_device_generator() for _ in range(5)]
     args = factory(data_slots=1,
                    osds_per_device=1,
                    osd_ids=[],
                    report=True,
                    format=format_,
                    devices=devs,
                    db_devices=[],
                    wal_devices=[],
                    bluestore=True,
                    block_db_size="1G",
                    dmcrypt=True,
                   )
     b = batch.Batch([])
     plan = b.get_plan(args)
     b.args = args
     b.report(plan)
Ejemplo n.º 10
0
 def test_json_report_valid_empty(self, format_, factory, conf_ceph_stub,
                                  mock_device_generator):
     # ensure json reports are valid when empty
     conf_ceph_stub('[global]\nfsid=asdf-lkjh')
     devs = []
     args = factory(
         data_slots=1,
         osds_per_device=1,
         osd_ids=[],
         report=True,
         format=format_,
         devices=devs,
         db_devices=[],
         wal_devices=[],
         bluestore=True,
         block_db_size="1G",
         dmcrypt=True,
     )
     b = batch.Batch([])
     plan = b.get_plan(args)
     b.args = args
     report = b._create_report(plan)
     json.loads(report)
Ejemplo n.º 11
0
 def test_invalid_osd_ids_passed(self):
     with pytest.raises(SystemExit):
         batch.Batch(argv=['--osd-ids', '1', 'foo']).main()
Ejemplo n.º 12
0
 def test_batch_instance(self, is_root):
     b = batch.Batch([])
     b.main()