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 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 26 | _, self.chassis = self.create_chassis() |
| 27 | _, self.node = self.create_node(self.chassis['uuid']) |
| 28 | |
| 29 | def _assertExpected(self, expected, actual): |
| 30 | # Check if not expected keys/values exists in actual response body |
| 31 | for key, value in six.iteritems(expected): |
| 32 | if key not in ('created_at', 'updated_at'): |
| 33 | self.assertIn(key, actual) |
| 34 | self.assertEqual(value, actual[key]) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 35 | |
| 36 | @test.attr(type='smoke') |
| 37 | def test_create_node(self): |
| 38 | params = {'cpu_arch': 'x86_64', |
| 39 | 'cpu_num': '12', |
| 40 | 'storage': '10240', |
| 41 | 'memory': '1024'} |
| 42 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 43 | resp, body = self.create_node(self.chassis['uuid'], **params) |
| 44 | self.assertEqual('201', resp['status']) |
| 45 | self._assertExpected(params, body['properties']) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 46 | |
| 47 | @test.attr(type='smoke') |
| 48 | def test_delete_node(self): |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 49 | resp, node = self.create_node(self.chassis['uuid']) |
| 50 | self.assertEqual('201', resp['status']) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 51 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 52 | resp = self.delete_node(node['uuid']) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 53 | |
| 54 | self.assertEqual(resp['status'], '204') |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 55 | self.assertRaises(exc.NotFound, self.client.show_node, node['uuid']) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 56 | |
| 57 | @test.attr(type='smoke') |
| 58 | def test_show_node(self): |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 59 | resp, loaded_node = self.client.show_node(self.node['uuid']) |
| 60 | self.assertEqual('200', resp['status']) |
| 61 | self._assertExpected(self.node, loaded_node) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 62 | |
| 63 | @test.attr(type='smoke') |
| 64 | def test_list_nodes(self): |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 65 | resp, body = self.client.list_nodes() |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 66 | self.assertEqual('200', resp['status']) |
| 67 | self.assertIn(self.node['uuid'], |
| 68 | [i['uuid'] for i in body['nodes']]) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 69 | |
| 70 | @test.attr(type='smoke') |
| 71 | def test_update_node(self): |
| 72 | props = {'cpu_arch': 'x86_64', |
| 73 | 'cpu_num': '12', |
| 74 | 'storage': '10', |
| 75 | 'memory': '128'} |
| 76 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 77 | resp, node = self.create_node(self.chassis['uuid'], **props) |
| 78 | self.assertEqual('201', resp['status']) |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 79 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 80 | new_p = {'cpu_arch': 'x86', |
| 81 | 'cpu_num': '1', |
| 82 | 'storage': '10000', |
| 83 | 'memory': '12300'} |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 84 | |
Mh Raies | a9bb79d | 2014-04-17 16:20:17 +0530 | [diff] [blame] | 85 | resp, body = self.client.update_node(node['uuid'], properties=new_p) |
| 86 | self.assertEqual('200', resp['status']) |
| 87 | resp, node = self.client.show_node(node['uuid']) |
| 88 | self.assertEqual('200', resp['status']) |
| 89 | self._assertExpected(new_p, node['properties']) |