gerrit: trim messages to "human length"
The "message" field of a gerrit response (i.e. the bit that has "Zuul encountered a syntax error while parsing its configuration ...") has a limit in Gerrit of "change.commentSizeLimit" which is by default 16KiB [1]. If you have a syntax error in a very long section, say the middle of the project: section of OpenDev system-config, you can actually overflow this length. Gerrit rejects the update and as an end-user you don't get any clue why. This truncates the message in the gerrit driver if it's going to overflow. [1] Note change.robotCommentSizeLimit is larger, but that's not how syntax messages are reported. Change-Id: I2f14e734ef5f9f203b14556c7d2c8ed1ad052319
This commit is contained in:
@@ -184,6 +184,28 @@ class TestGerritWeb(ZuulTestCase):
|
||||
'username': 'jenkins'}}
|
||||
)
|
||||
|
||||
def test_message_too_long(self):
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
- job:
|
||||
name: garbage-job
|
||||
%s
|
||||
garbage: True
|
||||
"""
|
||||
) % ('\n' * 16384)
|
||||
|
||||
file_dict = {'.zuul.yaml': in_repo_conf}
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
|
||||
files=file_dict)
|
||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertEqual(A.patchsets[0]['approvals'][0]['value'], "-1")
|
||||
self.assertEqual(A.patchsets[0]['approvals'][0]['__tag'],
|
||||
"autogenerated:zuul:check")
|
||||
self.assertIn('... (truncated)',
|
||||
A.messages[0])
|
||||
|
||||
def test_dependent_dynamic_line_comment(self):
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user