def test_vdo_status_exp3():
    """
    Here test the examples cause expections
    """
    with pytest.raises(KeyError) as sc1:
        vdo = VDOStatus(context_wrap(INPUT_STATUS_SIMPLE))
        vdo.get_physical_blocks_of_vol('vdo3')
    assert "No key(s) named" in str(sc1)
Exemple #2
0
def test_vdo_status_exp2_0():
    """
    Here test the examples cause expections
    """
    with pytest.raises(ParseException) as sc1:
        vdo = VDOStatus(context_wrap(INPUT_STATUS_2))
        vdo.get_physical_blocks_of_vol('vdoapp1')
    assert "Not available device mapper path in" in str(sc1)
def test_vdo_status_exp():
    """
    Here test the examples cause expections
    """
    with pytest.raises(ParseException) as sc1:
        VDOStatus(context_wrap(INPUT_EXP))
    assert "couldn't parse yaml" in str(sc1)
def test_vdo_status_simple():
    vdo = VDOStatus(context_wrap(INPUT_STATUS_SIMPLE))
    assert vdo.data['VDO status'] == {'Date': '2019-07-27 04:40:40-04:00', 'Node': 'rdma-qe-04.lab.bos.redhat.com'}
    assert vdo.data['VDOs']['vdo1']['Activate'] == 'enabled'
    assert vdo.data['VDO status']['Date'] == '2019-07-27 04:40:40-04:00'
    assert vdo.data['VDO status']['Node'] == 'rdma-qe-04.lab.bos.redhat.com'

    assert vdo.get_slab_size_of_vol('vdo1') == '2G'
    assert vdo.volumns == ['vdo1', 'vdo2']

    assert vdo.get_physical_blocks_of_vol('vdo1') == 1572864
    assert vdo.get_overhead_used_of_vol('vdo1') == 728175
    assert vdo.get_physical_used_of_vol('vdo1') == 161863
    assert vdo.get_physical_free_of_vol('vdo1') == 682826

    assert vdo.get_logical_blocks_of_vol('vdo1') == 844568
    assert vdo.get_logical_used_of_vol('vdo1') == 844502
    assert vdo.get_logical_free_of_vol('vdo1') == 66
def test_vdo_status_documentation():
    """
    Here we test the examples in the documentation automatically using
    doctest.  We set up an environment which is similar to what a rule
    writer might see - a '/usr/bin/vdo status' command output that has
    been passed in as a parameter to the rule declaration.
    """
    env = {'vdo': VDOStatus(context_wrap(INPUT_STATUS_FULL))}
    failed, total = doctest.testmod(vdo_status, globs=env)
    assert failed == 0
def test_vdo_status_full():
    vdo = VDOStatus(context_wrap(INPUT_STATUS_FULL))
    assert vdo.data["VDO status"]["Date"] == "2019-07-24 20:48:16-04:00"
    assert vdo.data["VDO status"]["Node"] == "dell-m620-10.rhts.gsslab.pek2.redhat.com"

    assert vdo.data["Kernel module"]["Name"] == "kvdo"
    assert vdo.data["Kernel module"]["Version information"]["kvdo version"] == "6.1.0.153"

    assert vdo.data["Configuration"]["File"] == "/etc/vdoconf.yml"
    assert vdo.data["Configuration"]["Last modified"] == "2019-07-24 20:47:59"

    assert vdo.data["VDOs"]["vdo1"]["Acknowledgement threads"] == 1
    assert vdo.data["VDOs"]["vdo1"]["Device mapper status"] == "0 8370216 vdo /dev/sda3 albserver online cpu=2,bio=4,ack=1,bioRotationInterval=64"
    assert vdo.data["VDOs"]["vdo1"]["VDO statistics"]["/dev/mapper/vdo1"]["KVDO module bios used"] == 74572

    assert vdo.get_slab_size_of_vol('vdo1') == '2G'

    assert vdo.volumns == ['vdo1', 'vdo2']

    assert vdo.get_physical_blocks_of_vol('vdo1') == 1835008
    assert vdo.get_overhead_used_of_vol('vdo1') == 787140
    assert vdo.get_physical_used_of_vol('vdo1') == 0

    assert vdo.get_logical_blocks_of_vol('vdo1') == 1046277
    assert vdo.get_logical_used_of_vol('vdo1') == 0

    assert vdo.get_logical_free_of_vol('vdo1') == 1046277
    assert vdo.get_physical_free_of_vol('vdo1') == 1047868

    assert vdo.get_logical_used_of_vol('vdo2') == 3
    assert vdo.get_physical_used_of_vol('vdo2') == 1
def test_vdo_status_empty():
    vdo = VDOStatus(context_wrap(INPUT_EMPTY))
    assert vdo.data["VDOs"] == {}

    assert vdo.data["Configuration"]["File"] == "does not exist"
    assert vdo.data["Configuration"]["Last modified"] == "not available"
Exemple #8
0
def test_vdo_status2():
    vdo = VDOStatus(context_wrap(INPUT_STATUS_2))
    assert vdo.data['VDOs']['vdoapp1']['VDO statistics'] == 'not available'