blob: fc6785499b271912afe1d4bc63d575ec85da35fb [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
Mh Raiesa9bb79d2014-04-17 16:20:17 +053043 resp, body = self.create_node(self.chassis['uuid'], **params)
44 self.assertEqual('201', resp['status'])
45 self._assertExpected(params, body['properties'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030046
47 @test.attr(type='smoke')
48 def test_delete_node(self):
Mh Raiesa9bb79d2014-04-17 16:20:17 +053049 resp, node = self.create_node(self.chassis['uuid'])
50 self.assertEqual('201', resp['status'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030051
Mh Raiesa9bb79d2014-04-17 16:20:17 +053052 resp = self.delete_node(node['uuid'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030053
54 self.assertEqual(resp['status'], '204')
Mh Raiesa9bb79d2014-04-17 16:20:17 +053055 self.assertRaises(exc.NotFound, self.client.show_node, node['uuid'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030056
57 @test.attr(type='smoke')
58 def test_show_node(self):
Mh Raiesa9bb79d2014-04-17 16:20:17 +053059 resp, loaded_node = self.client.show_node(self.node['uuid'])
60 self.assertEqual('200', resp['status'])
61 self._assertExpected(self.node, loaded_node)
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030062
63 @test.attr(type='smoke')
64 def test_list_nodes(self):
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030065 resp, body = self.client.list_nodes()
Mh Raiesa9bb79d2014-04-17 16:20:17 +053066 self.assertEqual('200', resp['status'])
67 self.assertIn(self.node['uuid'],
68 [i['uuid'] for i in body['nodes']])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030069
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 Raiesa9bb79d2014-04-17 16:20:17 +053077 resp, node = self.create_node(self.chassis['uuid'], **props)
78 self.assertEqual('201', resp['status'])
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030079
Mh Raiesa9bb79d2014-04-17 16:20:17 +053080 new_p = {'cpu_arch': 'x86',
81 'cpu_num': '1',
82 'storage': '10000',
83 'memory': '12300'}
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030084
Mh Raiesa9bb79d2014-04-17 16:20:17 +053085 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'])
raiesmh08e5d84572014-06-23 09:49:03 +053090
91 @test.attr(type='smoke')
92 def test_validate_driver_interface(self):
93 resp, body = self.client.validate_driver_interface(self.node['uuid'])
94 self.assertEqual('200', resp['status'])
95 core_interfaces = ['power', 'deploy']
96 for interface in core_interfaces:
97 self.assertIn(interface, body)