Example #1
0
        def make_sample_data(available=available,
                             data_devices=10,
                             wal_devices=0,
                             db_devices=2):
            factory = InventoryFactory()
            inventory_sample = []
            data_disks = factory.produce(pieces=data_devices,
                                         available=available)
            wal_disks = factory.produce(pieces=wal_devices,
                                        human_readable_size='20.00 GB',
                                        rotational='0',
                                        model='ssd_type_model',
                                        available=available)
            db_disks = factory.produce(pieces=db_devices,
                                       human_readable_size='20.00 GB',
                                       rotational='0',
                                       model='ssd_type_model',
                                       available=available)
            inventory_sample.extend(data_disks)
            inventory_sample.extend(wal_disks)
            inventory_sample.extend(db_disks)

            self.disks_mock = patch('srv.salt._modules.dg.Inventory.disks',
                                    new_callable=PropertyMock,
                                    return_value=inventory_sample)
            self.disks_mock.start()

            inv = dg.Inventory()
            return inv.disks

            self.disks_mock.stop()
Example #2
0
 def test_inventory_raw(self):
     """ Check if c-v inv gets called
     """
     dg.__salt__ = {}
     dg.__salt__['helper.run'] = Mock()
     dg.__salt__['helper.run'].return_value = (1, "out", "err")
     dg.Inventory().raw
     call1 = call("ceph-volume inventory --format json")
     assert call1 in dg.__salt__['helper.run'].call_args_list
Example #3
0
 def test_disk_positive_test(self, disks_mock):
     disks_mock.return_value = InventoryFactory().produce(size=10000000000000)
     assert len(dg.Inventory().disks) == 1
Example #4
0
 def test_disk_exclude_small_size(self, disks_mock):
     disks_mock.return_value = InventoryFactory().produce(size=1)
     assert not dg.Inventory().disks
Example #5
0
 def test_disk_exclude_mapper_devices(self, disks_mock):
     disks_mock.return_value = InventoryFactory().produce(
         path='/dev/mapper/foo')
     assert not dg.Inventory().disks