Case sensitive label matching

After upgrading Gerrit to 2.13 our gate stopped working. The reason
for this is that after a successful gate run zuul does something like
'gerrit review --label verified=2 --submit'. The verified label in
Gerrit by default is configured as 'Verified'. The newer version of
gerrit behaves different now. It accepts the +2 vote on verified but
doesn't submit the patch anymore if the casing is not correct. This
forces us to specify the label in the same casing as gerrit
expects. In that case the tolower() in canMerge prevents the patch
from entering the gate.

In order to avoid confusion and be consistent, avoid any case
conversions and use the labels exactly as defined in Gerrit.

Note that this patch requires changes to the pipelines such that the
labels are spelled exactly as defined in Gerrit.

Change-Id: I9713a075e07b268e4f2620c0862c128158283c7c
This commit is contained in:
Tobias Henkel 2017-05-29 21:15:17 +02:00 committed by Tobias Henkel
parent 961bb1a876
commit ea98a194cc
80 changed files with 347 additions and 341 deletions

View File

@ -115,10 +115,10 @@ success, the pipeline reports back to Gerrit with a *Verified* vote of
- event: patchset-created
success:
my_gerrit:
verified: 1
Verified: 1
failure:
my_gerrit
verified: -1
Verified: -1
.. TODO: See TODO for more annotated examples of common pipeline configurations.
@ -255,9 +255,9 @@ optional unless otherwise specified):
to match. Same format as "older-than".
Any other field is interpreted as a review category and value
pair. For example ``verified: 1`` would require that the approval
pair. For example ``Verified: 1`` would require that the approval
be for a +1 vote in the "Verified" column. The value may either
be a single value or a list: ``verified: [1, 2]`` would match
be a single value or a list: ``Verified: [1, 2]`` would match
either a +1 or +2 vote.
**open**
@ -287,7 +287,7 @@ optional unless otherwise specified):
reject:
approval:
- code-review: [-1, -2]
- Code-Review: [-1, -2]
**dequeue-on-new-patchset**
Normally, if a new patchset is uploaded to a change that is in a

View File

@ -6,10 +6,10 @@ pipelines:
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- name: tests
manager: IndependentPipelineManager
@ -19,10 +19,10 @@ pipelines:
email_filter: ^.*@example.org$
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- name: post
manager: IndependentPipelineManager
@ -38,16 +38,16 @@ pipelines:
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
start:
gerrit:
verified: 0
Verified: 0
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
jobs:
- name: ^.*-merge$

View File

