blob: 684e850db6c263135f1a33d8b44f5fb969e7b335 [file] [log] [blame]
# Copyright 2021 The Fuchsia 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 recipe_engine.recipe_api import Property
PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"fuchsia/builder_state",
"fuchsia/gerrit_auto_submit",
"fuchsia/status_check",
"fuchsia/tree_status",
"recipe_engine/json",
"recipe_engine/properties",
]
PROPERTIES = {
"dry_run": Property(kind=bool, help="", default=False),
}
def RunSteps(api, dry_run):
api.gerrit_auto_submit(dry_run=dry_run)
def GenTests(api):
properties = api.gerrit_auto_submit.properties()
previous_state_retryable = {
"27cc4558b5a3d3387dd11ee2df7a117e7e581825": {
"last_action_time_secs": 1336913500,
"attempts": 1,
},
"27cc4558b5a3d3387dd11ee2df7a117e7e581822": {
"last_action_time_secs": 1336913700,
"attempts": 1,
},
}
yield (
api.status_check.test("state_retryable")
+ api.properties(**properties)
+ api.builder_state(previous_state_retryable)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.change_detail_messages(3)
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data()
+ api.gerrit_auto_submit.cq_success()
)
previous_state_attempts = {
"27cc4558b5a3d3387dd11ee2df7a117e7e581822": {
"last_action_time_secs": 1336913700,
"attempts": 5,
},
}
yield (
api.status_check.test("state_too_many_attempts")
+ api.properties(**properties)
+ api.builder_state(previous_state_attempts)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data()
)
yield (
api.status_check.test("state_too_many_attempts_comments")
+ api.properties(**properties)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.change_detail_messages(5)
)
# If the tree is closed we should wait to retry changes.
yield (
api.status_check.test("state_tree_closed")
+ api.properties(**properties)
+ api.builder_state(previous_state_retryable)
+ api.tree_status.get("closed")
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data()
)
yield (
api.status_check.test("no_changes")
+ api.properties(**properties)
+ api.step_data(
"get eligible.get changes for fuchsia-review.googlesource.com",
api.json.output(None),
)
)
yield (
api.status_check.test("changes_submitted_together")
+ api.properties(**properties)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data(
other_change_count=1
)
)
yield (
api.status_check.test("unmergeable")
+ api.properties(**properties)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data(mergeable=False)
)
yield (
api.status_check.test("unmergeable_nontrivial_merge_conflict")
+ api.properties(**properties)
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data(mergeable=False)
+ api.gerrit_auto_submit.rebase_test_data(success=False)
)
yield (
api.status_check.test("dry_run")
+ api.gerrit_auto_submit.changes_query_test_data()
+ api.gerrit_auto_submit.changes_submitted_together_test_data()
+ api.gerrit_auto_submit.mergeable_test_data()
+ api.properties(dry_run=True, **properties)
)
yield (
api.status_check.test("unresolved_comments")
+ api.gerrit_auto_submit.changes_query_test_data(unresolved_comment_count=1)
)