From 0b4b988d9fb63eaf44ce5cfa8e3ad2f7f0eb8604 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 23 Dec 2015 17:20:30 +0100 Subject: [PATCH] Basic validation for gerritbot/channels.yaml Recently a change merged that had not branches line and gerritbot refused to start again. This could have been avoided by validation of the file. Test some basic validation of the yaml file to avoid breakage. Change-Id: I2dc4a28aeac07d3fc73d3954d8fbe8f2448334e5 --- tools/irc_tests.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/irc_tests.py b/tools/irc_tests.py index c7a51c0060..3b3b336846 100755 --- a/tools/irc_tests.py +++ b/tools/irc_tests.py @@ -33,7 +33,27 @@ def access_gerrit_check(): gerrit_config = yaml.load(open('gerritbot/channels.yaml')) - print("Checking that all channels in gerritbot are also in accessbot") + print("Basic check of gerritbot/channels.yaml") + REQUIRED_ENTRIES=("branches", "events", "projects") + VALID_EVENTS=("change-merged", "patchset-created", "x-vrif-minus-2") + for channel in gerrit_config: + for entry in REQUIRED_ENTRIES: + if entry not in gerrit_config[channel]: + print(" Required entry '%s' not specified for channel '%s'" + % (entry, channel)) + errors = True + elif not gerrit_config[channel][entry]: + print(" Entry '%s' has no content for channel '%s'" + % (entry, channel)) + errors = True + + for event in gerrit_config[channel]['events']: + if event not in VALID_EVENTS: + print(" Event '%s' for channel '%s' is invalid" + % (event, channel)) + errors = True + + print("\nChecking that all channels in gerritbot are also in accessbot") for channel in gerrit_config: if channel not in access_channel_set: print(" %s is missing from accessbot" % channel)