예제 #1
0
def stale_vg(tmp_storage):
    dev_size = 1 * 1024**3
    dev1 = tmp_storage.create_device(dev_size)
    dev2 = tmp_storage.create_device(dev_size)

    good_vg_name = str(uuid.uuid4())
    stale_vg_name = str(uuid.uuid4())

    lvm.set_read_only(False)

    # Create 1 VGs
    lvm.createVG(good_vg_name, [dev1], "initial-tag", 128)
    lvm.createVG(stale_vg_name, [dev2], "initial-tag", 128)

    # Reload the cache.
    vgs = sorted(vg.name for vg in lvm.getAllVGs())
    assert vgs == sorted([good_vg_name, stale_vg_name])

    # Simulate removal of the second VG on another host, leaving stale VG in
    # the cache.
    commands.run([
        "vgremove",
        "--config", tmp_storage.lvm_config(),
        stale_vg_name,
    ])

    # We still report both vgs.
    vgs = sorted(vg.name for vg in lvm.getAllVGs())
    assert vgs == sorted([good_vg_name, stale_vg_name])

    return good_vg_name, stale_vg_name
예제 #2
0
def test_vg_stale_reload_all_clear(stale_vg):
    good_vg_name, stale_vg_name = stale_vg

    # Drop all cache.
    lvm.invalidateCache()

    clear_stats()
    # Report only the good vg.
    vgs = [vg.name for vg in lvm.getAllVGs()]
    assert vgs == [good_vg_name]
    check_stats(hits=0, misses=1)

    # Second call for getAllVGs() will add cache hit.
    lvm.getAllVGs()
    check_stats(hits=1, misses=1)
예제 #3
0
def test_vg_stale_reload_all_clear(stale_vg):
    good_vg_name, stale_vg_name = stale_vg

    # Drop all cache.
    lvm.invalidateCache()

    # Report only the good vg.
    vgs = [vg.name for vg in lvm.getAllVGs()]
    assert vgs == [good_vg_name]
예제 #4
0
def test_vg_stale_reload_all_stub(stale_vg):
    good_vg_name, stale_vg_name = stale_vg

    # Invalidate vgs.
    lvm.invalidateVG(good_vg_name)
    lvm.invalidateVG(stale_vg_name)

    # Report only the good vg.
    vgs = [vg.name for vg in lvm.getAllVGs()]
    assert vgs == [good_vg_name]