def run_rule_test(self):
        parser = argparse.ArgumentParser(description='Validate a rule configuration')
        parser.add_argument('file', metavar='rule', type=str, help='rule configuration filename')
        parser.add_argument('--schema-only', action='store_true', help='Show only schema errors; do not run query')
        parser.add_argument('--days', type=int, default=1, action='store', help='Query the previous N days with this rule')
        parser.add_argument('--data', type=str, metavar='FILENAME', action='store', dest='json', help='A JSON file containing data to run the rule against')
        parser.add_argument('--alert', action='store_true', help='Use actual alerts instead of debug output')
        parser.add_argument('--save-json', type=str, metavar='FILENAME', action='store', dest='save', help='A file to which documents from the last day or --days will be saved')
        parser.add_argument('--count-only', action='store_true', dest='count', help='Only display the number of documents matching the filter')
        args = parser.parse_args()

        with open(args.file) as fh:
            rule_yaml = yaml.load(fh)

        if args.json:
            with open(args.json, 'r') as data_file:
                self.data = simplejson.loads(data_file.read())
        else:
            hits = self.test_file(copy.deepcopy(rule_yaml), args)
            if hits and args.save:
                with open(args.save, 'wb') as data_file:
                    # Add _id to _source for dump
                    [doc['_source'].update({'_id': doc['_id']}) for doc in hits]
                    data_file.write(simplejson.dumps([doc['_source'] for doc in hits], indent='    '))
        if not args.schema_only and not args.count:
            self.run_elastalert(rule_yaml, args)
Process AMQP queue messages.
dataset/ETHPy150Open Yelp/elastalert/elastalert/test_rule.py/MockElastAlerter.run_rule_test--crossover with--dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/apps/saf/server/dfa_listen_dcnm.py/DCNMListener.process_amqp_msgs