Add a test for a broken config on startup
We currently log an exception and then exit, requiring operator intervention. Change-Id: I39f7a0fea7c59776d929718fb4116e62d23d25cc
This commit is contained in:
parent
936b1778f6
commit
b9c0d77c2b
@ -1326,14 +1326,14 @@ class ZuulTestCase(BaseTestCase):
|
|||||||
self.rpc = zuul.rpclistener.RPCListener(self.config, self.sched)
|
self.rpc = zuul.rpclistener.RPCListener(self.config, self.sched)
|
||||||
|
|
||||||
self.sched.start()
|
self.sched.start()
|
||||||
self.sched.reconfigure(self.config)
|
|
||||||
self.sched.resume()
|
|
||||||
self.webapp.start()
|
self.webapp.start()
|
||||||
self.rpc.start()
|
self.rpc.start()
|
||||||
self.launch_client.gearman.waitForServer()
|
self.launch_client.gearman.waitForServer()
|
||||||
|
|
||||||
self.addCleanup(self.shutdown)
|
self.addCleanup(self.shutdown)
|
||||||
|
|
||||||
|
self.sched.reconfigure(self.config)
|
||||||
|
self.sched.resume()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(ZuulTestCase, self).tearDown()
|
super(ZuulTestCase, self).tearDown()
|
||||||
self.assertFinalState()
|
self.assertFinalState()
|
||||||
|
17
tests/fixtures/config/broken/git/common-config/zuul.yaml
vendored
Normal file
17
tests/fixtures/config/broken/git/common-config/zuul.yaml
vendored
Normal 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
|
6
tests/fixtures/config/broken/main.yaml
vendored
Normal file
6
tests/fixtures/config/broken/main.yaml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- tenant:
|
||||||
|
name: tenant-one
|
||||||
|
source:
|
||||||
|
gerrit:
|
||||||
|
config-repos:
|
||||||
|
- common-config
|
@ -39,7 +39,11 @@ def handle_repo(path):
|
|||||||
if os.path.exists(os.path.join(path, fn)):
|
if os.path.exists(os.path.join(path, fn)):
|
||||||
config_path = os.path.join(path, fn)
|
config_path = os.path.join(path, fn)
|
||||||
break
|
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:
|
for block in config:
|
||||||
if 'job' not in block:
|
if 'job' not in block:
|
||||||
continue
|
continue
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
import zuul.configloader
|
||||||
from tests.base import AnsibleZuulTestCase, ZuulTestCase
|
from tests.base import AnsibleZuulTestCase, ZuulTestCase
|
||||||
|
|
||||||
|
|
||||||
@ -280,3 +283,19 @@ class TestAnsible(AnsibleZuulTestCase):
|
|||||||
bare_role_flag_path = os.path.join(self.test_root,
|
bare_role_flag_path = os.path.join(self.test_root,
|
||||||
build.uuid + '.bare-role.flag')
|
build.uuid + '.bare-role.flag')
|
||||||
self.assertTrue(os.path.exists(bare_role_flag_path))
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user