Exemplo n.º 1
0
def test_checks_errored():
    checker = MachineChecker({}, 'test-disk')
    r = checker.check()
    for c in r:
        if c.name != 'network' and c.name != 'disk':
            assert c.status == 'error', c.name
            assert c.info.startswith('KeyError'), c.name
Exemplo n.º 2
0
def test_checks_machine_check(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    result = checker.check()
    assert not all([r.status == 'ok' for r in result])

    checker = MachineChecker(server_req, 'test-disk')
    checker._get_disk_size = mock.Mock(return_value=float('inf'))
    result = checker.check()
    assert all([r.status == 'ok' for r in result])
    report = generate_report_from_result(result)
    assert report == [{
        'name': 'cpu-physical',
        'status': 'ok'
    }, {
        'name': 'cpu-total',
        'status': 'ok'
    }, {
        'name': 'disk',
        'status': 'ok'
    }, {
        'name': 'memory',
        'status': 'ok'
    }, {
        'name': 'network',
        'status': 'ok'
    }, {
        'name': 'swap',
        'status': 'ok'
    }]
Exemplo n.º 3
0
def test_checks_cpu_total(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.cpu_total()
    assert r.name == 'cpu-total'
    assert r.status == 'ok'
    server_req['cpu_total'] = 10000  # too big
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.cpu_total()
    assert r.name == 'cpu-total'
    assert r.status == 'failed'
    assert checker.cpu_total().status == 'failed'
Exemplo n.º 4
0
def test_checks_swap(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.swap()
    assert r.name == 'swap'
    assert r.status == 'ok'
    # too big
    server_req['swap'] = 10000000000000
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.swap()
    assert r.name == 'swap'
    assert r.status == 'failed'
Exemplo n.º 5
0
def test_checks_memory(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.memory()
    assert r.name == 'memory'
    assert r.status == 'ok'
    # too big
    server_req['memory'] = 10000000000000
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.memory()
    assert r.name == 'memory'
    assert r.status == 'failed'
Exemplo n.º 6
0
def test_checks_disk(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.disk()
    assert r.status == 'error'
    assert r.name == 'disk'

    checker = MachineChecker(server_req, 'test-disk')
    checker._get_disk_size = mock.Mock(return_value=float('inf'))
    r = checker.disk()
    assert r.status == 'ok'
    assert r.name == 'disk'

    checker = MachineChecker(server_req, 'test-disk')
    checker._get_disk_size = mock.Mock(return_value=50)
    r = checker.disk()
    assert r.status == 'failed'
    assert r.name == 'disk'
    assert r.info == 'Expected disk size 0.09 GB, actual 0.0 GB'
Exemplo n.º 7
0
def test_checks_network(server_req):
    checker = MachineChecker(server_req, 'test-disk')
    r = checker.network()
    assert r.status == 'ok'
    assert r.name == 'network'