@ -133,9 +133,19 @@ class GerritChangeReference(git.Reference):
class FakeGerritChange(object):
categories = {'approved': ('Approved', -1, 1),
'code-review': ('Code-Review', -2, 2),
'verified': ('Verified', -2, 2)}
categories = {'Approved': ('Approved', -1, 1),
'Code-Review': ('Code-Review', -2, 2),
'Verified': ('Verified', -2, 2)}
# TODO(tobiash): This is used as a translation layer between the tests
# which use lower case labels. This can be removed if all
# tests are converted to use the correct casing.
categories_translation = {'approved': 'Approved',
'code-review': 'Code-Review',
'verified': 'Verified',
'Approved': 'Approved',
'Code-Review': 'Code-Review',
'Verified': 'Verified'}
def __init__(self, gerrit, number, project, branch, subject,
status='NEW', upstream_root=None, files={}):
@ -331,8 +341,8 @@ class FakeGerritChange(object):
if not granted_on:
granted_on = time.time()
approval = {
'description': self.categories[category][0],
'type': category,
'description': self.categories_translation[category],
'type': self.categories_translation[category],
'value': str(value),
'by': {
'username': username,
@ -341,7 +351,8 @@ class FakeGerritChange(object):
'grantedOn': int(granted_on)
}
for i, x in enumerate(self.patchsets[-1]['approvals'][:]):
if x['by']['username'] == username and x['type'] == category:
if x['by']['username'] == username and \
x['type'] == self.categories_translation[category]:
del self.patchsets[-1]['approvals'][i]
self.patchsets[-1]['approvals'].append(approval)
event = {'approvals': [approval],

View File

@ -7,10 +7,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -20,17 +20,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- secret:

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- project:
error: true

View File

@ -7,10 +7,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: data-return

View File

@ -6,17 +6,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -7,10 +7,10 @@
- event: change-restored
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: dup2
@ -21,10 +21,10 @@
- event: change-restored
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project-test1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project-test1

View File

@ -6,7 +6,7 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: tenant-one-gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- pipeline:
@ -39,17 +39,17 @@
gerrit:
- event: comment-added
approval:
- code-review: 2
- Code-Review: 2
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -7,10 +7,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- nodeset:
name: nodeset1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -6,7 +6,7 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: python27

View File

@ -6,17 +6,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- nodeset:

View File

@ -6,17 +6,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- nodeset:

View File

@ -7,10 +7,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -20,17 +20,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -7,10 +7,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: python27

View File

@ -6,10 +6,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
require:
gerrit:
approval:
@ -25,10 +25,10 @@
- email: jenkins@example.com
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -6,10 +6,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
require:
gerrit:
approval:
@ -27,10 +27,10 @@
newer-than: 48h
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -6,10 +6,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
require:
gerrit:
approval:
@ -27,10 +27,10 @@
older-than: 48h
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -10,10 +10,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: trigger
@ -25,10 +25,10 @@
- username: jenkins
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -5,13 +5,13 @@
gerrit:
approval:
- username: jenkins
verified:
Verified:
- 1
- 2
reject:
gerrit:
approval:
- verified:
- Verified:
- -1
- -2
trigger:
@ -19,10 +19,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: trigger
@ -32,19 +32,19 @@
- event: comment-added
require-approval:
- username: jenkins
verified:
Verified:
- 1
- 2
reject-approval:
- verified:
- Verified:
- -1
- -2
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -10,10 +10,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: open-check
@ -27,10 +27,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: status-check
@ -44,10 +44,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project-job

View File

@ -6,10 +6,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
require:
gerrit:
approval:
@ -25,10 +25,10 @@
- username: jenkins
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -5,16 +5,16 @@
gerrit:
approval:
- username: jenkins
verified: 1
Verified: 1
trigger:
gerrit:
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: trigger
@ -24,13 +24,13 @@
- event: comment-added
require-approval:
- username: jenkins
verified: 1
Verified: 1
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -5,7 +5,7 @@
gerrit:
approval:
- username: jenkins
verified:
Verified:
- 1
- 2
trigger:
@ -13,10 +13,10 @@
- event: comment-added
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: trigger
@ -26,15 +26,15 @@
- event: comment-added
require-approval:
- username: jenkins
verified:
Verified:
- 1
- 2
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project1-job

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: tenant-one-gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
# TODOv3(jeblair, tobiash): make semaphore definitions required, which
# will cause these tests to fail until we define test-semaphore

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project-test1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: base

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- pipeline:

View File

@ -6,7 +6,7 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1

View File

@ -6,12 +6,12 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
resultsdb:
score: 1
failure:
gerrit:
verified: -1
Verified: -1
resultsdb:
score: -1
resultsdb_failures:

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: python27

View File

@ -9,12 +9,12 @@
to: alternative_me@example.com
success:
gerrit:
verified: 1
Verified: 1
smtp:
to: alternative_me@example.com
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: docs-draft-test

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- pipeline:

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- job:
name: common-config-job

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
review_gerrit:
verified: 1
Verified: 1
failure:
review_gerrit:
verified: -1
Verified: -1
- pipeline:
name: another_check
@ -19,10 +19,10 @@
- event: patchset-created
success:
another_gerrit:
verified: 1
Verified: 1
failure:
another_gerrit:
verified: -1
Verified: -1
- pipeline:
name: common_check
@ -34,14 +34,14 @@
- event: patchset-created
success:
review_gerrit:
verified: 1
Verified: 1
another_gerrit:
verified: 1
Verified: 1
failure:
review_gerrit:
verified: -1
Verified: -1
another_gerrit:
verified: -1
Verified: -1
- job:
name: project-test1

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
review_gerrit:
verified: 1
Verified: 1
failure:
alt_voting_gerrit:
verified: -1
Verified: -1
- job:
name: project-test1

View File

@ -4,7 +4,7 @@
require:
gerrit:
approval:
- verified: -1
- Verified: -1
trigger:
gerrit:
- event: patchset-created
@ -13,10 +13,10 @@
pipeline: gate
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -24,25 +24,25 @@
require:
gerrit:
approval:
- verified: 1
- Verified: 1
trigger:
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
zuul:
- event: parent-change-enqueued
pipeline: gate
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- job:

View File

@ -6,10 +6,10 @@
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1
- pipeline:
name: gate
@ -19,17 +19,17 @@
gerrit:
- event: comment-added
approval:
- approved: 1
- Approved: 1
success:
gerrit:
verified: 2
Verified: 2
submit: true
failure:
gerrit:
verified: -2
Verified: -2
start:
gerrit:
verified: 0
Verified: 0
precedence: high
- pipeline:
@ -41,7 +41,7 @@
- event: project-change-merged
merge-failure:
gerrit:
verified: -1
Verified: -1
- job:
name: project-check

View File

@ -6,10 +6,10 @@ pipelines:
- event: patchset-created
success:
gerrit:
verified: 1
Verified: 1
failure:
gerrit:
verified: -1
Verified: -1