def test_ceph_osd_tree_doc_examples():
    env = {
        'cot':
        CephOsdTree(None, None,
                    CephOsdTreeText(context_wrap(CEPH_OSD_TREE_TEXT)))
    }
    failed, total = doctest.testmod(ceph_osd_tree, globs=env)
    assert failed == 0
def test_ceph_insights():
    ci = CephInsights(context_wrap(CEPH_INSIGHTS))
    cott = CephOsdTreeText(context_wrap(CEPH_OSD_TREE_TEXT))
    ret = CephOsdTree(None, ci, cott)
    assert ret["nodes"][0] == {
        'children': [-3],
        'type_id': 10,
        'type': 'root',
        'id': -1,
        'name': 'default'
    }
def test_ceph_osd_tree_parser_2():
    cot = CephOsdTreeParser(context_wrap(CEPH_OSD_TREE))
    ci = CephInsights(context_wrap(CEPH_INSIGHTS))
    cott = CephOsdTreeText(context_wrap(CEPH_OSD_TREE_TEXT))
    ret = CephOsdTree(cot, ci, cott)
    assert ret["nodes"][0] == {
        'id': -1,
        'name': 'default',
        'type': 'root',
        'type_id': 10,
        'children': [-7, -3, -5, -9]
    }
Example #4
0
def test_ceph_osd_tree_text_v2():
    ceph_osd_tree = CephOsdTreeText(context_wrap(OSD_TREE_CEPH_V2))
    assert ceph_osd_tree['nodes'][1] == {
        'id': '-2',
        'crush_weight': '0.02917',
        'name': 'osd1',
        'status': '',
        'reweight': '',
        'primary_affinity': '',
        'type': 'host',
        'children': [5, 2]
    }
Example #5
0
def test_ceph_osd_tree_text_v3():
    ceph_osd_tree = CephOsdTreeText(context_wrap(OSD_TREE_CEPH_V3))
    assert ceph_osd_tree['nodes'][0] == {
        'id': '-1',
        'device_class': '',
        'crush_weight': '0.08752',
        'name': 'default',
        'status': '',
        'reweight': '',
        'primary_affinity': '',
        'type': 'root',
        'children': [-7, -3, -5, -9]
    }
def test_ceph_osd_tree_text():
    cott = CephOsdTreeText(context_wrap(CEPH_OSD_TREE_TEXT))
    ret = CephOsdTree(None, None, cott)
    assert ret["nodes"][0] == {
        'id': '-1',
        'device_class': '',
        'crush_weight': '0.08752',
        'name': 'default',
        'status': '',
        'reweight': '',
        'primary_affinity': '',
        'type': 'root',
        'children': [-7, -3, -5, -9]
    }
Example #7
0
def test_ceph_osd_tree_text_doc_examples():
    env = {
        'ceph_osd_tree_text': CephOsdTreeText(context_wrap(OSD_TREE_CEPH_V3)),
    }
    failed, total = doctest.testmod(ceph_osd_tree_text, globs=env)
    assert failed == 0
Example #8
0
def test_error_content():
    with pytest.raises(ParseException) as e:
        CephOsdTreeText(context_wrap(OSD_TREE_INVALID))
    assert "Wrong content in table" in str(e)
Example #9
0
def test_skip_content():
    with pytest.raises(SkipException) as e:
        CephOsdTreeText(context_wrap(OSD_TREE_EMPTY))
    assert "Empty content." in str(e)