def test_create_domain_metadata(tmp_storage, tmp_repo, fake_sanlock, domain_version): sd_uuid = str(uuid.uuid4()) domain_name = "loop-domain" dev1 = tmp_storage.create_device(10 * 1024**3) dev2 = tmp_storage.create_device(10 * 1024**3) lvm.createVG(sd_uuid, [dev1, dev2], blockSD.STORAGE_UNREADY_DOMAIN_TAG, 128) vg = lvm.getVG(sd_uuid) pv1 = lvm.getPV(dev1) pv2 = lvm.getPV(dev2) dom = blockSD.BlockStorageDomain.create(sdUUID=sd_uuid, domainName=domain_name, domClass=sd.DATA_DOMAIN, vgUUID=vg.uuid, version=domain_version, storageType=sd.ISCSI_DOMAIN, block_size=sc.BLOCK_SIZE_512, alignment=sc.ALIGNMENT_1M) sdCache.knownSDs[sd_uuid] = blockSD.findDomain sdCache.manuallyAddDomain(dom) lease = sd.DEFAULT_LEASE_PARAMS expected = { # Common storage domain values. sd.DMDK_CLASS: sd.DATA_DOMAIN, sd.DMDK_DESCRIPTION: domain_name, sd.DMDK_IO_OP_TIMEOUT_SEC: lease[sd.DMDK_IO_OP_TIMEOUT_SEC], sd.DMDK_LEASE_RETRIES: lease[sd.DMDK_LEASE_RETRIES], sd.DMDK_LEASE_TIME_SEC: lease[sd.DMDK_LEASE_TIME_SEC], sd.DMDK_LOCK_POLICY: "", sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC: lease[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC], sd.DMDK_POOLS: [], sd.DMDK_ROLE: sd.REGULAR_DOMAIN, sd.DMDK_SDUUID: sd_uuid, sd.DMDK_TYPE: sd.ISCSI_DOMAIN, sd.DMDK_VERSION: domain_version, # Block storge domain extra values. blockSD.DMDK_VGUUID: vg.uuid, # PV keys for blockSD.DMDK_PV_REGEX. "PV0": { 'guid': os.path.basename(dev1), 'mapoffset': '0', 'pecount': '77', 'pestart': '0', 'uuid': pv1.uuid, }, "PV1": { 'guid': os.path.basename(dev2), 'mapoffset': '77', 'pecount': '77', 'pestart': '0', 'uuid': pv2.uuid, }, } # In version 5 we removed LOGBLKSIZE and PHYBLKSIZE and added # ALIGNMENT and BLOCK_SIZE. if domain_version < 5: expected[sd.DMDK_LOGBLKSIZE] = sc.BLOCK_SIZE_512 expected[sd.DMDK_PHYBLKSIZE] = sc.BLOCK_SIZE_512 else: expected[sd.DMDK_ALIGNMENT] = sc.ALIGNMENT_1M expected[sd.DMDK_BLOCK_SIZE] = sc.BLOCK_SIZE_512 # Tests also alignment and block size properties here. assert dom.alignment == sc.ALIGNMENT_1M assert dom.block_size == sc.BLOCK_SIZE_512 actual = dom.getMetadata() assert expected == actual # Check that first PV is device where metadata is stored. assert dev1 == lvm.getVgMetadataPv(dom.sdUUID) lv = lvm.getLV(dom.sdUUID, sd.METADATA) assert int(lv.size) == blockSD.METADATA_LV_SIZE_MB * constants.MEGAB
def test_create_domain_metadata(tmp_storage, tmp_repo, fake_sanlock, domain_version): sd_uuid = str(uuid.uuid4()) domain_name = "loop-domain" dev1 = tmp_storage.create_device(10 * GiB) dev2 = tmp_storage.create_device(10 * GiB) lvm.createVG(sd_uuid, [dev1, dev2], blockSD.STORAGE_UNREADY_DOMAIN_TAG, 128) vg = lvm.getVG(sd_uuid) pv1 = lvm.getPV(dev1) pv2 = lvm.getPV(dev2) dom = blockSD.BlockStorageDomain.create( sdUUID=sd_uuid, domainName=domain_name, domClass=sd.DATA_DOMAIN, vgUUID=vg.uuid, version=domain_version, storageType=sd.ISCSI_DOMAIN) sdCache.knownSDs[sd_uuid] = blockSD.findDomain sdCache.manuallyAddDomain(dom) lease = sd.DEFAULT_LEASE_PARAMS expected = { # Common storage domain values. sd.DMDK_CLASS: sd.DATA_DOMAIN, sd.DMDK_DESCRIPTION: domain_name, sd.DMDK_IO_OP_TIMEOUT_SEC: lease[sd.DMDK_IO_OP_TIMEOUT_SEC], sd.DMDK_LEASE_RETRIES: lease[sd.DMDK_LEASE_RETRIES], sd.DMDK_LEASE_TIME_SEC: lease[sd.DMDK_LEASE_TIME_SEC], sd.DMDK_LOCK_POLICY: "", sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC: lease[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC], sd.DMDK_POOLS: [], sd.DMDK_ROLE: sd.REGULAR_DOMAIN, sd.DMDK_SDUUID: sd_uuid, sd.DMDK_TYPE: sd.ISCSI_DOMAIN, sd.DMDK_VERSION: domain_version, # Block storge domain extra values. blockSD.DMDK_VGUUID: vg.uuid, # PV keys for blockSD.DMDK_PV_REGEX. "PV0": { 'guid': os.path.basename(dev1), 'mapoffset': '0', 'pecount': '77', 'pestart': '0', 'uuid': pv1.uuid, }, "PV1": { 'guid': os.path.basename(dev2), 'mapoffset': '77', 'pecount': '77', 'pestart': '0', 'uuid': pv2.uuid, }, } # In version 5 we removed LOGBLKSIZE and PHYBLKSIZE and added # ALIGNMENT and BLOCK_SIZE. if domain_version < 5: expected[sd.DMDK_LOGBLKSIZE] = sc.BLOCK_SIZE_512 expected[sd.DMDK_PHYBLKSIZE] = sc.BLOCK_SIZE_512 else: expected[sd.DMDK_ALIGNMENT] = sc.ALIGNMENT_1M expected[sd.DMDK_BLOCK_SIZE] = sc.BLOCK_SIZE_512 # Tests also alignment and block size properties here. assert dom.alignment == sc.ALIGNMENT_1M assert dom.block_size == sc.BLOCK_SIZE_512 actual = dom.getMetadata() assert expected == actual # Check that first PV is device where metadata is stored. assert dev1 == lvm.getVgMetadataPv(dom.sdUUID) lv = lvm.getLV(dom.sdUUID, sd.METADATA) assert int(lv.size) == blockSD.METADATA_LV_SIZE_MB * MiB # Test the domain lease. lease = dom.getClusterLease() assert lease.name == "SDM" assert lease.path == "/dev/{}/leases".format(dom.sdUUID) assert lease.offset == dom.alignment resource = fake_sanlock.read_resource( lease.path, lease.offset, align=dom.alignment, sector=dom.block_size) assert resource == { "acquired": False, "align": dom.alignment, "lockspace": dom.sdUUID.encode("utf-8"), "resource": lease.name.encode("utf-8"), "sector": dom.block_size, "version": 0, } # Test special volumes sizes. for name in (sd.IDS, sd.INBOX, sd.OUTBOX, sd.METADATA): lv = lvm.getLV(dom.sdUUID, name) # This is the minimal LV size on block storage. assert int(lv.size) == 128 * MiB lv = lvm.getLV(dom.sdUUID, blockSD.MASTERLV) assert int(lv.size) == GiB lv = lvm.getLV(dom.sdUUID, sd.LEASES) assert int(lv.size) == sd.LEASES_SLOTS * dom.alignment if domain_version > 3: lv = lvm.getLV(dom.sdUUID, sd.XLEASES) assert int(lv.size) == sd.XLEASES_SLOTS * dom.alignment
def test_create_domain_metadata(tmp_storage, tmp_repo, domain_version): sd_uuid = str(uuid.uuid4()) domain_name = "loop-domain" dev1 = tmp_storage.create_device(10 * 1024**3) dev2 = tmp_storage.create_device(10 * 1024**3) lvm.createVG(sd_uuid, [dev1, dev2], blockSD.STORAGE_UNREADY_DOMAIN_TAG, 128) vg = lvm.getVG(sd_uuid) pv1 = lvm.getPV(dev1) pv2 = lvm.getPV(dev2) dom = blockSD.BlockStorageDomain.create(sdUUID=sd_uuid, domainName=domain_name, domClass=sd.DATA_DOMAIN, vgUUID=vg.uuid, version=domain_version, storageType=sd.ISCSI_DOMAIN, block_size=sc.BLOCK_SIZE_512, alignment=sc.ALIGNMENT_1M) lease = sd.DEFAULT_LEASE_PARAMS assert dom.getMetadata() == { # Common storge domain values. sd.DMDK_CLASS: sd.DATA_DOMAIN, sd.DMDK_DESCRIPTION: domain_name, sd.DMDK_IO_OP_TIMEOUT_SEC: lease[sd.DMDK_IO_OP_TIMEOUT_SEC], sd.DMDK_LEASE_RETRIES: lease[sd.DMDK_LEASE_RETRIES], sd.DMDK_LEASE_TIME_SEC: lease[sd.DMDK_LEASE_TIME_SEC], sd.DMDK_LOCK_POLICY: "", sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC: lease[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC], sd.DMDK_POOLS: [], sd.DMDK_ROLE: sd.REGULAR_DOMAIN, sd.DMDK_SDUUID: sd_uuid, sd.DMDK_TYPE: sd.ISCSI_DOMAIN, sd.DMDK_VERSION: domain_version, # Block storge domain extra values. blockSD.DMDK_VGUUID: vg.uuid, blockSD.DMDK_LOGBLKSIZE: sc.BLOCK_SIZE_512, blockSD.DMDK_PHYBLKSIZE: sc.BLOCK_SIZE_512, # PV keys for blockSD.DMDK_PV_REGEX. "PV0": { 'guid': os.path.basename(dev1), 'mapoffset': '0', 'pecount': '77', 'pestart': '0', 'uuid': pv1.uuid, }, "PV1": { 'guid': os.path.basename(dev2), 'mapoffset': '77', 'pecount': '77', 'pestart': '0', 'uuid': pv2.uuid, }, } # Check that first PV is device where metadata is stored. assert dev1 == lvm.getVgMetadataPv(dom.sdUUID) lv = lvm.getLV(dom.sdUUID, sd.METADATA) assert int(lv.size) == blockSD.METADATA_LV_SIZE_MB * constants.MEGAB
def test_create_domain_metadata(tmp_storage, tmp_repo, fake_sanlock, domain_version): sd_uuid = str(uuid.uuid4()) domain_name = "loop-domain" dev1 = tmp_storage.create_device(10 * 1024**3) dev2 = tmp_storage.create_device(10 * 1024**3) lvm.createVG(sd_uuid, [dev1, dev2], blockSD.STORAGE_UNREADY_DOMAIN_TAG, 128) vg = lvm.getVG(sd_uuid) pv1 = lvm.getPV(dev1) pv2 = lvm.getPV(dev2) dom = blockSD.BlockStorageDomain.create( sdUUID=sd_uuid, domainName=domain_name, domClass=sd.DATA_DOMAIN, vgUUID=vg.uuid, version=domain_version, storageType=sd.ISCSI_DOMAIN, block_size=sc.BLOCK_SIZE_512, alignment=sc.ALIGNMENT_1M) sdCache.knownSDs[sd_uuid] = blockSD.findDomain sdCache.manuallyAddDomain(dom) lease = sd.DEFAULT_LEASE_PARAMS expected = { # Common storage domain values. sd.DMDK_CLASS: sd.DATA_DOMAIN, sd.DMDK_DESCRIPTION: domain_name, sd.DMDK_IO_OP_TIMEOUT_SEC: lease[sd.DMDK_IO_OP_TIMEOUT_SEC], sd.DMDK_LEASE_RETRIES: lease[sd.DMDK_LEASE_RETRIES], sd.DMDK_LEASE_TIME_SEC: lease[sd.DMDK_LEASE_TIME_SEC], sd.DMDK_LOCK_POLICY: "", sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC: lease[sd.DMDK_LOCK_RENEWAL_INTERVAL_SEC], sd.DMDK_POOLS: [], sd.DMDK_ROLE: sd.REGULAR_DOMAIN, sd.DMDK_SDUUID: sd_uuid, sd.DMDK_TYPE: sd.ISCSI_DOMAIN, sd.DMDK_VERSION: domain_version, # Block storge domain extra values. blockSD.DMDK_VGUUID: vg.uuid, # PV keys for blockSD.DMDK_PV_REGEX. "PV0": { 'guid': os.path.basename(dev1), 'mapoffset': '0', 'pecount': '77', 'pestart': '0', 'uuid': pv1.uuid, }, "PV1": { 'guid': os.path.basename(dev2), 'mapoffset': '77', 'pecount': '77', 'pestart': '0', 'uuid': pv2.uuid, }, } # In version 5 we removed LOGBLKSIZE and PHYBLKSIZE and added # ALIGNMENT and BLOCK_SIZE. if domain_version < 5: expected[sd.DMDK_LOGBLKSIZE] = sc.BLOCK_SIZE_512 expected[sd.DMDK_PHYBLKSIZE] = sc.BLOCK_SIZE_512 else: expected[sd.DMDK_ALIGNMENT] = sc.ALIGNMENT_1M expected[sd.DMDK_BLOCK_SIZE] = sc.BLOCK_SIZE_512 actual = dom.getMetadata() assert expected == actual # Check that first PV is device where metadata is stored. assert dev1 == lvm.getVgMetadataPv(dom.sdUUID) lv = lvm.getLV(dom.sdUUID, sd.METADATA) assert int(lv.size) == blockSD.METADATA_LV_SIZE_MB * constants.MEGAB