def perform_aggregation(self):
        message = TestMessage(process_name=self.process_name, uow_id=self.uow_id)
        self.aggregator._mq_callback(message)

        if self.generate_output:
            i = 0
            for key in self.aggregator.aggregated_objects:
                print(self.output_prefix + '_%02d = %s' % (i, self.aggregator.aggregated_objects[key].document))
                i += 1

        if self.compare_results:
            expected_values = base_fixtures.get_field_starting_with(self.output_prefix, self.output_module)
            if len(expected_values) == 0:
                assert 1 == 0
            for obj in expected_values:
                document = self.aggregator.aggregated_objects[self._get_key(obj)].document
                base_fixtures.compare_dictionaries(document, obj)
Example #2
0
from system.process_context import ProcessContext
from tests.base_fixtures import get_field_starting_with

def purge_mq_queue(mq_queue_name):
    conn = Connection()
    chan = conn.connection.channel()
    try:
        n = chan.queue_purge(mq_queue_name)
        print "Purged %s messages from %s queue" % (n, mq_queue_name)
    except Exception:
        print "Unable to purge %s" % mq_queue_name

    chan.close()
    conn.close()

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print "Usage 1 - to purge specific queue:\n\tpython purge_queue.py queue_name\n"
        print "Usage 2 - to purge all Synergy queues:\n\tpython purge_queue.py all\n"
        sys.exit(0)

    if sys.argv[1] == 'all':
        processes = get_field_starting_with('PROCESS_', process_context)
        for process_name in processes:
            mq_queue_name = ProcessContext.get_queue(process_name)
            purge_mq_queue(mq_queue_name)
    else:
        mq_queue_name = sys.argv[1]
        purge_mq_queue(mq_queue_name)