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

Unified Diff: appengine/findit/model/flake/master_flake_analysis.py

Issue 2124973003: These are the database objects used while finding the regression range. 1/3 (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Database objects post offline discussion 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/model/flake/master_flake_analysis.py
diff --git a/appengine/findit/model/flake/master_flake_analysis.py b/appengine/findit/model/flake/master_flake_analysis.py
new file mode 100644
index 0000000000000000000000000000000000000000..895e76477919876270f08afbe54a9d7afd84f0a9
--- /dev/null
+++ b/appengine/findit/model/flake/master_flake_analysis.py
@@ -0,0 +1,70 @@
+# 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 google.appengine.ext import ndb
+
+from common import constants
+from model import analysis_status
+from model.base_build_model import BaseBuildModel
+from model.base_analysis import BaseAnalysis
+from model.flake.flake_swarming_task import FlakeSwarmingTask
+
+class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel):
+ """Represents an analysis of a candidate flaky test in a Chromium Waterfall.
+
+ """
+ @staticmethod
+ def CreateAnalysisId(master_name, builder_name,
+ build_number, step_name, test_name):
+ return '%s/%s/%s/%s/%s' % (master_name, builder_name,
+ build_number, step_name, test_name)
+
+ @ndb.ComputedProperty
+ def step_name(self):
+ return self.key.pairs()[0][1].split('/')[3]
+
+ @ndb.ComputedProperty
+ def test_name(self):
+ return self.key.pairs()[0][1].split('/')[4]
+
+ @staticmethod
+ def _CreateKey(master_name, builder_name, build_number,
+ step_name, test_name): # pragma: no cover
+ return ndb.Key('MasterFlakeAnalysis',
+ MasterFlakeAnalysis.CreateAnalysisId(
+ master_name, builder_name, build_number,
+ step_name, test_name))
+
+ @staticmethod
+ def Create(master_name, builder_name, build_number,
+ step_name, test_name): # pragma: no cover
+ return MasterFlakeAnalysis(
+ key=MasterFlakeAnalysis._CreateKey(
+ master_name, builder_name, build_number,
+ step_name, test_name))
+
+ @staticmethod
+ def Get(master_name, builder_name, build_number,
+ step_name, test_name): # pragma: no cover
+ return MasterFlakeAnalysis._CreateKey(
+ master_name, builder_name, build_number, step_name, test_name).get()
+
+ @staticmethod
+ def generate_data(flake_swarming_tasks):
+ data = []
+ # Generates data in the format which the template can read
+ # Go through list of flake_swarming_tasks
+ for fst in flake_swarming_tasks:
+ # Append results to a list (this is a placeholder)
+ data.append((fst.successes, fst.tries,
+ fst.master_name(), fst.builder_name(),
+ fst.step_name(), fst.build_number(),
+ fst.test_name()))
+
+ # List of tested build_numbers and their corresponding success rates.
+ # We need to keep these sorted manually.
+ build_numbers = ndb.IntegerProperty(indexed=True, repeated=True)
+ success_rates = ndb.FloatProperty(indexed=False, repeated=True)
+ flake_swarming_tasks = ndb.KeyProperty(
+ kind='FlakeSwarmingTask', repeated=True)

Powered by Google App Engine
This is Rietveld 408576698