Browse Source

Support murano plugin installation in OSTF tests

- Add discover mechanism for murano if it enabled via plugin installation

Change-Id: I2e60a65676fcb3b452c2acf3793ef8e251182cae
targets: blueprint murano-fuel-plugin
Closes-Bug: #1584791
Victor Ryzhenkin 3 years ago
parent
commit
7cc4b17cee

+ 36
- 32
fuel_health/muranomanager.py View File

@@ -401,61 +401,65 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
401 401
             if inst_name in service['instance']['name']:
402 402
                 return service['instance']['floatingIpAddress']
403 403
 
404
-    def get_list_packages(self):
404
+    def get_list_packages(self, artifacts=False):
405 405
         try:
406
-            packages = self.murano_client.packages.list()
406
+            if artifacts:
407
+                packages_list = self.murano_art_client.packages.list()
408
+                packages = []
409
+                for package in packages_list:
410
+                    packages.append(package)
411
+            else:
412
+                packages_list = self.murano_client.packages.list()
413
+                packages = list(packages_list)
407 414
         except exceptions.ClientException:
408 415
             self.fail("Can not get list of packages")
409
-        packages_list = list(packages)
410
-        LOG.debug('Packages List: {0}'.format(packages_list))
411
-        self.assertIsInstance(packages_list, list)
412
-        return packages_list
416
+        LOG.debug('Packages List: {0}'.format(packages))
417
+        self.assertIsInstance(packages, list)
418
+        return packages
413 419
 
414
-    def generate_fqn_list(self):
420
+    def generate_fqn_list(self, artifacts=False):
415 421
         fqn_list = []
416
-        packages = self.get_list_packages()
422
+        packages = self.get_list_packages(artifacts)
417 423
         for package in packages:
418 424
             fqn_list.append(package.to_dict()['fully_qualified_name'])
419 425
         LOG.debug('FQN List: {0}'.format(fqn_list))
420 426
         return fqn_list
421 427
 
422
-    def upload_package(self, package_name, body, app):
428
+    def upload_package(self, package_name, body, app, artifacts=False):
423 429
         files = {'%s' % package_name: open(app, 'rb')}
424
-        package = self.murano_client.packages.create(body, files)
430
+        if artifacts:
431
+            package = self.murano_art_client.packages.create(body, files)
432
+        else:
433
+            package = self.murano_client.packages.create(body, files)
425 434
         self.packages.append(package)
426 435
         return package
427 436
 
428
-    def package_exists(self, *packages):
429
-        fqn_list = self.generate_fqn_list()
437
+    def package_exists(self, artifacts=False, *packages):
438
+        fqn_list = self.generate_fqn_list(artifacts)
430 439
         LOG.debug("Response for packages is {0}".format(fqn_list))
431 440
         for package in packages:
432 441
             if package not in fqn_list:
433 442
                 return False
434 443
         return True
435 444
 
436
-    def get_package(self, package_id):
437
-        resp = requests.get(self.endpoint + 'catalog/packages/{0}'.
438
-                            format(package_id), headers=self.headers,
439
-                            verify=False)
440
-        self.assertEqual(200, resp.status_code)
441
-        return resp.json()
445
+    def get_package(self, package_id, artifacts=False):
446
+        if artifacts:
447
+            package = self.murano_art_client.packages.get(package_id)
448
+        else:
449
+            package = self.murano_client.packages.get(package_id)
450
+        return package
442 451
 
443
-    def get_package_by_fqdn(self, package_name):
444
-        resp = requests.get(self.endpoint + 'catalog/packages',
445
-                            headers=self.headers, verify=False)
446
-        for package in resp.json()["packages"]:
447
-            if package["fully_qualified_name"] == package_name:
452
+    def get_package_by_fqdn(self, package_name, artifacts=False):
453
+        package_list = self.get_list_packages(artifacts)
454
+        for package in package_list:
455
+            if package.to_dict()["fully_qualified_name"] == package_name:
448 456
                 return package
449 457
 
