Browse Source

Merge "Test compact_services metadata"

Zuul 4 months ago
parent
commit
59b91ceebf
2 changed files with 45 additions and 6 deletions
  1. 9
    5
      novajoin/ipa.py
  2. 36
    1
      novajoin/tests/functional/test_enrollment.py

+ 9
- 5
novajoin/ipa.py View File

@@ -482,13 +482,17 @@ class IPAClient(IPANovaJoinBase):
482 482
                 return True
483 483
         return False
484 484
 
485
-    def host_has_services(self, service_host):
486
-        """Return True if this host manages any services"""
487
-        LOG.debug('Checking if host ' + service_host + ' has services')
485
+    def host_get_services(self, service_host):
486
+        """Return list of services this host manages"""
487
+        LOG.debug('Checking host ' + service_host + ' services')
488 488
         params = []
489
-        service_args = {'man_by_host': service_host}
489
+        service_args = {'man_by_host': six.text_type(service_host)}
490 490
         result = self._call_ipa('service_find', *params, **service_args)
491
-        return result['count'] > 0
491
+        return [service['krbprincipalname'][0] for service in result['result']]
492
+
493
+    def host_has_services(self, service_host):
494
+        """Return True if this host manages any services"""
495
+        return len(self.host_get_services(service_host)) > 0
492 496
 
493 497
     def find_host(self, hostname):
494 498
         """Return True if this host exists"""

+ 36
- 1
novajoin/tests/functional/test_enrollment.py View File

@@ -99,11 +99,33 @@ class TestEnrollment(testtools.TestCase):
99 99
         self._server = self.conn.compute.create_server(
100 100
             name=TEST_INSTANCE, image_id=image.id, flavor_id=flavor.id,
101 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 107
         server = self.conn.compute.wait_for_server(self._server)
105 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 129
     def _associate_floating_ip(self):
108 130
         self.conn.compute.add_floating_ip_to_server(
109 131
             self._server, self._ip.floating_ip_address)
@@ -182,6 +204,19 @@ class TestEnrollment(testtools.TestCase):
182 204
 
183 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 220
         self._delete_server()
186 221
         self._check_ipa_client_deleted()
187 222
         self._check_ip_record_removed()

Loading…
Cancel
Save