Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
| 13 | import six |
| 14 | |
| 15 | from tempest.api.baremetal import base |
| 16 | from tempest import exceptions as exc |
| 17 | from tempest import test |
| 18 | |
| 19 | |
| 20 | class TestNodes(base.BaseBaremetalTest): |
| 21 | '''Tests for baremetal nodes.''' |
| 22 | |
| 23 | def setUp(self): |
| 24 | super(TestNodes, self).setUp() |
| 25 | |
| 26 | self.chassis = self.create_chassis()['chassis'] |
| 27 | |
| 28 | @test.attr(type='smoke') |
| 29 | def test_create_node(self): |
| 30 | params = {'cpu_arch': 'x86_64', |
| 31 | 'cpu_num': '12', |
| 32 | 'storage': '10240', |
| 33 | 'memory': '1024'} |
| 34 | |
| 35 | node = self.create_node(self.chassis['uuid'], **params)['node'] |
| 36 | |
| 37 | for key in params: |
| 38 | self.assertEqual(node['properties'][key], params[key]) |
| 39 | |
| 40 | @test.attr(type='smoke') |
| 41 | def test_delete_node(self): |
| 42 | node = self.create_node(self.chassis['uuid'])['node'] |
| 43 | node_id = node['uuid'] |
| 44 | |
| 45 | resp = self.delete_node(node_id) |
| 46 | |
| 47 | self.assertEqual(resp['status'], '204') |
| 48 | self.assertRaises(exc.NotFound, self.client.show_node, node_id) |
| 49 | |
| 50 | @test.attr(type='smoke') |
| 51 | def test_show_node(self): |
| 52 | params = {'cpu_arch': 'x86_64', |
| 53 | 'cpu_num': '4', |
| 54 | 'storage': '100', |
| 55 | 'memory': '512'} |
| 56 | |
| 57 | created_node = self.create_node(self.chassis['uuid'], **params)['node'] |
| 58 | resp, loaded_node = self.client.show_node(created_node['uuid']) |
| 59 | |
| 60 | for key, val in created_node.iteritems(): |
| 61 | if key not in ('created_at', 'updated_at'): |
| 62 | self.assertEqual(loaded_node[key], val) |
| 63 | |
| 64 | @test.attr(type='smoke') |
| 65 | def test_list_nodes(self): |
| 66 | uuids = [self.create_node(self.chassis['uuid'])['node']['uuid'] |
| 67 | for i in range(0, 5)] |
| 68 | |
| 69 | resp, body = self.client.list_nodes() |
| 70 | loaded_uuids = [n['uuid'] for n in body['nodes']] |
| 71 | |
| 72 | for u in uuids: |
| 73 | self.assertIn(u, loaded_uuids) |
| 74 | |
| 75 | @test.attr(type='smoke') |
| 76 | def test_update_node(self): |
| 77 | props = {'cpu_arch': 'x86_64', |
| 78 | 'cpu_num': '12', |
| 79 | 'storage': '10', |
| 80 | 'memory': '128'} |
| 81 | |
| 82 | node = self.create_node(self.chassis['uuid'], **props)['node'] |
| 83 | node_id = node['uuid'] |
| 84 | |
| 85 | new_props = {'cpu_arch': 'x86', |
| 86 | 'cpu_num': '1', |
| 87 | 'storage': '10000', |
| 88 | 'memory': '12300'} |
| 89 | |
| 90 | self.client.update_node(node_id, properties=new_props) |
| 91 | resp, node = self.client.show_node(node_id) |
| 92 | |
| 93 | for name, value in six.iteritems(new_props): |
| 94 | if name not in ('created_at', 'updated_at'): |
| 95 | self.assertEqual(node['properties'][name], value) |