Esempio n. 1
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)

    # 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)
    }
Esempio n. 2
0
def test_lv_reload_error_one_stale(fake_devices, no_delay):
    fake_runner = FakeRunner(rc=5, err=b"Fake lvm error")
    lc = lvm.LVMCache(fake_runner)
    lc._lvs = {
        ("vg-name", "lv-name"): lvm.Stale("lv-name"),
        ("vg-name", "other-lv"): lvm.Stale("other-lv"),
    }
    lv = lc.getLv("vg-name", "lv-name")

    # Mark lv as unreadable. Because we always reload all lvs, the other lvs is
    # also marked as unreadable.
    assert lc._lvs == {
        ("vg-name", "lv-name"): lvm.Unreadable("lv-name"),
        ("vg-name", "other-lv"): lvm.Unreadable("other-lv"),
    }

    # Report the unreadbale lv.
    assert lv.name == "lv-name"
    assert isinstance(lv, lvm.Unreadable)
Esempio n. 3
0
def test_lv_reload_error_all_other_vg(fake_devices, no_delay):
    fake_runner = FakeRunner(rc=5, err=b"Fake lvm error")
    lc = lvm.LVMCache(fake_runner)
    lc._lvs = {("vg-name", "lv-name"): lvm.Stale("lv-name")}
    lvs = lc.getLv("vg-name")

    # Mark lv as unreadable.
    assert lc._lvs == {("vg-name", "lv-name"): lvm.Unreadable("lv-name")}

    # Currnetly we don't report stales or unreadables lvs. This is not
    # consistent with getLv(vg_name, lv_name).
    assert lvs == []
Esempio n. 4
0
def test_pv_stale_reload_one_stale(stale_pv):
    vg_name, good_pv_name, stale_pv_name = stale_pv

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

    # The good pv is still in the cache.
    pv = lvm.getPV(good_pv_name)
    assert pv.name == good_pv_name

    # Reloading the stale pv marks it as Unreadable.
    pv = lvm.getPV(stale_pv_name)
    assert pv == lvm.Unreadable(stale_pv_name)
Esempio n. 5
0
def test_pv_stale_reload_invalidated(stale_pv):
    vg_name, good_pv_name, stale_pv_name = stale_pv

    # Invalidate the good pv.
    lvm._lvminfo._invalidatepvs(good_pv_name)
    # Reloading the good pv returns it as valid.
    pv = lvm.getPV(good_pv_name)
    assert pv.name == good_pv_name

    # Invalidate the stale pv.
    lvm._lvminfo._invalidatepvs(stale_pv_name)
    # Reloading the stale pv returns it as Unreadable.
    pv = lvm.getPV(stale_pv_name)
    assert pv == lvm.Unreadable(stale_pv_name)