450
-    def delete_package(self, package_id):
451
-        resp = requests.delete(self.endpoint + 'catalog/packages/{0}'.
452
-                               format(package_id), headers=self.headers,
453
-                               verify=False)
454
-        try:
455
-            self.assertEqual(200, resp.status_code)
456
-        except Exception:
457
-            self.assertEqual(404, resp.status_code)
458
-            LOG.debug("Package not exists.")
458
+    def delete_package(self, package_id, artifacts=False):
459
+        if artifacts:
460
+            self.murano_art_client.packages.delete(package_id)
461
+        else:
462
+            self.murano_client.packages.delete(package_id)
459 463
 
460 464
     def get_list_categories(self):
461 465
         resp = requests.get(self.endpoint + 'catalog/packages/categories',

+ 36
- 6
fuel_health/nmanager.py View File

@@ -58,6 +58,11 @@ try:
58 58
 except Exception:
59 59
     LOG.exception()
60 60
     LOG.warning('Ironic client could not be imported')
61
+try:
62
+    import muranoclient.glance.client as art_client
63
+except Exception:
64
+    LOG.exception()
65
+    LOG.warning('Artifacts client could not be imported')
61 66
 
62 67
 import aodhclient.client
63 68
 import cinderclient.client
@@ -116,6 +121,8 @@ class OfficialClientManager(fuel_health.manager.Manager):
116 121
             self.glance_client_v1 = self._get_glance_client(version=1)
117 122
             self.ironic_client = self._get_ironic_client()
118 123
             self.aodh_client = self._get_aodh_client()
124
+            self.artifacts_client = self._get_artifacts_client()
125
+            self.murano_art_client = self._get_murano_client(artifacts=True)
119 126
             self.client_attr_names = [
120 127
                 'compute_client',
121 128
                 'identity_client',
@@ -129,7 +136,9 @@ class OfficialClientManager(fuel_health.manager.Manager):
129 136
                 'ceilometer_client',
130 137
                 'neutron_client',
131 138
                 'ironic_client',
132
-                'aodh_client'
139
+                'aodh_client',
140
+                'artifacts_client',
141
+                'murano_art_client'
133 142
             ]
134 143
 
135 144
     def _get_compute_client(self, username=None, password=None,
@@ -264,7 +273,7 @@ class OfficialClientManager(fuel_health.manager.Manager):
264 273
                                                token=token,
265 274
                                                insecure=True)
266 275
 
267
-    def _get_murano_client(self):
276
+    def _get_murano_client(self, artifacts=False):
268 277
         """This method returns Murano API client
269 278
         """
270 279
         keystone = self._get_identity_client(
@@ -283,10 +292,16 @@ class OfficialClientManager(fuel_health.manager.Manager):
283 292
                         'not found. Murano client cannot be initialized.')
284 293
             return
285 294
 
286
-        return muranoclient.v1.client.Client(
287
-            endpoint,
288
-            token=self.token_id,
289
-            insecure=True)
295
+        if artifacts:
296
+            return muranoclient.v1.client.Client(
297
+                endpoint,
298
+                token=self.token_id,
299
+                insecure=True, artifacts_client=self.artifacts_client)
300
+        else:
301
+            return muranoclient.v1.client.Client(
302
+                endpoint,
303
+                token=self.token_id,
304
+                insecure=True)
290 305
 
291 306
     def _get_sahara_client(self):
292 307
         sahara_api_version = self.config.sahara.api_version
@@ -351,6 +366,21 @@ class OfficialClientManager(fuel_health.manager.Manager):
351 366
             os_auth_token=keystone.auth_token,
352 367
             ironic_url=endpoint, insecure=True)
353 368
 
