| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 |
# not use this file except in compliance with the License. You may obtain |
| 4 |
# a copy of the License at |
| 5 |
# |
| 6 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
# |
| 8 |
# Unless required by applicable law or agreed to in writing, software |
| 9 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 |
# License for the specific language governing permissions and limitations |
| 12 |
# under the License. |
| 13 |
|
| 14 |
from tempest.lib.common.utils import data_utils |
| 15 |
from tempest.lib import decorators |
| 16 |
from tempest.lib import exceptions as lib_exc |
| 17 |
|
| 18 |
from ironic_tempest_plugin.tests.api import base |
| 19 |
|
| 20 |
|
| 21 |
class TestChassis(base.BaseBaremetalTest): |
| 22 |
"""Tests for chassis.""" |
| 23 |
|
| 24 |
@classmethod |
| 25 |
def resource_setup(cls): |
| 26 |
super(TestChassis, cls).resource_setup() |
| 27 |
_, cls.chassis = cls.create_chassis() |
| 28 |
|
| 29 |
@decorators.idempotent_id('7c5a2e09-699c-44be-89ed-2bc189992d42') |
| 30 |
def test_create_chassis(self): |
| 31 |
descr = data_utils.rand_name('test-chassis') |
| 32 |
_, chassis = self.create_chassis(description=descr) |
| 33 |
self.assertEqual(descr, chassis['description']) |
| 34 |
|
| 35 |
@decorators.idempotent_id('cabe9c6f-dc16-41a7-b6b9-0a90c212edd5') |
| 36 |
def test_create_chassis_unicode_description(self): |
| 37 |
# Use a unicode string for testing: |
| 38 |
# 'We ♡ OpenStack in Ukraine' |
| 39 |
descr = u'В Україні ♡ OpenStack!' |
| 40 |
_, chassis = self.create_chassis(description=descr) |
| 41 |
self.assertEqual(descr, chassis['description']) |
| 42 |
|
| 43 |
@decorators.idempotent_id('c84644df-31c4-49db-a307-8942881f41c0') |
| 44 |
def test_show_chassis(self): |
| 45 |
_, chassis = self.client.show_chassis(self.chassis['uuid']) |
| 46 |
self._assertExpected(self.chassis, chassis) |
| 47 |
|
| 48 |
@decorators.idempotent_id('29c9cd3f-19b5-417b-9864-99512c3b33b3') |
| 49 |
def test_list_chassis(self): |
| 50 |
_, body = self.client.list_chassis() |
| 51 |
self.assertIn(self.chassis['uuid'], |
| 52 |
[i['uuid'] for i in body['chassis']]) |
| 53 |
|
| 54 |
@decorators.idempotent_id('5ae649ad-22d1-4fe1-bbc6-97227d199fb3') |
| 55 |
def test_delete_chassis(self): |
| 56 |
_, body = self.create_chassis() |
| 57 |
uuid = body['uuid'] |
| 58 |
|
| 59 |
self.delete_chassis(uuid) |
| 60 |
self.assertRaises(lib_exc.NotFound, self.client.show_chassis, uuid) |
| 61 |
|
| 62 |
@decorators.idempotent_id('cda8a41f-6be2-4cbf-840c-994b00a89b44') |
| 63 |
def test_update_chassis(self): |
| 64 |
_, body = self.create_chassis() |
| 65 |
uuid = body['uuid'] |
| 66 |
|
| 67 |
new_description = data_utils.rand_name('new-description') |
| 68 |
_, body = (self.client.update_chassis(uuid, |
| 69 |
description=new_description)) |
| 70 |
_, chassis = self.client.show_chassis(uuid) |
| 71 |
self.assertEqual(new_description, chassis['description']) |
| 72 |
|
| 73 |
@decorators.idempotent_id('76305e22-a4e2-4ab3-855c-f4e2368b9335') |
| 74 |
def test_chassis_node_list(self): |
| 75 |
_, node = self.create_node(self.chassis['uuid']) |
| 76 |
_, body = self.client.list_chassis_nodes(self.chassis['uuid']) |
| 77 |
self.assertIn(node['uuid'], [n['uuid'] for n in body['nodes']]) |
| 78 |
|
| 79 |
@decorators.idempotent_id('dd52bd5d-610c-4f2c-8fa3-d5e59269325f') |
| 80 |
def test_create_chassis_uuid(self): |
| 81 |
uuid = data_utils.rand_uuid() |
| 82 |
_, chassis = self.create_chassis(uuid=uuid) |
| 83 |
self.assertEqual(uuid, chassis['uuid']) |