summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Grasza <xek@redhat.com>2018-12-13 15:24:22 +0100
committerGrzegorz Grasza <xek@redhat.com>2018-12-19 20:39:53 +0100
commitf5aab5544d6da87c71cbffe808a8958a5ae6c84c (patch)
treeec57cf17d586bfe260474849c2f59c768bb4272b
parent62475be1c24efc730e2550b17d4c3b0ef550abf6 (diff)
Test compact_services metadata
This tests new and old formats, as well as instance metadata updates. Change-Id: Ie7b3bcdbb98bb2786000207b72e7b289d5051b8f
Notes
Notes (review): Code-Review+2: Ade Lee <alee@redhat.com> Workflow+1: Ade Lee <alee@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 19 Dec 2018 20:50:58 +0000 Reviewed-on: https://review.openstack.org/625012 Project: openstack/novajoin Branch: refs/heads/master
-rw-r--r--novajoin/ipa.py14
-rw-r--r--novajoin/tests/functional/test_enrollment.py37
2 files changed, 45 insertions, 6 deletions
diff --git a/novajoin/ipa.py b/novajoin/ipa.py
index 6af9d62..a1e4154 100644
--- a/novajoin/ipa.py
+++ b/novajoin/ipa.py
@@ -474,13 +474,17 @@ class IPAClient(IPANovaJoinBase):
474 return True 474 return True
475 return False 475 return False
476 476
477 def host_has_services(self, service_host): 477 def host_get_services(self, service_host):
478 """Return True if this host manages any services""" 478 """Return list of services this host manages"""
479 LOG.debug('Checking if host ' + service_host + ' has services') 479 LOG.debug('Checking host ' + service_host + ' services')
480 params = [] 480 params = []
481 service_args = {'man_by_host': service_host} 481 service_args = {'man_by_host': six.text_type(service_host)}
482 result = self._call_ipa('service_find', *params, **service_args) 482 result = self._call_ipa('service_find', *params, **service_args)
483 return result['count'] > 0 483 return [service['krbprincipalname'][0] for service in result['result']]
484
485 def host_has_services(self, service_host):
486 """Return True if this host manages any services"""
487 return len(self.host_get_services(service_host)) > 0
484 488
485 def find_host(self, hostname): 489 def find_host(self, hostname):
486 """Return True if this host exists""" 490 """Return True if this host exists"""
diff --git a/novajoin/tests/functional/test_enrollment.py b/novajoin/tests/functional/test_enrollment.py
index 8a4999c..e8ef0c3 100644
--- a/novajoin/tests/functional/test_enrollment.py
+++ b/novajoin/tests/functional/test_enrollment.py
@@ -99,11 +99,33 @@ class TestEnrollment(testtools.TestCase):
99 self._server = self.conn.compute.create_server( 99 self._server = self.conn.compute.create_server(
100 name=TEST_INSTANCE, image_id=image.id, flavor_id=flavor.id, 100 name=TEST_INSTANCE, image_id=image.id, flavor_id=flavor.id,
101 networks=[{"uuid": network.id}], key_name=self._key.name, 101 networks=[{"uuid": network.id}], key_name=self._key.name,
102 metadata = {"ipa_enroll": "True"}) 102 metadata = {
103 "ipa_enroll": "True",
104 'compact_service_http': json.dumps(['test1', 'test2']),
105 })
103 106
104 server = self.conn.compute.wait_for_server(self._server) 107 server = self.conn.compute.wait_for_server(self._server)
105 return server 108 return server
106 109
110 def _update_server_compact_service_new(self):
111 self.conn.compute.set_server_metadata(
112 self._server,
113 compact_service_rabbitmq=json.dumps(['test3', 'test4']))
114
115 def _update_server_compact_service_old(self):
116 self.conn.compute.delete_server_metadata(self._server, [
117 'compact_service_http', 'compact_service_rabbitmq'])
118 self.conn.compute.set_server_metadata(
119 self._server,
120 compact_services=json.dumps({'http': ['test5', 'test6']}))
121
122 @loopingcall.RetryDecorator(50, 5, 5, (AssertionError,))
123 def _check_server_compact_services(self, service_list):
124 services = ['\\'.join([s.split('/', 1)[0].lower(), s.split('.', 2)[1]])
125 for s in self.ipaclient.host_get_services(
126 TEST_INSTANCE + EXAMPLE_DOMAIN)]
127 self.assertSetEqual(set(services), set(service_list))
128
107 def _associate_floating_ip(self): 129 def _associate_floating_ip(self):
108 self.conn.compute.add_floating_ip_to_server( 130 self.conn.compute.add_floating_ip_to_server(
109 self._server, self._ip.floating_ip_address) 131 self._server, self._ip.floating_ip_address)
@@ -182,6 +204,19 @@ class TestEnrollment(testtools.TestCase):
182 204
183 self._check_ipa_client_install() 205 self._check_ipa_client_install()
184 206
207 self._check_server_compact_services(['http\\test1', 'http\\test2'])
208
209 self._update_server_compact_service_new()
210 self._check_server_compact_services([
211 'http\\test1', 'http\\test2',
212 'rabbitmq\\test3', 'rabbitmq\\test4'])
213
214 self._update_server_compact_service_old()
215 # NOTE(xek), novajoin doesn't support removing of services via update
216 self._check_server_compact_services([
217 'http\\test1', 'http\\test2', 'http\\test5', 'http\\test6',
218 'rabbitmq\\test3', 'rabbitmq\\test4'])
219
185 self._delete_server() 220 self._delete_server()
186 self._check_ipa_client_deleted() 221 self._check_ipa_client_deleted()
187 self._check_ip_record_removed() 222 self._check_ip_record_removed()