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

Side by Side 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: rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from common.waterfall import failure_type
6 from model import analysis_approach_type
7 from model import suspected_cl_status
8 from model.wf_suspected_cl import WfSuspectedCL
9 from waterfall import suspected_cl_util
10 from waterfall.test import wf_testcase
11
12
13 class SuspectedCLUtilTest(wf_testcase.WaterfallTestCase):
14
15 def testCreateWfSuspectedCL(self):
16 approach = analysis_approach_type.HEURISTIC
17 master_name = 'm'
18 builder_name = 'b'
19 build_number = 123
20 compile_failure_type = failure_type.COMPILE
21 repo_name = 'chromium'
22 revision = 'r1'
23 commit_position = 1
24 failures = {'compile': []}
25 top_score = 5
26
27 self.assertIsNone(WfSuspectedCL.Get(repo_name, revision))
28
29 suspected_cl_util.UpdateSuspectedCL(
30 repo_name, revision, commit_position, approach, master_name,
31 builder_name, build_number, compile_failure_type, failures, top_score)
32
33 expected_builds = {
34 '%s/%s/%d' % (master_name, builder_name, build_number ):{
35 'approaches': [approach],
36 'failure_type': compile_failure_type,
37 'failures': failures,
38 'status': None,
39 'top_score': top_score
40 }
41 }
42
43 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
44
45 self.assertIsNotNone(suspected_cl)
46 self.assertEqual(
47 [analysis_approach_type.HEURISTIC], suspected_cl.approaches)
48 self.assertEqual([compile_failure_type], suspected_cl.failure_type)
49 self.assertEqual(expected_builds, suspected_cl.builds)
50
51 def testUpdateWfSuspectedCLAddAnotherApproach(self):
52 approach = analysis_approach_type.TRY_JOB
53 master_name = 'm'
54 builder_name = 'b'
55 build_number = 122
56 test_failure_type = failure_type.TEST
57 repo_name = 'chromium'
58 revision = 'r2'
59 commit_position = 2
60 failures = {'step_1': ['test1', 'test2']}
61 top_score = None
62
63 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
64 suspected_cl.approaches = [analysis_approach_type.HEURISTIC]
65 suspected_cl.builds = {
66 '%s/%s/%d' % (master_name, builder_name, build_number ): {
67 'approaches': [analysis_approach_type.HEURISTIC],
68 'failure_type': test_failure_type,
69 'failures': failures,
70 'status': None,
71 'top_score': 4
72 }
73 }
74 suspected_cl.failure_type = [test_failure_type]
75 suspected_cl.put()
76
77 suspected_cl_util.UpdateSuspectedCL(
78 repo_name, revision, commit_position, approach, master_name,
79 builder_name, build_number, test_failure_type, failures, top_score)
80
81 expected_builds = {
82 '%s/%s/%d' % (master_name, builder_name, build_number ): {
83 'approaches': [
84 analysis_approach_type.HEURISTIC,
85 analysis_approach_type.TRY_JOB],
86 'failure_type': test_failure_type,
87 'failures': failures,
88 'status': None,
89 'top_score': 4
90 }
91 }
92
93 expected_approaches = [
94 analysis_approach_type.HEURISTIC,
95 analysis_approach_type.TRY_JOB]
96
97 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
98
99 self.assertIsNotNone(suspected_cl)
100 self.assertEqual(expected_approaches, suspected_cl.approaches)
101 self.assertEqual([test_failure_type], suspected_cl.failure_type)
102 self.assertEqual(expected_builds, suspected_cl.builds)
103
104 def testUpdateWfSuspectedCLAddAnotherHeuristic(self):
105 approach = analysis_approach_type.HEURISTIC
106 master_name = 'm'
107 builder_name = 'b'
108 build_number = 122
109 test_failure_type = failure_type.TEST
110 repo_name = 'chromium'
111 revision = 'r2'
112 commit_position = 2
113 failures = {'step_1': ['test1', 'test2']}
114 top_score = 4
115
116 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
117 suspected_cl.approaches = [analysis_approach_type.HEURISTIC]
118 suspected_cl.builds = {
119 '%s/%s/%d' % (master_name, builder_name, build_number-1): {
120 'approaches': [analysis_approach_type.HEURISTIC],
121 'failure_type': test_failure_type,
122 'failures': {'step': ['test']},
123 'status': suspected_cl_status.CORRECT,
124 'top_score': 4
125 },
126 '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
127 'approaches': [analysis_approach_type.HEURISTIC],
128 'failure_type': test_failure_type,
129 'failures': failures,
130 'status': suspected_cl_status.CORRECT,
131 'top_score': 4
132 }
133 }
134 suspected_cl.failure_type = [test_failure_type]
135 suspected_cl.put()
136
137 suspected_cl_util.UpdateSuspectedCL(
138 repo_name, revision, commit_position, approach, master_name,
139 builder_name, build_number, test_failure_type, failures, top_score)
140
141 expected_builds = {
142 '%s/%s/%d' % (master_name, builder_name, build_number-1): {
143 'approaches': [analysis_approach_type.HEURISTIC],
144 'failure_type': test_failure_type,
145 'failures': {'step': ['test']},
146 'status': suspected_cl_status.CORRECT,
147 'top_score': 4
148 },
149 '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
150 'approaches': [analysis_approach_type.HEURISTIC],
151 'failure_type': test_failure_type,
152 'failures': failures,
153 'status': suspected_cl_status.CORRECT,
154 'top_score': 4
155 },
156 '%s/%s/%d' % (master_name, builder_name, build_number ): {
157 'approaches': [analysis_approach_type.HEURISTIC],
158 'failure_type': test_failure_type,
159 'failures': failures,
160 'status': suspected_cl_status.CORRECT,
161 'top_score': 4
162 }
163 }
164
165 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
166
167 self.assertIsNotNone(suspected_cl)
168 self.assertEqual(
169 [analysis_approach_type.HEURISTIC], suspected_cl.approaches)
170 self.assertEqual([test_failure_type], suspected_cl.failure_type)
171 self.assertEqual(expected_builds, suspected_cl.builds)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698