示例#1
0
def test_discover_no_exclusive():
    c = MockConfig(get_bad_config())
    with patch('intel.config.Config', MagicMock(return_value=c)):
        with pytest.raises(KeyError) as err:
            discover.add_node_oir()
        expected_msg = "Exclusive pool does not exist"
        assert err.value.args[0] == expected_msg
示例#2
0
def test_discover_oir_update_failure(caplog):
    c = MockConfig(get_fake_config())
    with patch('intel.config.Config', MagicMock(return_value=c)):
        fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body")
        fake_api_exception = K8sApiException(http_resp=fake_http_resp)
        with patch('intel.discover.patch_k8s_node_status',
                   MagicMock(side_effect=fake_api_exception)):
            with pytest.raises(SystemExit):
                discover.add_node_oir()
            exp_err = "Exception when patching node with OIR"
            exp_log_err = get_expected_log_error(exp_err)
            caplog_tuple = caplog.record_tuples
            assert caplog_tuple[0][2] == exp_log_err
示例#3
0
def test_discover_no_cldp():
    temp_dir = tempfile.mkdtemp()
    conf_dir = os.path.join(temp_dir, "discover")

    helpers.execute("cp",
                    ["-r", helpers.conf_dir("ok"), "{}".format(conf_dir)])
    helpers.execute(
        "rm",
        ["-r", "{}".format(os.path.join(conf_dir, "pools", "dataplane", "*"))])

    with pytest.raises(KeyError) as err:
        discover.add_node_oir(conf_dir)
    expected_msg = "No CPU list in dataplane pool"
    assert err.value.args[0] == expected_msg
示例#4
0
def test_discover_no_exclusive():
    temp_dir = tempfile.mkdtemp()
    conf_dir = os.path.join(temp_dir, "discover")

    helpers.execute("cp",
                    ["-r", helpers.conf_dir("ok"), "{}".format(conf_dir)])
    helpers.execute(
        "rm",
        ["-r", "{}".format(os.path.join(conf_dir, "pools", "exclusive"))])

    with pytest.raises(KeyError) as err:
        discover.add_node_oir(conf_dir)
    expected_msg = "Exclusive pool does not exist"
    assert err.value.args[0] == expected_msg
示例#5
0
def test_discover_oir_update_failure(caplog):
    temp_dir = tempfile.mkdtemp()
    conf_dir = os.path.join(temp_dir, "discover")

    helpers.execute("cp",
                    ["-r", helpers.conf_dir("ok"), "{}".format(conf_dir)])

    fake_http_resp = FakeHTTPResponse(500, "fake reason", "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    with patch('intel.discover.patch_k8s_node_status',
               MagicMock(side_effect=fake_api_exception)):
        with pytest.raises(SystemExit):
            discover.add_node_oir(conf_dir)
        exp_err = "Exception when patching node with OIR"
        exp_log_err = get_expected_log_error(exp_err)
        caplog_tuple = caplog.record_tuples
        assert caplog_tuple[0][2] == exp_log_err