示例#1
0
def stale_pv(tmp_storage):
    dev_size = 1 * 1024**3

    good_pv_name = tmp_storage.create_device(dev_size)
    stale_pv_name = tmp_storage.create_device(dev_size)
    vg_name = str(uuid.uuid4())

    lvm.set_read_only(False)

    # Create VG with 2 PVs.
    lvm.createVG(vg_name, [good_pv_name, stale_pv_name], "initial-tag", 128)

    # Reload the cache.
    pvs = sorted(pv.name for pv in lvm.getAllPVs())
    assert pvs == sorted([good_pv_name, stale_pv_name])

    # Simulate removal of the second PV on another host, leaving stale PV in
    # the cache.
    commands.run([
        "vgreduce",
        "--config", tmp_storage.lvm_config(),
        vg_name,
        stale_pv_name,
    ])
    commands.run([
        "pvremove",
        "--config", tmp_storage.lvm_config(),
        stale_pv_name,
    ])

    # We still report both devies.
    pvs = sorted(pv.name for pv in lvm.getAllPVs())
    assert pvs == sorted([good_pv_name, stale_pv_name])

    return vg_name, good_pv_name, stale_pv_name
示例#2
0
def test_retry_with_wider_filter(tmp_storage, read_only):
    lvm.set_read_only(read_only)

    # Force reload of the cache. The system does not know about any device at
    # this point.
    lvm.getAllPVs()

    # Create a device - this device in not the lvm cached filter yet.
    dev = tmp_storage.create_device(20 * GiB)

    # Creating VG requires read-write mode.
    lvm.set_read_only(False)

    # We run vgcreate with explicit devices argument, so the filter is correct
    # and it succeeds.
    vg_name = str(uuid.uuid4())
    lvm.createVG(vg_name, [dev], "initial-tag", 128)

    # Checking VG must work in both read-only and read-write modes.
    lvm.set_read_only(read_only)

    # The cached filter is stale at this point, and so is the vg metadata in
    # the cache. Running "vgs --select 'vg_name = vg-name'" will return no data
    # because of the stale filter, so we invalidate the filter and run it
    # again.

    vg = lvm.getVG(vg_name)
    assert vg.pv_name == (dev, )
示例#3
0
def test_pv_stale_reload_all_clear(stale_pv):
    vg_name, good_pv_name, stale_pv_name = stale_pv

    # Drop all cache.
    lvm.invalidateCache()

    # Report only the good pv.
    pv_names = [pv.name for pv in lvm.getAllPVs()]
    assert pv_names == [good_pv_name]
示例#4
0
def test_pv_stale_reload_all_stale(stale_pv):
    vg_name, good_pv_name, stale_pv_name = stale_pv

    # Invalidate VG and its PVs.
    lvm.invalidateVG(vg_name, invalidatePVs=True)

    # Report only the good pv.
    pv_names = [pv.name for pv in lvm.getAllPVs()]
    assert pv_names == [good_pv_name]
示例#5
0
def test_retry_with_wider_filter(tmp_storage):
    lvm.set_read_only(False)

    # Force reload of the cache. The system does not know about any device at
    # this point.
    lvm.getAllPVs()

    # Create a device - this device in not the lvm cached filter yet.
    dev = tmp_storage.create_device(20 * 1024**3)

    # We run vgcreate with explicit devices argument, so the filter is correct
    # and it succeeds.
    vg_name = str(uuid.uuid4())
    lvm.createVG(vg_name, [dev], "initial-tag", 128)

    # The cached filter is stale at this point, and so is the vg metadata in
    # the cache. Running "vgs vg-name" fails because of the stale filter, so we
    # invalidate the filter and run it again.

    vg = lvm.getVG(vg_name)
    assert vg.pv_name == (dev, )
示例#6
0
文件: lvm_test.py 项目: nirs/vdsm
def test_retry_with_wider_filter(tmp_storage):
    lvm.set_read_only(False)

    # Force reload of the cache. The system does not know about any device at
    # this point.
    lvm.getAllPVs()

    # Create a device - this device in not the lvm cached filter yet.
    dev = tmp_storage.create_device(20 * 1024**3)

    # We run vgcreate with explicit devices argument, so the filter is correct
    # and it succeeds.
    vg_name = str(uuid.uuid4())
    lvm.createVG(vg_name, [dev], "initial-tag", 128)

    # The cached filter is stale at this point, and so is the vg metadata in
    # the cache. Running "vgs vg-name" fails because of the stale filter, so we
    # invalidate the filter and run it again.

    vg = lvm.getVG(vg_name)
    assert vg.pv_name == (dev,)
示例#7
0
文件: lvm_test.py 项目: vjuranek/vdsm
def test_pv_stale_reload_all_stale(stale_pv):
    vg_name, good_pv_name, stale_pv_name = stale_pv

    # Invalidate VG and its PVs.
    lvm.invalidateVG(vg_name, invalidatePVs=True)

    # Reloading all PVs will return them as Unreadable due to missing
    # stale PV.
    assert set(lvm.getAllPVs()) == {
        lvm.Unreadable(good_pv_name),
        lvm.Unreadable(stale_pv_name)
    }
示例#8
0
文件: lvm_test.py 项目: vjuranek/vdsm
def test_retry_with_wider_filter(tmp_storage, read_only):
    lvm.set_read_only(read_only)

    # Force reload of the cache. The system does not know about any device at
    # this point.
    clear_stats()
    lvm.getAllPVs()
    check_stats(hits=0, misses=1)

    # Create a device - this device in not the lvm cached filter yet.
    dev = tmp_storage.create_device(20 * GiB)

    # Creating VG requires read-write mode.
    lvm.set_read_only(False)

    # We run vgcreate with explicit devices argument, so the filter is correct
    # and it succeeds.
    vg_name = str(uuid.uuid4())
    lvm.createVG(vg_name, [dev], "initial-tag", 128)

    # Calling getAllPVs() have cache miss since createVG invalidates the PVs.
    clear_stats()
    lvm.getAllPVs()
    check_stats(hits=0, misses=1)

    # Second call for getAllPVs() adds cache hit since the new PV was reloaded.
    lvm.getAllPVs()
    check_stats(hits=1, misses=1)

    # Checking VG must work in both read-only and read-write modes.
    lvm.set_read_only(read_only)

    # The cached filter is stale at this point, and so is the vg metadata in
    # the cache. Running "vgs vg-name" fails because of the stale filter, so we
    # invalidate the filter and run it again.
    vg = lvm.getVG(vg_name)
    assert vg.pv_name == (dev,)