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

Unified Diff: appengine/findit/model/flake/flake_swarming_task_result.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: 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/flake_swarming_task_result.py
diff --git a/appengine/findit/model/flake/flake_swarming_task_result.py b/appengine/findit/model/flake/flake_swarming_task_result.py
new file mode 100644
index 0000000000000000000000000000000000000000..a125097e0ebff2bb6664be04ecefed50de85504c
--- /dev/null
+++ b/appengine/findit/model/flake/flake_swarming_task_result.py
@@ -0,0 +1,80 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
chanli 2016/07/07 23:38:28 2014 -> 2016
caiw 2016/07/14 00:59:40 Done.
+# 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
+
+class FlakeSwarmingTaskResult(ndb.Model):
+ """Results of a swarming task for a single suspected flaky test.
+ """
+
+ @staticmethod
+ def CreateAnalysisId(master_name, builder_name,
+ step_name, build_number, testname): # pragma: no cover
chanli 2016/07/07 23:38:28 nit: I would use test_name instead of testname
caiw 2016/07/14 00:59:40 Done.
+ return '%s/%s/%s/%s/%s' % (master_name, builder_name,
+ step_name, build_number, testname)
+
+ @staticmethod
+ def _CreateKey(master_name, builder_name,
+ step_name, build_number, testname): # pragma: no cover
+ return ndb.Key('FlakeSwarmingTaskResult',
+ FlakeSwarmingTaskResult.CreateAnalysisId(
+ master_name, builder_name, step_name,
+ build_number, testname))
+
+ @staticmethod
+ def Create(master_name, builder_name,
+ step_name, build_number, testname): # pragma: no cover
+ return FlakeSwarmingTaskResult(key=FlakeSwarmingTaskResult._CreateKey(
+ master_name, builder_name, step_name, build_number, testname))
+
+ @staticmethod
+ def Get(master_name, builder_name,
+ step_name, build_number, testname): # pragma: no cover
+ return FlakeSwarmingTaskResult._CreateKey(
+ master_name, builder_name, step_name, build_number, testname).get()
+
+
+ @property
+ def completed(self):
+ return self.status in (
+ analysis_status.COMPLETED, analysis_status.ERROR)
+
+ @property
+ def failed(self):
+ return self.status == analysis_status.ERROR
+
+ @property
+ def status_description(self):
+ return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown')
+
+ @ndb.ComputedProperty
+ def master_name(self):
+ return self.key.pairs()[0][1].split('/')[0]
stgao 2016/07/08 22:51:27 As we discussed, some code here could be cleaned u
caiw 2016/07/14 00:59:40 Done.
+
+ @ndb.ComputedProperty
+ def builder_name(self):
+ return self.key.pairs()[0][1].split('/')[1]
+
+ @ndb.ComputedProperty
+ def step_name(self):
+ return self.key.pairs()[0][1].split('/')[2]
+
+ @ndb.ComputedProperty
+ def build_number(self):
+ return int(self.key.pairs()[0][1].split('/')[3])
+
+ @ndb.ComputedProperty
+ def test_name(self):
+ return self.key.pairs()[0][1].split('/')[4]
+
+
chanli 2016/07/07 23:38:28 Same here: please add comments.
caiw 2016/07/14 00:59:40 Done.
+ status = ndb.IntegerProperty(default=analysis_status.PENDING, indexed=False)
+ successes = ndb.IntegerProperty(default=0, indexed=False)
+ tries = ndb.IntegerProperty(default=0, indexed=False)
+ git_hash = ndb.StringProperty(indexed=False)
+ commit_position = ndb.IntegerProperty(indexed=False)
+ master_name = ndb.StringProperty(indexed=False)

Powered by Google App Engine
This is Rietveld 408576698