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

Unified Diff: appengine/findit/waterfall/flake/initialize_flake_pipeline.py

Issue 2130543004: Waterfall components of regression range finder. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: addressed comments, added trigger test which somehow wasn't included last time Created 4 years, 5 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
Index: appengine/findit/waterfall/flake/initialize_flake_pipeline.py
diff --git a/appengine/findit/waterfall/flake/initialize_flake_pipeline.py b/appengine/findit/waterfall/flake/initialize_flake_pipeline.py
new file mode 100644
index 0000000000000000000000000000000000000000..61301db78c136f81e7896e530c0e32cf1d0d8b6b
--- /dev/null
+++ b/appengine/findit/waterfall/flake/initialize_flake_pipeline.py
@@ -0,0 +1,81 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from datetime import datetime
+
+from google.appengine.ext import ndb
+
+from common import appengine_util
+from common import constants
+from model import analysis_status
+from model.flake.flake_swarming_task import FlakeSwarmingTask
+from model.flake.master_flake_analysis import MasterFlakeAnalysis
+from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline
+
+
+@ndb.transactional
+def NeedANewAnalysis(
+ master_name, builder_name, build_number, step_name, test_name):
+ """Checks status of analysis for the test and decides if a new one is needed.
+
+ A MasterFlakeAnalysis entity for the given build will be created if none
+ exists. When a new analysis is needed, this function will create and
+ save a MasterFlakeAnalysis entity to the datastore, or it will
+ reset the existing one but still keep the result of last analysis.
+
+ Returns:
+ True if an analysis is needed, otherwise False.
+ """
+ analysis = MasterFlakeAnalysis.Get(master_name, builder_name, build_number,
+ step_name, test_name)
+
+ if not analysis:
+ analysis = MasterFlakeAnalysis.Create(
+ master_name, builder_name, build_number, step_name, test_name)
+ analysis.status = analysis_status.PENDING
+ analysis.put()
+ return True
+ elif (analysis.status == analysis_status.COMPLETED or
+ analysis.status == analysis_status.PENDING or
+ analysis.status == analysis_status.RUNNING):
+ return False
+ else:
+ # TODO(caiw): Reset method.
+ MasterFlakeAnalysis.Get(
+ master_name, builder_name, build_number,
+ step_name, test_name).key.delete()
+ analysis = MasterFlakeAnalysis.Create(
+ master_name, builder_name, build_number, step_name, test_name)
+ analysis.status = analysis_status.PENDING
+ analysis.put()
+ return True
+
+# Unused arguments - pylint: disable=W0612, W0613
+def ScheduleAnalysisIfNeeded(master_name, builder_name, build_number, step_name,
+ test_name, force=False,
+ queue_name=constants.DEFAULT_QUEUE):
+ """Schedules an analysis if needed and returns the MasterFlakeAnalysis.
+
+ When the build failure was already analyzed and a new analysis is scheduled,
+ the returned WfAnalysis will still have the result of last completed analysis.
+
+ Args:
+ master_name (str): The master name of the failed test
+ builder_name (str): The builder name of the failed test
+ build_number (int): The build number of the failed test
+ step_name (str): The name of the test suite
+ test_name (str): The single test we are checking
+ Returns:
lijeffrey 2016/07/26 20:49:02 nit: empty line before Returns section
caiw 2016/07/26 21:09:01 Done.
+ A MasterFlakeAnalysis instance.
+ """
+ if NeedANewAnalysis(
+ master_name, builder_name, build_number, step_name, test_name):
+ pipeline_job = RecursiveFlakePipeline(
+ master_name, builder_name, build_number, step_name, test_name,
+ master_build_number=build_number)
+ pipeline_job.target = appengine_util.GetTargetNameForModule(
+ constants.WATERFALL_BACKEND)
+ pipeline_job.start(queue_name=queue_name)
+ return MasterFlakeAnalysis.Get(
+ master_name, builder_name, build_number, step_name, test_name)

Powered by Google App Engine
This is Rietveld 408576698