Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2848)

Unified Diff: appengine/findit/waterfall/identify_try_job_culprit_pipeline.py

Issue 1935193002: [Findit] Update try-job result in a transaction and fix bugs in unittests. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nit. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/findit/waterfall/monitor_try_job_pipeline.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/waterfall/identify_try_job_culprit_pipeline.py
diff --git a/appengine/findit/waterfall/identify_try_job_culprit_pipeline.py b/appengine/findit/waterfall/identify_try_job_culprit_pipeline.py
index 7e2f32eb9f03d34d1b21eb19c491fc17c35f5158..eac4f40a5f5d551037250c8bbcc79303c0dcbe07 100644
--- a/appengine/findit/waterfall/identify_try_job_culprit_pipeline.py
+++ b/appengine/findit/waterfall/identify_try_job_culprit_pipeline.py
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from google.appengine.ext import ndb
+
from common.git_repository import GitRepository
from common.http_client_appengine import HttpClientAppengine as HttpClient
from common.pipeline_wrapper import BasePipeline
@@ -258,19 +260,26 @@ class IdentifyTryJobCulpritPipeline(BasePipeline):
try_job_data.culprits = self._GetCulpritDataForTest(culprit_map)
try_job_data.put()
- # Store try job results.
- try_job_result = WfTryJob.Get(master_name, builder_name, build_number)
-
- if culprits:
- result_to_update = (
- try_job_result.compile_results if
- try_job_type == TryJobType.COMPILE else
- try_job_result.test_results)
- if (result_to_update and
- result_to_update[-1]['try_job_id'] == try_job_id):
- result_to_update[-1].update(result)
- else: # pragma: no cover
- result_to_update.append(result)
+ @ndb.transactional
+ def UpdateTryJobResult():
+ try_job_result = WfTryJob.Get(master_name, builder_name, build_number)
+ if culprits:
+ result_to_update = (
+ try_job_result.compile_results if
+ try_job_type == TryJobType.COMPILE else
+ try_job_result.test_results)
+ if (result_to_update and
+ result_to_update[-1]['try_job_id'] == try_job_id):
+ result_to_update[-1].update(result)
+ else: # pragma: no cover
+ result_to_update.append(result)
+ try_job_result.status = analysis_status.COMPLETED
+ try_job_result.put()
+
+ @ndb.transactional
+ def UpdateWfAnalysisWithTryJobResult():
+ if not culprits:
+ return
# Update analysis result and suspected CLs with results of this try job if
# culprits were found.
@@ -284,7 +293,9 @@ class IdentifyTryJobCulpritPipeline(BasePipeline):
analysis.suspected_cls = updated_suspected_cls
analysis.put()
- try_job_result.status = analysis_status.COMPLETED
- try_job_result.put()
+ # Store try-job results.
+ UpdateTryJobResult()
+ # Add try-job results to WfAnalysis.
+ UpdateWfAnalysisWithTryJobResult()
return result.get('culprit') if result else None
« no previous file with comments | « no previous file | appengine/findit/waterfall/monitor_try_job_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698