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

Unified Diff: appengine/findit/waterfall/test/suspected_cl_util_test.py

Issue 2230103002: [Findit] Pipeline change to save suspected cls to data store. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0808-resubmit-suspected_cl_model
Patch Set: Self review. Created 4 years, 3 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/test/suspected_cl_util_test.py
diff --git a/appengine/findit/waterfall/test/suspected_cl_util_test.py b/appengine/findit/waterfall/test/suspected_cl_util_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..becae2ae9ed660c69c0410e1b119987ded9168fc
--- /dev/null
+++ b/appengine/findit/waterfall/test/suspected_cl_util_test.py
@@ -0,0 +1,163 @@
+# 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 common.waterfall import failure_type
+from model import analysis_approach_type
+from model import suspected_cl_status
+from model.wf_suspected_cl import WfSuspectedCL
+from waterfall import suspected_cl_util
+from waterfall.test import wf_testcase
+
+
+class SuspectedCLUtilTest(wf_testcase.WaterfallTestCase):
+
+ def testCreateWfSuspectedCL(self):
+ approach = analysis_approach_type.HEURISTIC
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 123
+ compile_failure_type = failure_type.COMPILE
+ repo_name = 'chromium'
+ revision = 'r1'
+ commit_position = 1
+ failures = {'compile': []}
+ top_score = 5
+
+ self.assertIsNone(WfSuspectedCL.Get(repo_name, revision))
+
+ suspected_cl_util.UpdateSuspectedCL(
+ repo_name, revision, commit_position, approach, master_name,
+ builder_name, build_number, compile_failure_type, failures, top_score)
+
+ expected_builds = {
+ '%s/%s/%d' % (master_name, builder_name, build_number ):{
+ 'approach': approach,
+ 'failure_type': compile_failure_type,
+ 'failures': failures,
+ 'status': None,
+ 'top_score': top_score
+ }
+ }
+
+ suspected_cl = WfSuspectedCL.Get(repo_name, revision)
+
+ self.assertIsNotNone(suspected_cl)
+ self.assertEqual(analysis_approach_type.HEURISTIC, suspected_cl.approach)
+ self.assertEqual(compile_failure_type, suspected_cl.failure_type)
+ self.assertEqual(expected_builds, suspected_cl.builds)
+
+ def testUpdateWfSuspectedCLAddAnotherApproach(self):
+ approach = analysis_approach_type.TRY_JOB
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 122
+ test_failure_type = failure_type.TEST
+ repo_name = 'chromium'
+ revision = 'r2'
+ commit_position = 2
+ failures = {'step_1': ['test1', 'test2']}
+ top_score = None
+
+ suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
+ suspected_cl.approach = analysis_approach_type.HEURISTIC
+ suspected_cl.builds = {
+ '%s/%s/%d' % (master_name, builder_name, build_number ): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': failures,
+ 'status': None,
+ 'top_score': 4
+ }
+ }
+ suspected_cl.failure_type = test_failure_type
+ suspected_cl.put()
+
+ suspected_cl_util.UpdateSuspectedCL(
+ repo_name, revision, commit_position, approach, master_name,
+ builder_name, build_number, test_failure_type, failures, top_score)
+
+ expected_builds = {
+ '%s/%s/%d' % (master_name, builder_name, build_number ): {
+ 'approach': analysis_approach_type.BOTH,
+ 'failure_type': test_failure_type,
+ 'failures': failures,
+ 'status': None,
+ 'top_score': 4
+ }
+ }
+
+ suspected_cl = WfSuspectedCL.Get(repo_name, revision)
+
+ self.assertIsNotNone(suspected_cl)
+ self.assertEqual(analysis_approach_type.BOTH, suspected_cl.approach)
+ self.assertEqual(test_failure_type, suspected_cl.failure_type)
+ self.assertEqual(expected_builds, suspected_cl.builds)
+
+ def testUpdateWfSuspectedCLAddAnotherHeuristic(self):
+ approach = analysis_approach_type.HEURISTIC
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 122
+ test_failure_type = failure_type.TEST
+ repo_name = 'chromium'
+ revision = 'r2'
+ commit_position = 2
+ failures = {'step_1': ['test1', 'test2']}
+ top_score = 4
+
+ suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
+ suspected_cl.approach = analysis_approach_type.HEURISTIC
+ suspected_cl.builds = {
+ '%s/%s/%d' % (master_name, builder_name, build_number-1): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': {'step': ['test']},
+ 'status': suspected_cl_status.CORRECT,
+ 'top_score': 4
+ },
+ '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': failures,
+ 'status': suspected_cl_status.CORRECT,
+ 'top_score': 4
+ }
+ }
+ suspected_cl.failure_type = test_failure_type
+ suspected_cl.put()
+
+ suspected_cl_util.UpdateSuspectedCL(
+ repo_name, revision, commit_position, approach, master_name,
+ builder_name, build_number, test_failure_type, failures, top_score)
+
+ expected_builds = {
+ '%s/%s/%d' % (master_name, builder_name, build_number-1): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': {'step': ['test']},
+ 'status': suspected_cl_status.CORRECT,
+ 'top_score': 4
+ },
+ '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': failures,
+ 'status': suspected_cl_status.CORRECT,
+ 'top_score': 4
+ },
+ '%s/%s/%d' % (master_name, builder_name, build_number ): {
+ 'approach': analysis_approach_type.HEURISTIC,
+ 'failure_type': test_failure_type,
+ 'failures': failures,
+ 'status': suspected_cl_status.CORRECT,
+ 'top_score': 4
+ }
+ }
+
+ suspected_cl = WfSuspectedCL.Get(repo_name, revision)
+
+ self.assertIsNotNone(suspected_cl)
+ self.assertEqual(analysis_approach_type.HEURISTIC, suspected_cl.approach)
+ self.assertEqual(test_failure_type, suspected_cl.failure_type)
+ self.assertEqual(expected_builds, suspected_cl.builds)

Powered by Google App Engine
This is Rietveld 408576698