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

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

Issue 2586483003: [Findit] Adding build model for flake try jobs (Closed)
Patch Set: Fixing whitespace Created 4 years 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 | « appengine/findit/model/base_try_job.py ('k') | appengine/findit/model/flake/test/flake_try_job_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/model/flake/flake_try_job.py
diff --git a/appengine/findit/model/flake/flake_try_job.py b/appengine/findit/model/flake/flake_try_job.py
new file mode 100644
index 0000000000000000000000000000000000000000..0ffeac3d5df0b0be93c231cb58ce527208e40b00
--- /dev/null
+++ b/appengine/findit/model/flake/flake_try_job.py
@@ -0,0 +1,66 @@
+# Copyright 2015 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.
+
+import base64
+
+from google.appengine.ext import ndb
+
+from model.base_try_job import BaseTryJob
+
+
+class FlakeTryJob(BaseTryJob):
+ """Represents a try job results for a check flake try job."""
+ # A list of dict containing results and urls of each flake try job.
+ # For example:
+ # [
+ # {
+ # 'report': (dict) The 'result' dict of the try job,
+ # 'url': (str) The url to the try job,
+ # 'try_job_id': (str) The try job id.
+ # },
+ # ...
+ # ]
+ flake_results = ndb.JsonProperty(indexed=False, compressed=True)
+
+ @staticmethod
+ def _CreateTryJobId(master_name, builder_name, step_name, test_name,
+ git_hash): # pragma: no cover
+ """Creates an ID to associate with this try job.
+
+ Args:
+ master_name (str): The name of the master the flake was detected on.
+ builder_name (str): the name of the builder the flake was detected on.
+ step_name (str): The name of the step the flake was detected on.
+ test_name (str): The original name of the test that flaked. This will be
+ converted to base64 to avoid special characters in the test name
+ causing issues.
+ git_hash (str): The revision the try job will sync to and run against.
+
+ Returns:
+ The string ID to be associated with this try job.
+ """
+ encoded_test_name = base64.urlsafe_b64encode(test_name)
+ return '%s/%s/%s/%s/%s' % (
+ master_name, builder_name, step_name, encoded_test_name, git_hash)
+
+ @staticmethod
+ def _CreateKey(master_name, builder_name, step_name, test_name,
+ git_hash): # pragma: no cover
+ return ndb.Key(
+ 'FlakeTryJob', FlakeTryJob._CreateTryJobId(
+ master_name, builder_name, step_name, test_name, git_hash))
+
+ @staticmethod
+ def Create(master_name, builder_name, step_name, test_name, git_hash):
+ flake_try_job = FlakeTryJob(
+ key=FlakeTryJob._CreateKey(master_name, builder_name, step_name,
+ test_name, git_hash))
+ flake_try_job.flake_results = flake_try_job.flake_results or []
+ flake_try_job.try_job_ids = flake_try_job.try_job_ids or []
+ return flake_try_job
+
+ @staticmethod
+ def Get(master_name, builder_name, step_name, test_name, git_hash):
+ return FlakeTryJob._CreateKey(
+ master_name, builder_name, step_name, test_name, git_hash).get()
« no previous file with comments | « appengine/findit/model/base_try_job.py ('k') | appengine/findit/model/flake/test/flake_try_job_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698