369
+    def _get_artifacts_client(self, version='1'):
370
+        keystone = self._get_identity_client()
371
+        try:
372
+            endpoint = keystone.service_catalog.url_for(
373
+                service_type='artifact',
374
+                endpoint_type='publicURL')
375
+        except keystoneclient.exceptions.EndpointNotFound:
376
+            LOG.warning('Can not initialize artifacts client')
377
+            return None
378
+        return art_client.Client(endpoint=endpoint,
379
+                                 type_name='murano',
380
+                                 type_version=version,
381
+                                 token=keystone.auth_token,
382
+                                 insecure=True)
383
+
354 384
     def _get_aodh_client(self, version='2'):
355 385
         username = self.config.identity.admin_username
356 386
         password = self.config.identity.admin_password

+ 18
- 3
fuel_health/tests/sanity/test_sanity_murano.py View File

@@ -33,7 +33,7 @@ class MuranoSanityTests(muranomanager.MuranoTest):
33 33
 
34 34
         Duration: 10 s.
35 35
 
36
-        Deployment tags: Murano
36
+        Deployment tags: Murano | murano_plugin
37 37
         """
38 38
 
39 39
         fail_msg = "Can't create environment. Murano API isn't available. "
@@ -55,7 +55,7 @@ class MuranoSanityTests(muranomanager.MuranoTest):
55 55
 
56 56
         Duration: 10 s.
57 57
 
58
-        Deployment tags: Murano
58
+        Deployment tags: Murano | murano_plugin
59 59
         """
60 60
         fail_msg = "Can't get list of categories. Murano API isn't available. "
