Commit e868546a authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by LUCI CQ

tryserver: delete failure_hash support.

It was used by CQ a while ago, but since 2019, it had little if any
effect, and has since been deleted from CQ entirely.

Companion CL
https://chromium-review.googlesource.com/c/chromium/tools/build/+/2040484

R=jbudorick

Change-Id: Ia570bce4886fa60a3bf16e88919f3a230d48fbc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2040699Reviewed-by: 's avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@google.com>
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
parent 4d200f44
...@@ -795,37 +795,31 @@ Returns: ...@@ -795,37 +795,31 @@ Returns:
#### **class [TryserverApi](/recipes/recipe_modules/tryserver/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):** #### **class [TryserverApi](/recipes/recipe_modules/tryserver/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
&mdash; **def [add\_failure\_reason](/recipes/recipe_modules/tryserver/api.py#237)(self, reason):** &emsp; **@property**<br>&mdash; **def [gerrit\_change](/recipes/recipe_modules/tryserver/api.py#32)(self):**
Records a more detailed reason why build is failing.
The reason can be any JSON-serializable object.
&emsp; **@property**<br>&mdash; **def [gerrit\_change](/recipes/recipe_modules/tryserver/api.py#34)(self):**
Returns current gerrit change, if there is exactly one. Returns current gerrit change, if there is exactly one.
Returns a self.m.buildbucket.common_pb2.GerritChange or None. Returns a self.m.buildbucket.common_pb2.GerritChange or None.
&emsp; **@property**<br>&mdash; **def [gerrit\_change\_fetch\_ref](/recipes/recipe_modules/tryserver/api.py#98)(self):** &emsp; **@property**<br>&mdash; **def [gerrit\_change\_fetch\_ref](/recipes/recipe_modules/tryserver/api.py#96)(self):**
Returns gerrit patch ref, e.g. "refs/heads/45/12345/6, or None. Returns gerrit patch ref, e.g. "refs/heads/45/12345/6, or None.
Populated iff gerrit_change is populated. Populated iff gerrit_change is populated.
&emsp; **@property**<br>&mdash; **def [gerrit\_change\_repo\_url](/recipes/recipe_modules/tryserver/api.py#42)(self):** &emsp; **@property**<br>&mdash; **def [gerrit\_change\_repo\_url](/recipes/recipe_modules/tryserver/api.py#40)(self):**
Returns canonical URL of the gitiles repo of the current Gerrit CL. Returns canonical URL of the gitiles repo of the current Gerrit CL.
Populated iff gerrit_change is populated. Populated iff gerrit_change is populated.
&emsp; **@property**<br>&mdash; **def [gerrit\_change\_target\_ref](/recipes/recipe_modules/tryserver/api.py#107)(self):** &emsp; **@property**<br>&mdash; **def [gerrit\_change\_target\_ref](/recipes/recipe_modules/tryserver/api.py#105)(self):**
Returns gerrit change destination ref, e.g. "refs/heads/master". Returns gerrit change destination ref, e.g. "refs/heads/master".
Populated iff gerrit_change is populated. Populated iff gerrit_change is populated.
&mdash; **def [get\_files\_affected\_by\_patch](/recipes/recipe_modules/tryserver/api.py#137)(self, patch_root, \*\*kwargs):** &mdash; **def [get\_files\_affected\_by\_patch](/recipes/recipe_modules/tryserver/api.py#135)(self, patch_root, \*\*kwargs):**
Returns list of paths to files affected by the patch. Returns list of paths to files affected by the patch.
...@@ -835,52 +829,43 @@ Argument: ...@@ -835,52 +829,43 @@ Argument:
Returned paths will be relative to to patch_root. Returned paths will be relative to to patch_root.
&mdash; **def [get\_footer](/recipes/recipe_modules/tryserver/api.py#295)(self, tag, patch_text=None):** &mdash; **def [get\_footer](/recipes/recipe_modules/tryserver/api.py#255)(self, tag, patch_text=None):**
Gets a specific tag from a CL description Gets a specific tag from a CL description
&mdash; **def [get\_footers](/recipes/recipe_modules/tryserver/api.py#275)(self, patch_text=None):** &mdash; **def [get\_footers](/recipes/recipe_modules/tryserver/api.py#235)(self, patch_text=None):**
Retrieves footers from the patch description. Retrieves footers from the patch description.
footers are machine readable tags embedded in commit messages. See footers are machine readable tags embedded in commit messages. See
git-footers documentation for more information. git-footers documentation for more information.
&mdash; **def [initialize](/recipes/recipe_modules/tryserver/api.py#23)(self):** &mdash; **def [initialize](/recipes/recipe_modules/tryserver/api.py#21)(self):**
&emsp; **@property**<br>&mdash; **def [is\_gerrit\_issue](/recipes/recipe_modules/tryserver/api.py#121)(self):** &emsp; **@property**<br>&mdash; **def [is\_gerrit\_issue](/recipes/recipe_modules/tryserver/api.py#119)(self):**
Returns true iff the properties exist to match a Gerrit issue. Returns true iff the properties exist to match a Gerrit issue.
&emsp; **@property**<br>&mdash; **def [is\_patch\_in\_git](/recipes/recipe_modules/tryserver/api.py#131)(self):** &emsp; **@property**<br>&mdash; **def [is\_patch\_in\_git](/recipes/recipe_modules/tryserver/api.py#129)(self):**
&emsp; **@property**<br>&mdash; **def [is\_tryserver](/recipes/recipe_modules/tryserver/api.py#116)(self):** &emsp; **@property**<br>&mdash; **def [is\_tryserver](/recipes/recipe_modules/tryserver/api.py#114)(self):**
Returns true iff we have a change to check out. Returns true iff we have a change to check out.
&mdash; **def [normalize\_footer\_name](/recipes/recipe_modules/tryserver/api.py#299)(self, footer):** &mdash; **def [normalize\_footer\_name](/recipes/recipe_modules/tryserver/api.py#259)(self, footer):**
&mdash; **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#200)(self):** &mdash; **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#198)(self):**
Mark the tryjob result as a compile failure. Mark the tryjob result as a compile failure.
&mdash; **def [set\_do\_not\_retry\_build](/recipes/recipe_modules/tryserver/api.py#186)(self):** &mdash; **def [set\_do\_not\_retry\_build](/recipes/recipe_modules/tryserver/api.py#184)(self):**
A flag to indicate the build should not be retried by the CQ. A flag to indicate the build should not be retried by the CQ.
This mechanism is used to reduce CQ duration when retrying will likely This mechanism is used to reduce CQ duration when retrying will likely
return an identical result. return an identical result.
&emsp; **@contextlib.contextmanager**<br>&mdash; **def [set\_failure\_hash](/recipes/recipe_modules/tryserver/api.py#246)(self):** &mdash; **def [set\_invalid\_test\_results\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#210)(self):**
Context manager that sets a failure_hash build property on StepFailure.
This can be used to easily compare whether two builds have failed
for the same reason. For example, if a patch is bad (breaks something),
we'd expect it to always break in the same way. Different failures
for the same patch are usually a sign of flakiness.
&mdash; **def [set\_invalid\_test\_results\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#212)(self):**
Mark the tryjob result as having invalid test results. Mark the tryjob result as having invalid test results.
...@@ -888,32 +873,32 @@ This means we run some tests, but the results were not valid ...@@ -888,32 +873,32 @@ This means we run some tests, but the results were not valid
(e.g. no list of specific test cases that failed, or too many (e.g. no list of specific test cases that failed, or too many
tests failing, etc). tests failing, etc).
&mdash; **def [set\_patch\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#196)(self):** &mdash; **def [set\_patch\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#194)(self):**
Mark the tryjob result as failure to apply the patch. Mark the tryjob result as failure to apply the patch.
&mdash; **def [set\_subproject\_tag](/recipes/recipe_modules/tryserver/api.py#164)(self, subproject_tag):** &mdash; **def [set\_subproject\_tag](/recipes/recipe_modules/tryserver/api.py#162)(self, subproject_tag):**
Adds a subproject tag to the build. Adds a subproject tag to the build.
This can be used to distinguish between builds that execute different steps This can be used to distinguish between builds that execute different steps
depending on what was patched, e.g. blink vs. pure chromium patches. depending on what was patched, e.g. blink vs. pure chromium patches.
&mdash; **def [set\_test\_expired\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#229)(self):** &mdash; **def [set\_test\_expired\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#227)(self):**
Mark the tryjob result as a test expiration. Mark the tryjob result as a test expiration.
This means a test task expired and was never scheduled, most likely due to This means a test task expired and was never scheduled, most likely due to
lack of capacity. lack of capacity.
&mdash; **def [set\_test\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#204)(self):** &mdash; **def [set\_test\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#202)(self):**
Mark the tryjob result as a test failure. Mark the tryjob result as a test failure.
This means we started running actual tests (not prerequisite steps This means we started running actual tests (not prerequisite steps
like checkout or compile), and some of these tests have failed. like checkout or compile), and some of these tests have failed.
&mdash; **def [set\_test\_timeout\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#221)(self):** &mdash; **def [set\_test\_timeout\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#219)(self):**
Mark the tryjob result as a test timeout. Mark the tryjob result as a test timeout.
......
...@@ -11,8 +11,6 @@ from recipe_engine import recipe_api ...@@ -11,8 +11,6 @@ from recipe_engine import recipe_api
class TryserverApi(recipe_api.RecipeApi): class TryserverApi(recipe_api.RecipeApi):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(TryserverApi, self).__init__(*args, **kwargs) super(TryserverApi, self).__init__(*args, **kwargs)
self._failure_reasons = []
self._gerrit_change = None # self.m.buildbucket.common_pb2.GerritChange self._gerrit_change = None # self.m.buildbucket.common_pb2.GerritChange
self._gerrit_change_repo_url = None self._gerrit_change_repo_url = None
...@@ -234,44 +232,6 @@ class TryserverApi(recipe_api.RecipeApi): ...@@ -234,44 +232,6 @@ class TryserverApi(recipe_api.RecipeApi):
""" """
self._set_failure_type('TEST_EXPIRED') self._set_failure_type('TEST_EXPIRED')
def add_failure_reason(self, reason):
"""
Records a more detailed reason why build is failing.
The reason can be any JSON-serializable object.
"""
assert self.m.json.is_serializable(reason)
self._failure_reasons.append(reason)
@contextlib.contextmanager
def set_failure_hash(self):
"""
Context manager that sets a failure_hash build property on StepFailure.
This can be used to easily compare whether two builds have failed
for the same reason. For example, if a patch is bad (breaks something),
we'd expect it to always break in the same way. Different failures
for the same patch are usually a sign of flakiness.
"""
try:
yield
except self.m.step.StepFailure as e:
self.add_failure_reason(e.reason)
# TODO(iannucci): add API to set properties regardless of the current
# step.
try:
step_result = self.m.step.active_result
except ValueError:
step_result = None
if step_result:
failure_hash = hashlib.sha1()
failure_hash.update(self.m.json.dumps(self._failure_reasons))
step_result.presentation.properties['failure_hash'] = (
failure_hash.hexdigest())
raise e
def get_footers(self, patch_text=None): def get_footers(self, patch_text=None):
"""Retrieves footers from the patch description. """Retrieves footers from the patch description.
......
[
{
"failure": {
"failure": {},
"humanReason": "boom!"
},
"name": "$result"
}
]
\ No newline at end of file
...@@ -189,23 +189,6 @@ ...@@ -189,23 +189,6 @@
] ]
}, },
{ {
"cmd": [
"python",
"-u",
"import sys; sys.exit(1)"
],
"name": "fail",
"~followup_annotations": [
"@@@STEP_TEXT@foo@@@",
"@@@SET_BUILD_PROPERTY@failure_hash@\"622c0c52e65e6d0dc78957dd113ad343e57ae6d2\"@@@",
"@@@STEP_FAILURE@@@"
]
},
{
"failure": {
"failure": {},
"humanReason": "Step('fail') (retcode: 1)"
},
"name": "$result" "name": "$result"
} }
] ]
\ No newline at end of file
...@@ -189,23 +189,6 @@ ...@@ -189,23 +189,6 @@
] ]
}, },
{ {
"cmd": [
"python",
"-u",
"import sys; sys.exit(1)"
],
"name": "fail",
"~followup_annotations": [
"@@@STEP_TEXT@foo@@@",
"@@@SET_BUILD_PROPERTY@failure_hash@\"622c0c52e65e6d0dc78957dd113ad343e57ae6d2\"@@@",
"@@@STEP_FAILURE@@@"
]
},
{
"failure": {
"failure": {},
"humanReason": "Step('fail') (retcode: 1)"
},
"name": "$result" "name": "$result"
} }
] ]
\ No newline at end of file
...@@ -23,23 +23,6 @@ ...@@ -23,23 +23,6 @@
] ]
}, },
{ {
"cmd": [
"python",
"-u",
"import sys; sys.exit(1)"
],
"name": "fail",
"~followup_annotations": [
"@@@STEP_TEXT@foo@@@",
"@@@SET_BUILD_PROPERTY@failure_hash@\"622c0c52e65e6d0dc78957dd113ad343e57ae6d2\"@@@",
"@@@STEP_FAILURE@@@"
]
},
{
"failure": {
"failure": {},
"humanReason": "Step('fail') (retcode: 1)"
},
"name": "$result" "name": "$result"
} }
] ]
\ No newline at end of file
...@@ -24,23 +24,6 @@ ...@@ -24,23 +24,6 @@
] ]
}, },
{ {
"cmd": [
"python",
"-u",
"import sys; sys.exit(1)"
],
"name": "fail",
"~followup_annotations": [
"@@@STEP_TEXT@foo@@@",
"@@@SET_BUILD_PROPERTY@failure_hash@\"622c0c52e65e6d0dc78957dd113ad343e57ae6d2\"@@@",
"@@@STEP_FAILURE@@@"
]
},
{
"failure": {
"failure": {},
"humanReason": "Step('fail') (retcode: 1)"
},
"name": "$result" "name": "$result"
} }
] ]
\ No newline at end of file
...@@ -17,10 +17,6 @@ DEPS = [ ...@@ -17,10 +17,6 @@ DEPS = [
def RunSteps(api): def RunSteps(api):
if api.properties.get('set_failure_hash_with_no_steps'):
with api.tryserver.set_failure_hash():
raise api.step.StepFailure('boom!')
api.path['checkout'] = api.path['start_dir'] api.path['checkout'] = api.path['start_dir']
if api.properties.get('patch_text'): if api.properties.get('patch_text'):
api.step('patch_text test', [ api.step('patch_text test', [
...@@ -56,9 +52,6 @@ def RunSteps(api): ...@@ -56,9 +52,6 @@ def RunSteps(api):
api.tryserver.normalize_footer_name('Cr-Commit-Position') api.tryserver.normalize_footer_name('Cr-Commit-Position')
with api.tryserver.set_failure_hash():
api.python.failing_step('fail', 'foo')
def GenTests(api): def GenTests(api):
description_step = api.override_step_data( description_step = api.override_step_data(
...@@ -103,6 +96,3 @@ def GenTests(api): ...@@ -103,6 +96,3 @@ def GenTests(api):
'parse description (2)', 'parse description (2)',
api.json.output({'Foo': ['bar']})) api.json.output({'Foo': ['bar']}))
) )
yield (api.test('set_failure_hash_with_no_steps') +
api.properties(set_failure_hash_with_no_steps=True))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment