blob: 43ea1e67ccd03626e24f5eb4750f547ead7793f9 [file] [log] [blame]
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +03001# 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
13import six
14
Adam Gandelman2a86f1c2014-06-18 11:34:42 -070015from tempest.api.baremetal.admin import base
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030016from tempest import exceptions as exc
17from tempest import test
18
19
20class TestNodes(base.BaseBaremetalTest):
21 '''Tests for baremetal nodes.'''
22
23 def setUp(self):
24 super(TestNodes, self).setUp()
25
Mh Raiesa9bb79d2014-04-17 16:20:17 +053026 _, 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 Prykhodchenko62b1ed12013-10-16 21:51:47 +030035
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
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000043 _, body = self.create_node(self.chassis['uuid'], **params)
Mh Raiesa9bb79d2014-04-17 16:20:17 +053044 self._assertExpected(params, body['properties'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030045
46 @test.attr(type='smoke')
47 def test_delete_node(self):
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000048 _, node = self.create_node(self.chassis['uuid'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030049
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000050 self.delete_node(node['uuid'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030051
Mh Raiesa9bb79d2014-04-17 16:20:17 +053052 self.assertRaises(exc.NotFound, self.client.show_node, node['uuid'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030053
54 @test.attr(type='smoke')
55 def test_show_node(self):
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000056 _, loaded_node = self.client.show_node(self.node['uuid'])
Mh Raiesa9bb79d2014-04-17 16:20:17 +053057 self._assertExpected(self.node, loaded_node)
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030058
59 @test.attr(type='smoke')
60 def test_list_nodes(self):
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000061 _, body = self.client.list_nodes()
Mh Raiesa9bb79d2014-04-17 16:20:17 +053062 self.assertIn(self.node['uuid'],
63 [i['uuid'] for i in body['nodes']])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030064
65 @test.attr(type='smoke')
66 def test_update_node(self):
67 props = {'cpu_arch': 'x86_64',
68 'cpu_num': '12',
69 'storage': '10',
70 'memory': '128'}
71
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000072 _, node = self.create_node(self.chassis['uuid'], **props)
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030073
Mh Raiesa9bb79d2014-04-17 16:20:17 +053074 new_p = {'cpu_arch': 'x86',
75 'cpu_num': '1',
76 'storage': '10000',
77 'memory': '12300'}
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030078
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000079 _, body = self.client.update_node(node['uuid'], properties=new_p)
80 _, node = self.client.show_node(node['uuid'])
Mh Raiesa9bb79d2014-04-17 16:20:17 +053081 self._assertExpected(new_p, node['properties'])
raiesmh08e5d84572014-06-23 09:49:03 +053082
83 @test.attr(type='smoke')
84 def test_validate_driver_interface(self):
Swapnil Kulkarniaa57d6e2014-08-19 10:40:35 +000085 _, body = self.client.validate_driver_interface(self.node['uuid'])
raiesmh08e5d84572014-06-23 09:49:03 +053086 core_interfaces = ['power', 'deploy']
87 for interface in core_interfaces:
88 self.assertIn(interface, body)