Merge "Add a test for a broken config on startup" into feature/zuulv3

This commit is contained in:
Jenkins 2017-03-10 15:31:54 +00:00 committed by Gerrit Code Review
commit 7c1fca2a8a
5 changed files with 50 additions and 4 deletions

View File

@ -1370,14 +1370,14 @@ class ZuulTestCase(BaseTestCase):
self.rpc = zuul.rpclistener.RPCListener(self.config, self.sched)
self.sched.start()
self.sched.reconfigure(self.config)
self.sched.resume()
self.webapp.start()
self.rpc.start()
self.launch_client.gearman.waitForServer()
self.addCleanup(self.shutdown)
self.sched.reconfigure(self.config)
self.sched.resume()
def tearDown(self):
super(ZuulTestCase, self).tearDown()
self.assertFinalState()

View File

@ -0,0 +1,17 @@
- pipeline:
name: check
manager: independent
source:
gerrit
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
verified: 1
failure:
gerrit:
verified: -1
- project:
error: true

View File

@ -0,0 +1,6 @@
- tenant:
name: tenant-one
source:
gerrit:
config-repos:
- common-config

View File

@ -39,7 +39,11 @@ def handle_repo(path):
if os.path.exists(os.path.join(path, fn)):
config_path = os.path.join(path, fn)
break
config = yaml.safe_load(open(config_path))
try:
config = yaml.safe_load(open(config_path))
except Exception:
print(" Has yaml errors")
return
for block in config:
if 'job' not in block:
continue

View File

@ -17,6 +17,9 @@
import os
import textwrap
import testtools
import zuul.configloader
from tests.base import AnsibleZuulTestCase, ZuulTestCase
@ -282,3 +285,19 @@ class TestAnsible(AnsibleZuulTestCase):
bare_role_flag_path = os.path.join(self.test_root,
build.uuid + '.bare-role.flag')
self.assertTrue(os.path.exists(bare_role_flag_path))
class TestBrokenConfig(ZuulTestCase):
# Test that we get an appropriate syntax error if we start with a
# broken config.
tenant_config_file = 'config/broken/main.yaml'
def setUp(self):
with testtools.ExpectedException(
zuul.configloader.ConfigurationSyntaxError,
"\nZuul encountered a syntax error"):
super(TestBrokenConfig, self).setUp()
def test_broken_config_on_startup(self):
pass