示例#1
0
    def test_lvm_numbering(self):
        input_model = InputModel(config=safe_load(lvm_disk_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        lv_devices = []
        lv_info = set()
        for lv_device in input_model._iter_volume_groups():
            lv_devices.append(DeviceInfo(lv_device))
            lv_info.add((lv_device.server_name, lv_device.ring_name,
                         lv_device.swift_drive_name))
        self.assertEqual(len(lv_devices), 11)

        # Do not change this without also examining test_drivedata.py
        lv_expected = [('padawan-ccp-c1-m1', 'object-0', 'lvm0'),
                       ('padawan-ccp-c1-m1', 'object-1', 'lvm0'),
                       ('padawan-ccp-c1-m1', 'object-2', 'lvm1'),
                       ('padawan-ccp-c1-m1', 'object-3', 'lvm1'),
                       ('padawan-ccp-c1-m1', 'object-4', 'lvm2'),
                       ('padawan-ccp-c1-m1', 'object-5', 'lvm2'),
                       ('padawan-ccp-c1-m1', 'object-6', 'lvm2'),
                       ('padawan-ccp-c1-m2', 'object-7', 'lvm0'),
                       ('padawan-ccp-c1-m2', 'object-8', 'lvm1'),
                       ('padawan-ccp-c1-m2', 'object-9', 'lvm3'),
                       ('padawan-ccp-c1-m2', 'object-10', 'lvm3')]
        for lv in set(lv_expected):
            self.assertTrue(lv in lv_info,
                            '%s missing from %s' % (lv, lv_info))
            lv_expected.remove(lv)
        self.assertEqual(0, len(lv_expected), 'still have %s' % lv_expected)
示例#2
0
    def test_iter_volume_groups(self):
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        lv_devices = []
        lv_expected = []
        for lv_device in input_model._iter_volume_groups():
            lv_devices.append(DeviceInfo(lv_device))
        self.assertEqual(len(lv_devices), 3)

        # This could be done with a simple assertEquals(), but this allowed
        # me to pin-point differences between actual and expected results
        for lv_device in expected_lv_devices:
            lv_expected.append(DeviceInfo(lv_device))
        lv_expected = sorted(lv_expected, None, DeviceInfo.sortkey)
        lv_devices = sorted(lv_devices, None, DeviceInfo.sortkey)
        for i in range(0, len(lv_expected)):
            self.assertEqual(sorted(lv_expected[i].keys()),
                             sorted(lv_devices[i].keys()))
            for key in lv_expected[i].keys():
                self.assertEqual(lv_expected[i].get(key),
                                 lv_devices[i].get(key))