YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 1 | # Copyright 2015 NEC Corporation. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | from tempest.api.compute import base |
| 16 | from tempest import config |
| 17 | from tempest import test |
| 18 | |
| 19 | CONF = config.CONF |
| 20 | |
| 21 | |
| 22 | class BaremetalNodesAdminTestJSON(base.BaseV2ComputeAdminTest): |
| 23 | """ |
| 24 | Tests Baremetal API |
| 25 | """ |
| 26 | |
| 27 | @classmethod |
| 28 | def resource_setup(cls): |
| 29 | super(BaremetalNodesAdminTestJSON, cls).resource_setup() |
| 30 | if not CONF.service_available.ironic: |
| 31 | skip_msg = ('%s skipped as Ironic is not available' % cls.__name__) |
| 32 | raise cls.skipException(skip_msg) |
| 33 | cls.client = cls.os_adm.baremetal_nodes_client |
Adam Gandelman | 118cd39 | 2015-03-09 14:41:36 -0700 | [diff] [blame] | 34 | cls.ironic_client = cls.os_adm.baremetal_client |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 35 | |
Sean Dague | f0462a1 | 2015-04-27 11:03:59 -0400 | [diff] [blame] | 36 | @test.attr(type=['baremetal']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 37 | @test.idempotent_id('e475aa6e-416d-4fa4-b3af-28d5e84250fb') |
Adam Gandelman | 118cd39 | 2015-03-09 14:41:36 -0700 | [diff] [blame] | 38 | def test_list_get_baremetal_nodes(self): |
| 39 | # Create some test nodes in Ironic directly |
| 40 | test_nodes = [] |
| 41 | for i in range(0, 3): |
| 42 | _, node = self.ironic_client.create_node() |
| 43 | test_nodes.append(node) |
| 44 | self.addCleanup(self.ironic_client.delete_node, node['uuid']) |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 45 | |
Adam Gandelman | 118cd39 | 2015-03-09 14:41:36 -0700 | [diff] [blame] | 46 | # List all baremetal nodes and ensure our created test nodes are |
| 47 | # listed |
| 48 | bm_node_ids = set([n['id'] for n in |
ghanshyam | f9a569b | 2015-08-04 15:29:06 +0900 | [diff] [blame] | 49 | self.client.list_baremetal_nodes()['nodes']]) |
Adam Gandelman | 118cd39 | 2015-03-09 14:41:36 -0700 | [diff] [blame] | 50 | test_node_ids = set([n['uuid'] for n in test_nodes]) |
| 51 | self.assertTrue(test_node_ids.issubset(bm_node_ids)) |
| 52 | |
| 53 | # Test getting each individually |
| 54 | for node in test_nodes: |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 55 | baremetal_node = self.client.show_baremetal_node(node['uuid']) |
ghanshyam | f9a569b | 2015-08-04 15:29:06 +0900 | [diff] [blame] | 56 | self.assertEqual(node['uuid'], baremetal_node['node']['id']) |