Add test with unresolvable static node

Before the pre-registration change the static driver was broken if a
node was not resolvable. This was caused by a not catched
exception. This is not a problem anymore since the pre-registration
change. However we should add this as a test case so it cannot break
in future.

Change-Id: I3f06deb6c25c287f2dc282c494e4c8158d0c63c6
This commit is contained in:
Tobias Henkel 2018-07-04 09:14:15 +02:00 committed by Tobias Henkel
parent eb52394c8c
commit 1f75733a16
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,26 @@
zookeeper-servers:
- host: {zookeeper_host}
port: {zookeeper_port}
chroot: {zookeeper_chroot}
labels:
- name: fake-label
- name: fake-label-unresolvable
providers:
- name: static-provider
driver: static
pools:
- name: main
nodes:
- name: unresolvable.unresolvable.unresolvable
labels: fake-label-unresolvable
timeout: 13
connection-port: 22022
username: zuul
- name: fake-host-1
labels: fake-label
host-key: ssh-rsa FAKEKEY
timeout: 13
connection-port: 22022
username: zuul

View File

@ -62,6 +62,30 @@ class TestDriverStatic(tests.DBTestCase):
self.assertEqual(nodes[0].connection_type, 'ssh')
self.assertEqual(nodes[0].host_keys, ['ssh-rsa FAKEKEY'])
def test_static_unresolvable(self):
'''
Test that basic node registration works.
'''
configfile = self.setup_config('static-unresolvable.yaml')
pool = self.useNodepool(configfile, watermark_sleep=1)
pool.start()
self.log.debug("Waiting for node pre-registration")
nodes = self.waitForNodes('fake-label')
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].state, zk.READY)
self.assertEqual(nodes[0].provider, "static-provider")
self.assertEqual(nodes[0].pool, "main")
self.assertEqual(nodes[0].launcher, "static driver")
self.assertEqual(nodes[0].type, ['fake-label'])
self.assertEqual(nodes[0].hostname, 'fake-host-1')
self.assertEqual(nodes[0].interface_ip, 'fake-host-1')
self.assertEqual(nodes[0].username, 'zuul')
self.assertEqual(nodes[0].connection_port, 22022)
self.assertEqual(nodes[0].connection_type, 'ssh')
self.assertEqual(nodes[0].host_keys, ['ssh-rsa FAKEKEY'])
def test_static_node_increase(self):
'''
Test that adding new nodes to the config creates additional nodes.