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

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: added another init whoooo 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..9ffab76655aaeb27bc47c3767cd8f5e35eb6f2f7
--- /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 parameters will be created if none
+ exists. When a new analysis is needed, this function will create and
+ save a MasterFlakeAnalysis entity to the datastore.
+
+ Returns:
+ True if an analysis is needed, otherwise False.
+ """
+ master_flake_analysis = MasterFlakeAnalysis.Get(
+ master_name, builder_name, build_number,step_name, test_name)
+
+ if not master_flake_analysis:
+ master_flake_analysis = MasterFlakeAnalysis.Create(
+ master_name, builder_name, build_number, step_name, test_name)
+ master_flake_analysis.status = analysis_status.PENDING
+ master_flake_analysis.put()
+ return True
+ elif (master_flake_analysis.status == analysis_status.COMPLETED or
+ master_flake_analysis.status == analysis_status.PENDING or
+ master_flake_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()
+ master_flake_analysis = MasterFlakeAnalysis.Create(
+ master_name, builder_name, build_number, step_name, test_name)
+ master_flake_analysis.status = analysis_status.PENDING
+ master_flake_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:
+ 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)
« no previous file with comments | « appengine/findit/model/flake/test/__init__.py ('k') | appengine/findit/waterfall/flake/recursive_flake_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698