コード例 #1
0
def test_insights_evaluator_show_links():
    components = [
        hostname,
        Specs.redhat_release,
        Specs.machine_id,
        show_links,
    ]

    broker = dr.Broker()
    broker[Specs.hostname] = context_wrap("www.example.com")
    broker[Specs.machine_id] = context_wrap("12345")
    broker[Specs.redhat_release] = context_wrap(
        "Red Hat Enterprise Linux Server release 7.4 (Maipo)")

    e = InsightsEvaluator(broker)
    e.process(components)

    result = e.get_response()

    assert result["system"]["hostname"] == "www.example.com", result["system"][
        "hostname"]
    assert result["system"]["system_id"] == "12345"
    assert result["system"]["metadata"][
        "release"] == "Red Hat Enterprise Linux Server release 7.4 (Maipo)"

    rule_response = result["reports"][0]
    assert "kcs" in rule_response["links"]
コード例 #2
0
def test_insights_evaluator():
    broker = dr.Broker()
    e = InsightsEvaluator(broker)
    graph = dr.get_dependency_graph(report)
    result1 = e.process(graph)

    broker = dr.Broker()
    with InsightsEvaluator(broker) as e:
        dr.run(report, broker=broker)
        result2 = e.get_response()
        assert result1 == result2
コード例 #3
0
def test_insights_evaluator_attrs_incremental_process():
    broker = dr.Broker()
    broker[Specs.hostname] = context_wrap("www.example.com")
    broker[Specs.machine_id] = context_wrap("12345")
    broker[Specs.redhat_release] = context_wrap("Red Hat Enterprise Linux Server release 7.4 (Maipo)")
    e = InsightsEvaluator(broker)
    e.process(components)
    result = e.get_response()
    assert result["system"]["hostname"] == "www.example.com"
    assert result["system"]["system_id"] == "12345"
    assert result["system"]["metadata"]["release"] == "Red Hat Enterprise Linux Server release 7.4 (Maipo)"
コード例 #4
0
def test_insights_evaluator():
    broker = dr.Broker()
    e = InsightsEvaluator(broker)
    graph = dr.get_dependency_graph(report)
    result1 = e.process(graph)

    broker = dr.Broker()
    with InsightsEvaluator(broker) as e:
        dr.run(report, broker=broker)
        result2 = e.get_response()
        assert result1["reports"] == result2["reports"]
        for k in ["start", "finish", "execution_context", "plugin_sets"]:
            assert k in result1["analysis_metadata"]
            assert k in result2["analysis_metadata"]
コード例 #5
0
def test_insights_evaluator_make_unsure():
    broker = dr.Broker()
    broker[Specs.hostname] = context_wrap("www.example.com")
    broker[Specs.machine_id] = context_wrap("12345")
    broker[Specs.redhat_release] = context_wrap(
        "Red Hat Enterprise Linux Server release 7.4 (Maipo)")
    e = InsightsEvaluator(broker)
    e.process(components)
    result = e.get_response()
    assert result["system"]["hostname"] == "www.example.com"
    assert result["system"]["system_id"] == "12345"
    assert result["system"]["metadata"][
        "release"] == "Red Hat Enterprise Linux Server release 7.4 (Maipo)"
    assert len(result["unsure"]) == 1
    assert len([r["component"] for r in result["unsure"]]) == 1
    assert len([r["type"] for r in result["unsure"]]) == 1
    assert len([r["key"] for r in result["unsure"]]) == 1
コード例 #6
0
def create_evaluator(tmp_dir, system_id):
    from insights.core.hydration import create_context

    broker = dr.Broker()
    ctx = create_context(tmp_dir)
    broker[ctx.__class__] = ctx
    if system_id:
        return InsightsEvaluator(broker=broker, system_id=system_id)
    return SingleEvaluator(broker=broker)