def test_single_evaluator():
    broker = dr.Broker()
    e = SingleEvaluator(broker)
    graph = dr.get_dependency_graph(report)
    result1 = e.process(graph)

    broker = dr.Broker()
    with SingleEvaluator(broker) as e:
        dr.run(report, broker=broker)
        result2 = e.get_response()
        assert result1 == result2
Exemple #2
0
def test_single_evaluator():
    broker = dr.Broker()
    e = SingleEvaluator(broker)
    graph = dr.get_dependency_graph(report)
    result1 = e.process(graph)

    broker = dr.Broker()
    with SingleEvaluator(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"]
Exemple #3
0
def hydrate_new_dir(path, broker=None):
    broker = broker or dr.Broker()
    for root, dirs, names in os.walk(path):
        for name in names:
            p = os.path.join(root, name)
            with open(p) as f:
                serde.hydrate(serde.ser.load(f), broker)
    return SingleEvaluator(broker=broker)
Exemple #4
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)
Exemple #5
0
class EvaluatorFormatter(Formatter):
    """
    Base class for formatters that want to serialize a SingleEvaluator after
    execution.
    """
    def __init__(self, args=None):
        if args:
            hn = "insights.combiners.hostname"
            args.plugins = ",".join([args.plugins, hn]) if args.plugins else hn

    def preprocess(self, broker):
        self.evaluator = SingleEvaluator(broker=broker)

    def postprocess(self, broker):
        self.evaluator.post_process()
        print(self.dump(self.evaluator.get_response()))

    def dump(self, data):
        raise NotImplemented("Subclasses must implement the dump method.")
Exemple #6
0
 def preprocess(self, broker):
     self.evaluator = SingleEvaluator(broker=broker)