| 1 |
# Copyright (c) 2022 Dell Inc. or its subsidiaries. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
# not use this file except in compliance with the License. You may obtain |
| 5 |
# a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 |
# License for the specific language governing permissions and limitations |
| 13 |
# under the License. |
| 14 |
|
| 15 |
from tempest import config |
| 16 |
from tempest.lib import decorators |
| 17 |
|
| 18 |
from ironic_tempest_plugin.tests.scenario import \ |
| 19 |
baremetal_standalone_manager as bsm |
| 20 |
|
| 21 |
CONF = config.CONF |
| 22 |
|
| 23 |
|
| 24 |
class BaremetalInspectBase: |
| 25 |
|
| 26 |
mandatory_attr = ['driver', 'inspect_interface'] |
| 27 |
# (# v1.31: Support for updating inspect_interface). |
| 28 |
api_microversion = '1.31' |
| 29 |
delete_node = False |
| 30 |
wait_provisioning_state_interval = 1 |
| 31 |
|
| 32 |
def _verify_node_inspection_data(self, node): |
| 33 |
self.assertIn(node['properties']['cpu_arch'], ['x86_64', 'aarch64']) |
| 34 |
|
| 35 |
@decorators.idempotent_id('47ea4487-4720-43e8-a024-53ae82f8c264') |
| 36 |
def test_baremetal_inspect(self): |
| 37 |
"""This test case follows this set of operations: |
| 38 |
|
| 39 |
* Sets nodes to manageable state |
| 40 |
* Inspects nodes |
| 41 |
* Verifies inspection data |
| 42 |
* Sets node to available state |
| 43 |
""" |
| 44 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 45 |
'manage') |
| 46 |
_, node = self.baremetal_client.show_node(self.node['uuid']) |
| 47 |
if 'cpu_arch' in node['properties']: |
| 48 |
new_properties = node['properties'].copy() |
| 49 |
new_properties.pop('cpu_arch') |
| 50 |
self.baremetal_client.update_node(self.node['uuid'], |
| 51 |
properties=new_properties) |
| 52 |
|
| 53 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 54 |
'inspect') |
| 55 |
self.wait_provisioning_state( |
| 56 |
self.node['uuid'], 'manageable', |
| 57 |
timeout=CONF.baremetal.inspect_timeout, |
| 58 |
interval=self.wait_provisioning_state_interval) |
| 59 |
|
| 60 |
_, node = self.baremetal_client.show_node(self.node['uuid']) |
| 61 |
self._verify_node_inspection_data(node) |
| 62 |
|
| 63 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 64 |
'provide') |
| 65 |
self.wait_provisioning_state(self.node['uuid'], 'available') |
| 66 |
|
| 67 |
|
| 68 |
class BaremetalRedfishAgentInspect(BaremetalInspectBase, |
| 69 |
bsm.BaremetalStandaloneScenarioTest): |
| 70 |
driver = 'redfish' |
| 71 |
inspect_interface = 'agent' |
| 72 |
wait_provisioning_state_interval = 15 |
| 73 |
# 1.81 adds support for inventory API |
| 74 |
api_microversion = '1.81' |
| 75 |
|
| 76 |
def _verify_node_inspection_data(self, node): |
| 77 |
super()._verify_node_inspection_data(node) |
| 78 |
inspection_data = self.baremetal_client.show_inventory( |
| 79 |
self.node['uuid']) |
| 80 |
self.assertEqual({'inventory', 'plugin_data'}, set(inspection_data)) |
| 81 |
|
| 82 |
# Inventory sanity check |
| 83 |
inventory = inspection_data['inventory'] |
| 84 |
self.assertGreater(inventory['cpu']['count'], 0) |
| 85 |
self.assertGreater(inventory['memory']['physical_mb'], 256) |
| 86 |
self.assertGreater(len(inventory['disks']), 0) |
| 87 |
self.assertGreater(len(inventory['interfaces']), 0) |
| 88 |
|
| 89 |
@decorators.idempotent_id('82670a85-49b7-4d28-b8a8-6e18b0d4c8d1') |
| 90 |
def test_inspect_abort(self): |
| 91 |
_, node = self.baremetal_client.show_node(self.node['uuid']) |
| 92 |
current_state = node['provision_state'] |
| 93 |
|
| 94 |
def cleanup(): |
| 95 |
nonlocal current_state |
| 96 |
|
| 97 |
if current_state == 'inspect failed': |
| 98 |
self.baremetal_client.set_node_provision_state( |
| 99 |
self.node['uuid'], 'manage') |
| 100 |
self.wait_provisioning_state(self.node['uuid'], 'manageable') |
| 101 |
current_state = 'manageable' |
| 102 |
|
| 103 |
if current_state == 'manageable': |
| 104 |
self.baremetal_client.set_node_provision_state( |
| 105 |
self.node['uuid'], 'provide') |
| 106 |
self.wait_provisioning_state(self.node['uuid'], 'available') |
| 107 |
|
| 108 |
self.addCleanup(cleanup) |
| 109 |
|
| 110 |
if current_state != 'manageable': |
| 111 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 112 |
'manage') |
| 113 |
current_state = 'manageable' |
| 114 |
|
| 115 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 116 |
'inspect') |
| 117 |
self.wait_provisioning_state( |
| 118 |
self.node['uuid'], 'inspect wait', |
| 119 |
timeout=300, interval=5) |
| 120 |
|
| 121 |
self.baremetal_client.set_node_provision_state(self.node['uuid'], |
| 122 |
'abort') |
| 123 |
self.wait_provisioning_state( |
| 124 |
self.node['uuid'], 'inspect failed', |
| 125 |
timeout=60, interval=1) |
| 126 |
current_state = 'inspect failed' |
| 127 |
|
| 128 |
|
| 129 |
class BaremetalIdracInspect(BaremetalInspectBase, |
| 130 |
bsm.BaremetalStandaloneScenarioTest): |
| 131 |
driver = 'idrac' |
| 132 |
|
| 133 |
def _verify_node_inspection_data(self, node): |
| 134 |
super()._verify_node_inspection_data(node) |
| 135 |
self.assertGreater(int(node['properties']['memory_mb']), 0) |
| 136 |
self.assertGreater(int(node['properties']['cpus']), 0) |
| 137 |
self.assertGreater(int(node['properties']['local_gb']), 0) |
| 138 |
|
| 139 |
|
| 140 |
class BaremetalIdracRedfishInspect(BaremetalIdracInspect): |
| 141 |
inspect_interface = 'idrac-redfish' |