From 0a93eddeb0122e94a117572088450f47e7100bf2 Mon Sep 17 00:00:00 2001 From: Stanislav Ochotnicky Date: Feb 16 2018 09:39:11 +0000 Subject: Add more logging around result creation This should help debug issues if needed --- diff --git a/resultsdb/__init__.py b/resultsdb/__init__.py index afc5e94..7892940 100644 --- a/resultsdb/__init__.py +++ b/resultsdb/__init__.py @@ -186,3 +186,5 @@ app.register_blueprint(api_v1, url_prefix="/api/v1.0") from resultsdb.controllers.api_v2 import api as api_v2 app.register_blueprint(api_v2, url_prefix="/api/v2.0") + +app.logger.debug("Finished ResultsDB initialization") diff --git a/resultsdb/controllers/api_v2.py b/resultsdb/controllers/api_v2.py index 9596494..732b06a 100644 --- a/resultsdb/controllers/api_v2.py +++ b/resultsdb/controllers/api_v2.py @@ -580,11 +580,13 @@ def create_result(): outcome = args['outcome'].strip().upper() if outcome not in RESULT_OUTCOME: + app.logger.warning("Invalid result outcome submitted: %s", outcome) return jsonify({'message': "outcome must be one of %r" % (RESULT_OUTCOME,)}), 400 if args['data']: invalid_keys = [key for key in args['data'].iterkeys() if ':' in key] if invalid_keys: + app.logger.warning("Colon not allowed in key name: %s", invalid_keys) return jsonify({'message': "Colon not allowed in key name: %r" % invalid_keys}), 400 # args[testcase] can be either string or object @@ -593,12 +595,15 @@ def create_result(): if isinstance(tc, basestring): tc = dict(name=args['testcase']) if not tc['name']: + app.logger.warning("Result submitted without valid testcase.name: %s", tc) return jsonify({'message': "testcase name not set"}), 400 elif isinstance(tc, dict) and 'name' not in tc: + app.logger.warning("Result submitted without testcase.name: %s", tc) return jsonify({'message': "testcase.name not set"}), 400 testcase = Testcase.query.filter_by(name=tc['name']).first() if not testcase: + app.logger.debug("Testcase %s does not exist yet. Creating", tc['name']) testcase = Testcase(name=tc['name']) testcase.ref_url = tc.get('ref_url', testcase.ref_url) db.session.add(testcase) @@ -660,8 +665,10 @@ def create_result(): db.session.commit() db.session.add(result) + app.logger.debug("Created new result for testcase %s with outcome %s", testcase.name, outcome) if app.config['MESSAGE_BUS_PUBLISH']: + app.logger.debug("Preparing to publish message for result id %d", result.id) prev_result = get_prev_result(result) # result is considered duplicate of prev_result when # outcomes are the same. @@ -671,6 +678,8 @@ def create_result(): kwargs=app.config['MESSAGE_BUS_KWARGS'], ) plugin.publish(plugin.create_message(result, prev_result)) + else: + app.logger.debug("Skipping messaging, result %d outcome has not changed", result.id) return jsonify(SERIALIZE(result)), 201 diff --git a/resultsdb/messaging.py b/resultsdb/messaging.py index b807c16..5ec453e 100644 --- a/resultsdb/messaging.py +++ b/resultsdb/messaging.py @@ -129,6 +129,7 @@ class StompPlugin(MessagingPlugin): conn.connect() try: conn.send(**kwargs) + log.debug("Published message through stomp: %s", msg) finally: conn.disconnect()