blob: b9b9b559d625da575e612cbce42596a42997830c [file] [log] [blame]
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest.api.baremetal.admin import base
from tempest import exceptions as exc
from tempest import test
class TestNodes(base.BaseBaremetalTest):
'''Tests for baremetal nodes.'''
def setUp(self):
super(TestNodes, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'])
def _assertExpected(self, expected, actual):
# Check if not expected keys/values exists in actual response body
for key, value in six.iteritems(expected):
if key not in ('created_at', 'updated_at'):
self.assertIn(key, actual)
self.assertEqual(value, actual[key])
@test.attr(type='smoke')
def test_create_node(self):
params = {'cpu_arch': 'x86_64',
'cpu_num': '12',
'storage': '10240',
'memory': '1024'}
_, body = self.create_node(self.chassis['uuid'], **params)
self._assertExpected(params, body['properties'])
@test.attr(type='smoke')
def test_delete_node(self):
_, node = self.create_node(self.chassis['uuid'])
self.delete_node(node['uuid'])
self.assertRaises(exc.NotFound, self.client.show_node, node['uuid'])
@test.attr(type='smoke')
def test_show_node(self):
_, loaded_node = self.client.show_node(self.node['uuid'])
self._assertExpected(self.node, loaded_node)
@test.attr(type='smoke')
def test_list_nodes(self):
_, body = self.client.list_nodes()
self.assertIn(self.node['uuid'],
[i['uuid'] for i in body['nodes']])
@test.attr(type='smoke')
def test_update_node(self):
props = {'cpu_arch': 'x86_64',
'cpu_num': '12',
'storage': '10',
'memory': '128'}
_, node = self.create_node(self.chassis['uuid'], **props)
new_p = {'cpu_arch': 'x86',
'cpu_num': '1',
'storage': '10000',
'memory': '12300'}
_, body = self.client.update_node(node['uuid'], properties=new_p)
_, node = self.client.show_node(node['uuid'])
self._assertExpected(new_p, node['properties'])
@test.attr(type='smoke')
def test_validate_driver_interface(self):
_, body = self.client.validate_driver_interface(self.node['uuid'])
core_interfaces = ['power', 'deploy']
for interface in core_interfaces:
self.assertIn(interface, body)
@test.attr(type='smoke')
def test_set_node_boot_device(self):
body = self.client.set_node_boot_device(self.node['uuid'], 'pxe')
# No content
self.assertEqual('', body)
@test.attr(type='smoke')
def test_get_node_boot_device(self):
body = self.client.get_node_boot_device(self.node['uuid'])
self.assertIn('boot_device', body)
self.assertIn('persistent', body)
self.assertTrue(isinstance(body['boot_device'], six.string_types))
self.assertTrue(isinstance(body['persistent'], bool))
@test.attr(type='smoke')
def test_get_node_supported_boot_devices(self):
body = self.client.get_node_supported_boot_devices(self.node['uuid'])
self.assertIn('supported_boot_devices', body)
self.assertTrue(isinstance(body['supported_boot_devices'], list))
@test.attr(type='smoke')
def test_get_console(self):
_, body = self.client.get_console(self.node['uuid'])
con_info = ['console_enabled', 'console_info']
for key in con_info:
self.assertIn(key, body)
@test.attr(type='smoke')
def test_set_console_mode(self):
self.client.set_console_mode(self.node['uuid'], True)
_, body = self.client.get_console(self.node['uuid'])
self.assertEqual(True, body['console_enabled'])