Exemplo n.º 1
0
 def test_get_trace_db_by_trigger_instance(self):
     trigger_instance = DummyComponent(
         id_=self.trace1.trigger_instances[0].object_id)
     trace_db = trace_service.get_trace_db_by_trigger_instance(
         trigger_instance=trigger_instance)
     self.assertEqual(trace_db.id, self.trace1.id,
                      'Incorrect trace_db returned.')
Exemplo n.º 2
0
    def _update_trace(self):
        """
        :rtype: ``dict`` trace_context as a dict; could be None
        """
        trace_db = None
        try:
            trace_db = trace_service.get_trace_db_by_trigger_instance(
                self.trigger_instance
            )
        except:
            LOG.exception(
                "No Trace found for TriggerInstance %s.", self.trigger_instance.id
            )
            return None

        # This would signify some sort of coding error so raise ValueError.
        if not trace_db:
            raise ValueError("Trace database not found.")

        trace_db = trace_service.add_or_update_given_trace_db(
            trace_db=trace_db,
            rules=[
                trace_service.get_trace_component_for_rule(
                    self.rule, self.trigger_instance
                )
            ],
        )
        return vars(TraceContext(id_=str(trace_db.id), trace_tag=trace_db.trace_tag))
Exemplo n.º 3
0
    def _update_trace(self):
        """
        :rtype: ``dict`` trace_context as a dict; could be None
        """
        trace_db = None
        try:
            trace_db = trace_service.get_trace_db_by_trigger_instance(self.trigger_instance)
        except:
            LOG.exception('No Trace found for TriggerInstance %s.', self.trigger_instance.id)
            return None

        # This would signify some sort of coding error so assert.
        assert trace_db

        trace_db = trace_service.add_or_update_given_trace_db(
            trace_db=trace_db,
            rules=[
                trace_service.get_trace_component_for_rule(self.rule, self.trigger_instance)
            ])
        return vars(TraceContext(id_=str(trace_db.id), trace_tag=trace_db.trace_tag))
Exemplo n.º 4
0
    def _update_trace(self):
        """
        :rtype: ``dict`` trace_context as a dict; could be None
        """
        trace_db = None
        try:
            trace_db = trace_service.get_trace_db_by_trigger_instance(
                self.trigger_instance)
        except:
            LOG.exception('No Trace found for TriggerInstance %s.',
                          self.trigger_instance.id)
            return None

        # This would signify some sort of coding error so assert.
        assert trace_db

        trace_db = trace_service.add_or_update_given_trace_db(
            trace_db=trace_db, rules=[str(self.rule.id)])
        return vars(
            TraceContext(id_=str(trace_db.id), trace_tag=trace_db.trace_tag))
Exemplo n.º 5
0
 def test_get_trace_db_by_trigger_instance(self):
     trigger_instance = DummyComponent(id_=self.trace1.trigger_instances[0].object_id)
     trace_db = trace_service.get_trace_db_by_trigger_instance(trigger_instance=trigger_instance)
     self.assertEqual(trace_db.id, self.trace1.id, 'Incorrect trace_db returned.')