61 61
         self.verify(10, self.get_list_categories, 1, fail_msg,
@@ -70,8 +70,23 @@ class MuranoSanityTests(muranomanager.MuranoTest):
70 70
 
71 71
         Duration: 10 s.
72 72
 
73
-        Deployment tags: Murano
73
+        Deployment tags: Murano | murano_plugin, murano_without_glare
74 74
         """
75 75
         fail_msg = "Can't get list of packages. Murano API isn't available. "
76 76
         self.verify(10, self.get_list_packages, 1, fail_msg,
77 77
                     "getting list of packages")
78
+
79
+    def test_get_list_artifacts_packages(self):
80
+        """Get list of Murano Artifact applications packages
81
+        Target component: Murano
82
+
83
+        Scenario:
84
+            1. Send request to get list of artifact packages
85
+
86
+        Duration: 10 s.
87
+
88
+        Deployment tags: Murano | murano_plugin, murano_use_glare
89
+        """
90
+        fail_msg = "Can't get list of packages. Murano API isn't available. "
91
+        self.verify(10, self.get_list_packages, 1, fail_msg,
92
+                    "getting list of packages", artifacts=True)

+ 114
- 4
fuel_health/tests/tests_platform/test_murano_linux.py View File

@@ -43,7 +43,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
43 43
 
44 44
         self.dummy_fqdn = 'io.murano.apps.Simple'
45 45
 
46
-        # Flavor with 2 vCPU and 40Gb HDD will allow to sucessfully
46
+        # Flavor with 2 vCPU and 40Gb HDD will allow to successfully
47 47
         # deploy all Murano applications.
48 48
         self.flavor_name = rand_name("ostf_test_Murano_flavor")
49 49
         flavor = self.compute_client.flavors.create(
@@ -70,7 +70,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
70 70
             10. Send request to delete package.
71 71
 
72 72
         Duration: 1200 s.
73
-        Deployment tags: Murano, Heat
73
+        Deployment tags: Murano | murano_plugin, murano_without_glare
74 74
         Available since release: 2014.2-6.1
75 75
         """
76 76
 
@@ -163,6 +163,116 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
163 163
         self.verify(5, self.delete_package, 10, fail_msg, "deleting_package",
164 164
                     self.package.id)
165 165
 
166
+    def test_deploy_dummy_app_with_glare(self):
167
+        """Check application deployment in Murano environment with GLARE
168
+        Target component: Murano
169
+
170
+        Scenario:
171
+            1. Prepare test app.
172
+            2. Upload test app.
173
+            3. Send request to create environment.
174
+            4. Send request to create session for environment.
175
+            5. Send request to create test service.
176
+            6. Send request to deploy session.
177
+            7. Checking environment status.
178
+            8. Checking deployment status.
179
+            9. Send request to delete environment.
180
+            10. Send request to delete package.
181
+
182
+        Duration: 1200 s.
183
+        Deployment tags: Murano | murano_plugin, murano_use_glare
184
+        Available since release: 2014.2-6.1
185
+        """
186
+        artifacts = True
187
+        vms_count = self.get_info_about_available_resources(
188
+            self.min_required_ram_mb, 40, 2)
189
+        if vms_count < 1:
190
+            msg = ('This test requires more hardware resources of your '
191
+                   'OpenStack cluster: your cloud should allow to create '
192
+                   'at least 1 VM with {0} MB of RAM, {1} HDD and {2} vCPUs. '
193
+                   'You need to remove some resources or add compute nodes '
194
+                   'to have an ability to run this OSTF test.'
195
+                   .format(self.min_required_ram_mb, 40, 2))
196
+            LOG.debug(msg)
197
+            self.skipTest(msg)
198
+
199
+        if self.package_exists(artifacts, self.dummy_fqdn):
200
+            package = self.get_package_by_fqdn(self.dummy_fqdn, artifacts)
201
+            self.delete_package(package.to_dict()["id"], artifacts)
202
+
203
+        fail_msg = ("Package preparation failed. Please refer to "
204
+                    "OSTF logs for more information")
205
+        zip_path = self.verify(10, self.zip_dir, 1, fail_msg,
206
+                               'prepare package',
207
+                               os.path.dirname(__file__), self.dummy_fqdn)
208
+
209
+        fail_msg = ("Package uploading failed. "
210
+                    "Please refer to Openstack and OSTF logs")
211
+        self.package = self.verify(10, self.upload_package, 2, fail_msg,
212
+                                   'uploading package', 'SimpleApp',
213
+                                   {"categories": ["Web"], "tags": ["tag"]},
214
+                                   zip_path, artifacts)
215
+
216
+        fail_msg = "Can't create environment. Murano API is not available. "
217
+        self.environment = self.verify(15, self.create_environment,
218
+                                       3, fail_msg, 'creating environment',
219
+                                       self.env_name)
220
+
221
+        fail_msg = "User can't create session for environment. "
222
+        session = self.verify(5, self.create_session,
223
+                              4, fail_msg, "session creating",
224
+                              self.environment.id)
225
+
226
+        post_body = {
227
+            "instance": {
228
+                "flavor": self.flavor_name,
229
+                "image": "TestVM",
230
+                "assignFloatingIp": True,
231
+                "?": {
232
+                    "type": "io.murano.resources.LinuxMuranoInstance",
233
+                    "id": str(uuid.uuid4())
234
+                },
235
+                "name": rand_name("testMurano")
236
+            },
237
+            "name": rand_name("teMurano"),
238
+            "?": {
239
+                "_{id}".format(id=uuid.uuid4().hex): {
240
+                    "name": "SimpleApp"
241
+                },
242
+                "type": self.dummy_fqdn,
243
+                "id": str(uuid.uuid4())
244
+            }
245
+        }
246
+
247
+        fail_msg = "User can't create service. "
248
+        self.verify(5, self.create_service,
249
+                    5, fail_msg, "service creating",
250
+                    self.environment.id, session.id, post_body)
251
+
252
+        fail_msg = "User can't deploy session. "
253
+        self.verify(5, self.deploy_session,
254
+                    6, fail_msg,
255
+                    "sending session on deployment",
256
+                    self.environment.id, session.id)
257
+
258
+        fail_msg = "Deployment was not completed correctly. "
259
+        self.verify(860, self.deploy_check,
260
+                    7, fail_msg, 'deployment is going',
261
+                    self.environment)
262
+
263
+        self.verify(5, self.deployments_status_check, 8, fail_msg,
264
+                    'Check deployments status',
265
+                    self.environment.id)
266
+
267
+        fail_msg = "Can't delete environment. "
268
+        self.verify(60, self.environment_delete_check,
269
+                    9, fail_msg, "deleting environment",
270
+                    self.environment.id)
271
+
272
+        fail_msg = "Can't delete package"
273
+        self.verify(5, self.delete_package, 10, fail_msg, "deleting_package",
274
+                    self.package.id, artifacts)
275
+
166 276
     def test_deploy_apache_service(self):
167 277
         """Check that user can deploy Apache service in Murano environment
168 278
         Target component: Murano
@@ -178,7 +288,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
178 288
             8. Send request to delete environment.
179 289
 
180 290
         Duration: 2140 s.
181
-        Deployment tags: Murano, Heat
291
+        Deployment tags: Murano | murano_plugin, murano_without_artifacts
182 292
         Available since release: 2014.2-6.0
183 293
         """
184 294
 
@@ -287,7 +397,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
287 397
             11. Send request to delete environment.
288 398
 
289 399
         Duration: 2140 s.
290
-        Deployment tags: Murano, Heat
400
+        Deployment tags: Murano | murano_plugin, murano_without_artifacts
291 401
         Available since release: 2014.2-6.1
292 402
         """
293 403
 

+ 27
- 2
fuel_plugin/ostf_adapter/mixins.py View File

@@ -30,10 +30,8 @@ from sqlalchemy.orm import joinedload
30 30
 from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
31 31
 from fuel_plugin.ostf_adapter.storage import models
32 32
 
33
-
34 33
 LOG = logging.getLogger(__name__)
35 34
 
36
-
37 35
 TEST_REPOSITORY = []
38 36
 # TODO(ikutukov): remove hardcoded Nailgun API urls here and below
39 37
 NAILGUN_VERSION_API_URL = 'http://{0}:{1}/api/v1/version'
@@ -242,6 +240,33 @@ def _get_cluster_attrs(cluster_id, token=None):
242 240
     for comp in comp_names:
243 241
         processor(comp)
244 242
 
243
+    # TODO(freerunner): Rework murano part after removal murano from the box
244
+    murano_settings = response['editable'].get('murano_settings', None)
245
+    # NOTE(freerunner): Murano settings appears only if murano enabled
246
+    murano_artifacts = None
247
+    if murano_settings:
248
+        murano_artifacts = (murano_settings
249
+                            ['murano_glance_artifacts_plugin']['value'])
250
+    detach_murano = response['editable'].get('detach-murano', None)
251
+    murano_plugin_enabled = None
252
+    if detach_murano:
253
+        murano_plugin_enabled = detach_murano['metadata'].get('enabled', None)
254
+        if murano_plugin_enabled:
255
+            additional_depl_tags.add('murano_plugin')
256
+
257
+    # TODO(freerunner): Rework GLARE discover mechanism after
258
+    # TODO(freerunner): removal murano from the box
259
+    if murano_artifacts:
260
+        additional_depl_tags.add('murano_use_glare')
261
+    # NOTE(freerunner): Murano plugin will always support only one version
262
+    elif detach_murano and murano_plugin_enabled and (
263
+            detach_murano['metadata']['versions'][0]
264
+            ['murano_glance_artifacts'].get('value', None)):
265
+        additional_depl_tags.add('murano_use_glare')
266
+    # NOTE(freerunner): Set this tag only if murano is present
267
+    elif murano_plugin_enabled or murano_settings:
268
+        additional_depl_tags.add('murano_without_glare')
269
+
245 270
     storage_components = response['editable'].get('storage', dict())
246 271
 
247 272
     storage_comp = ['volumes_ceph', 'images_ceph', 'ephemeral_ceph',

+ 115
- 1
fuel_plugin/testing/tests/base.py View File

@@ -236,7 +236,121 @@ CLUSTERS = {
236 236
                 'common': {}
237 237
             }
238 238
         }
239
-    }
239
+    },
240
+    9: {
241
+        'cluster_meta': {
242
+            'release_id': 9,
243
+            'mode': 'multinode'
244
+        },
245
+        'release_data': {
246
+            'operating_system': 'ubuntu',
247
+            'version': '2016.1-9.0'
248
+        },
249
+        'cluster_node': {
250
+        },
251
+        'cluster_attributes': {
252
+            'editable': {
253
+                'detach-murano': {
254
+                    'metadata': {
255
+                        'enabled': True,
256
+                        'versions': [
257
+                            {
258
+                                'murano_glance_artifacts': {
259
+                                    "value": True
260
+                                }
261
+                            }
262
+                        ]
263
+                    }
264
+                },
265
+                'additional_components': {},
266
+                'common': {}
267
+            }
268
+        }
269
+    },
270
+    10: {
271
+        'cluster_meta': {
272
+            'release_id': 10,
273
+            'mode': 'multinode'
274
+        },
275
+        'release_data': {
276
+            'operating_system': 'ubuntu',
277
+            'version': '2016.1-9.0'
278
+        },
279
+        'cluster_node': {
280
+        },
281
+        'cluster_attributes': {
282
+            'editable': {
283
+                'detach-murano': {
284
+                    'metadata': {
285
+                        'enabled': True,
286
+                        'versions': [
287
+                            {
288
+                                'murano_glance_artifacts': {
289
+                                    "value": False
290
+                                }
291
+                            }
292
+                        ]
293
+                    }
294
+                },
295
+                'additional_components': {},
296
+                'common': {}
297
+            }
298
+        }
299
+    },
300
+    11: {
301
+        'cluster_meta': {
302
+            'release_id': 11,
303
+            'mode': 'multinode'
304
+        },
305
+        'release_data': {
306
+            'operating_system': 'ubuntu',
307
+            'version': '2016.1-9.0'
308
+        },
309
+        'cluster_node': {
310
+        },
311
+        'cluster_attributes': {
312
+            'editable': {
313
+                'additional_components': {
314
+                    'murano': {
315
+                        'value': True
316
+                    }
317
+                },
318
+                'murano_settings': {
319
+                    'murano_glance_artifacts_plugin': {
320
+                        'value': True
321
+                    }
322
+                },
323
+                'common': {}
324
+            }
325
+        }
326
+    },
327
+    12: {
328
+        'cluster_meta': {
329
+            'release_id': 12,
330
+            'mode': 'multinode'
331
+        },
332
+        'release_data': {
333
+            'operating_system': 'ubuntu',
334
+            'version': '2016.1-9.0'
335
+        },
336
+        'cluster_node': {
337
+        },
338
+        'cluster_attributes': {
339
+            'editable': {
340
+                'additional_components': {
341
+                    'murano': {
342
+                        'value': True
343
+                    }
344
+                },
345
+                'murano_settings': {
346
+                    'murano_glance_artifacts_plugin': {
347
+                        'value': False
348
+                    }
349
+                },
350
+                'common': {}
351
+            }
352
+        }
353
+    },
240 354
 }
241 355
 
242 356
 

+ 96
- 0
fuel_plugin/testing/tests/unit/test_support_utilities.py View File

@@ -108,3 +108,99 @@ class TestDeplTagsGetter(base.BaseUnitTest):
108 108
             res = mixins._get_cluster_attrs(expected['cluster_id'])
109 109
 
110 110
         self.assertEqual(res, expected['attrs'])
111
+
112
+
113
+class TestDeplMuranoTags(base.BaseUnitTest):
114
+
115
+    def setUp(self):
116
+        config.init_config([])
117
+
118
+        self.expected = {
119
+            'attrs': {
120
+                'deployment_tags': set(
121
+                    ['multinode', 'ubuntu', 'additional_components',
122
+                     'nova_network', 'public_on_all_nodes',
123
+                     'enable_without_ceph', 'computes_without_dpdk']),
124
+                'release_version': '2016.1-9.0'
125
+            }
126
+        }
127
+
128
+    def test_get_murano_plugin_tags_with_artifacts(self):
129
+        expected = self.expected
130
+        expected['cluster_id'] = 9
131
+        expected['attrs']['deployment_tags'].add('murano_plugin')
132
+        expected['attrs']['deployment_tags'].add('murano_use_glare')
133
+
134
+        with requests_mock.Mocker() as m:
135
+            cluster = base.CLUSTERS[expected['cluster_id']]
136
+            m.register_uri('GET', '/api/clusters/9',
137
+                           json=cluster['cluster_meta'])
138
+            m.register_uri('GET', '/api/clusters/9/attributes',
139
+                           json=cluster['cluster_attributes'])
140
+            m.register_uri('GET', '/api/releases/9',
141
+                           json=cluster['release_data'])
142
+            m.register_uri('GET', '/api/nodes?cluster_id=9',
143
+                           json=cluster['cluster_node'])
144
+            res = mixins._get_cluster_attrs(expected['cluster_id'])
145
+
146
+        self.assertEqual(res, expected['attrs'])
147
+
148
+    def test_get_murano_plugin_tags_without_artifacts(self):
149
+        expected = self.expected
150
+        expected['cluster_id'] = 10
151
+        expected['attrs']['deployment_tags'].add('murano_plugin')
152
+        expected['attrs']['deployment_tags'].add('murano_without_glare')
153
+
154
+        with requests_mock.Mocker() as m:
155
+            cluster = base.CLUSTERS[expected['cluster_id']]
156
+            m.register_uri('GET', '/api/clusters/10',
157
+                           json=cluster['cluster_meta'])
158
+            m.register_uri('GET', '/api/clusters/10/attributes',
159
+                           json=cluster['cluster_attributes'])
160
+            m.register_uri('GET', '/api/releases/10',
161
+                           json=cluster['release_data'])
162
+            m.register_uri('GET', '/api/nodes?cluster_id=10',
163
+                           json=cluster['cluster_node'])
164
+            res = mixins._get_cluster_attrs(expected['cluster_id'])
165
+
166
+        self.assertEqual(res, expected['attrs'])
167
+
168
+    def test_get_murano_tags_with_artifacts(self):
169
+        expected = self.expected
170
+        expected['cluster_id'] = 11
171
+        expected['attrs']['deployment_tags'].add('murano')
172
+        expected['attrs']['deployment_tags'].add('murano_use_glare')
173
+
174
+        with requests_mock.Mocker() as m:
175
+            cluster = base.CLUSTERS[expected['cluster_id']]
176
+            m.register_uri('GET', '/api/clusters/11',
177
+                           json=cluster['cluster_meta'])
178
+            m.register_uri('GET', '/api/clusters/11/attributes',
179
+                           json=cluster['cluster_attributes'])
180
+            m.register_uri('GET', '/api/releases/11',
181
+                           json=cluster['release_data'])
182
+            m.register_uri('GET', '/api/nodes?cluster_id=11',
183
+                           json=cluster['cluster_node'])
184
+            res = mixins._get_cluster_attrs(expected['cluster_id'])
185
+
186
+        self.assertEqual(res, expected['attrs'])
187
+
188
+    def test_get_murano_tags_without_artifacts(self):
189
+        expected = self.expected
190
+        expected['cluster_id'] = 12
191
+        expected['attrs']['deployment_tags'].add('murano')
192
+        expected['attrs']['deployment_tags'].add('murano_without_glare')
193
+
194
+        with requests_mock.Mocker() as m:
195
+            cluster = base.CLUSTERS[expected['cluster_id']]
196
+            m.register_uri('GET', '/api/clusters/12',
197
+                           json=cluster['cluster_meta'])
198
+            m.register_uri('GET', '/api/clusters/12/attributes',
199
+                           json=cluster['cluster_attributes'])
200
+            m.register_uri('GET', '/api/releases/12',
201
+                           json=cluster['release_data'])
202
+            m.register_uri('GET', '/api/nodes?cluster_id=12',
203
+                           json=cluster['cluster_node'])
204
+            res = mixins._get_cluster_attrs(expected['cluster_id'])
205
+
206
+        self.assertEqual(res, expected['attrs'])

Loading…
Cancel
Save