Debian Codegraph @

ironic_tempest_plugin/tests/scenario/ironic_standalone/test_cleaning.py

raw
1 #
2 # Copyright 2017 Mirantis Inc.
3 #
4 # Copyright (c) 2022 Dell Inc. or its subsidiaries.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17
18 import json
19 import os
20
21 import jsonschema
22 from jsonschema import exceptions as json_schema_exc
23 from oslo_log import log as logging
24 from tempest.common import utils
25 from tempest import config
26 from tempest.lib import decorators
27
28 from ironic_tempest_plugin import exceptions
29 from ironic_tempest_plugin.tests.scenario import \
30 baremetal_standalone_manager as bsm
31
32 LOG = logging.getLogger(__name__)
33 CONF = config.CONF
34
35
36 class BaremetalCleaningIpmiWholedisk(
37 bsm.BaremetalStandaloneScenarioTest):
38
39 driver = 'ipmi'
40 image_ref = CONF.baremetal.whole_disk_image_ref
41 wholedisk_image = True
42 delete_node = False
43 deploy_interface = 'iscsi'
44 api_microversion = '1.31'
45
46 @classmethod
47 def skip_checks(cls):
48 super(BaremetalCleaningIpmiWholedisk, cls).skip_checks()
49 if CONF.baremetal_feature_enabled.software_raid:
50 raise cls.skipException("Cleaning is covered in the RAID test")
51
52 @decorators.idempotent_id('065238db-1b6d-4d75-a9da-c240f8cbd956')
53 @utils.services('image', 'network')
54 def test_manual_cleaning(self):
55 self.check_manual_partition_cleaning(self.node)
56
57
58 class SoftwareRaidIscsi(bsm.BaremetalStandaloneScenarioTest):
59
60 if 'redfish' in CONF.baremetal.enabled_hardware_types:
61 driver = 'redfish'
62 else:
63 driver = 'ipmi'
64 image_ref = CONF.baremetal.whole_disk_image_ref
65 wholedisk_image = True
66 deploy_interface = 'iscsi'
67 raid_interface = 'agent'
68 api_microversion = '1.55'
69 # Software RAID is always local boot
70 boot_option = 'local'
71 delete_node = False
72
73 raid_config = {
74 "logical_disks": [
75 {
76 "size_gb": "MAX",
77 "raid_level": "1",
78 "controller": "software"
79 },
80 ]
81 }
82
83 @classmethod
84 def skip_checks(cls):
85 super(SoftwareRaidIscsi, cls).skip_checks()
86 if cls.driver == 'ipmi':
87 raise cls.skipException("Testing with redfish driver")
88 if not CONF.baremetal_feature_enabled.software_raid:
89 raise cls.skipException("Software RAID feature is not enabled")
90
91 @decorators.idempotent_id('7ecba4f7-98b8-4ea1-b95e-3ec399f46798')
92 @utils.services('image', 'network')
93 def test_software_raid(self):
94 self.build_raid_and_verify_node(
95 deploy_time=CONF.baremetal_feature_enabled.deploy_time_raid)
96 # NOTE(TheJulia): tearing down/terminating the instance does not
97 # remove the root device hint, so it is best for us to go ahead
98 # and remove it before exiting the test.
99 self.remove_root_device_hint()
100 self.terminate_node(self.node['uuid'], force_delete=True)
101
102
103 class SoftwareRaidDirect(bsm.BaremetalStandaloneScenarioTest):
104
105 if 'redfish' in CONF.baremetal.enabled_hardware_types:
106 driver = 'redfish'
107 else:
108 driver = 'ipmi'
109 image_ref = CONF.baremetal.whole_disk_image_ref
110 wholedisk_image = True
111 deploy_interface = 'direct'
112 raid_interface = 'agent'
113 api_microversion = '1.55'
114 # Software RAID is always local boot
115 boot_option = 'local'
116 delete_node = False
117
118 # TODO(dtantsur): more complex layout in this job
119 raid_config = {
120 "logical_disks": [
121 {
122 "size_gb": "MAX",
123 "raid_level": "1",
124 "controller": "software"
125 },
126 ]
127 }
128
129 @classmethod
130 def skip_checks(cls):
131 super(SoftwareRaidDirect, cls).skip_checks()
132 if cls.driver == 'redfish':
133 raise cls.skipException("Testing with ipmi driver")
134 if not CONF.baremetal_feature_enabled.software_raid:
135 raise cls.skipException("Software RAID feature is not enabled")
136
137 @decorators.idempotent_id('125361ac-0eb3-4d79-8be2-a91936aa3f46')
138 @utils.services('image', 'network')
139 def test_software_raid(self):
140 self.build_raid_and_verify_node(
141 deploy_time=CONF.baremetal_feature_enabled.deploy_time_raid)
142 # NOTE(TheJulia): tearing down/terminating the instance does not
143 # remove the root device hint, so it is best for us to go ahead
144 # and remove it before exiting the test.
145 self.remove_root_device_hint()
146 self.terminate_node(self.node['uuid'], force_delete=True)
147
148
149 class BaremetalIdracManagementCleaning(
150 bsm.BaremetalStandaloneScenarioTest):
151
152 mandatory_attr = ['driver', 'management_interface',
153 'power_interface']
154
155 driver = 'idrac'
156 delete_node = False
157 # Minimum version for manual cleaning is 1.15 (# v1.15: Add ability to
158 # do manual cleaning of nodes). The test cases clean up at the end by
159 # detaching the VIF. Support for VIFs was introduced by version 1.28
160 # (# v1.28: Add vifs subcontroller to node).
161 api_microversion = '1.28'
162
163 @decorators.idempotent_id('d085ff72-abef-4931-a5b0-06efd5f9a037')
164 def test_reset_idrac(self):
165 clean_steps = [
166 {
167 "interface": "management",
168 "step": "reset_idrac"
169 }
170 ]
171 self.manual_cleaning(self.node, clean_steps=clean_steps)
172
173 @decorators.idempotent_id('9252ec6f-6b5b-447e-a323-c52775b88b4e')
174 def test_clear_job_queue(self):
175 clean_steps = [
176 {
177 "interface": "management",
178 "step": "clear_job_queue"
179 }
180 ]
181 self.manual_cleaning(self.node, clean_steps=clean_steps)
182
183 @decorators.idempotent_id('7baeff52-7d6e-4dea-a48f-a85a6bfc9f62')
184 def test_known_good_state(self):
185 clean_steps = [
186 {
187 "interface": "management",
188 "step": "known_good_state"
189 }
190 ]
191 self.manual_cleaning(self.node, clean_steps=clean_steps)
192
193
194 class BaremetalIdracRedfishManagementCleaning(
195 BaremetalIdracManagementCleaning):
196
197 management_interface = 'idrac-redfish'
198 power_interface = 'idrac-redfish'
199
200
201 class BaremetalIdracRaidCleaning(bsm.BaremetalStandaloneScenarioTest):
202
203 mandatory_attr = ['driver', 'raid_interface']
204 image_ref = CONF.baremetal.whole_disk_image_ref
205 wholedisk_image = True
206 storage_inventory_info = None
207 driver = 'idrac'
208 api_microversion = '1.31' # to set raid_interface
209 delete_node = False
210
211 @classmethod
212 def skip_checks(cls):
213 """Validates the storage information passed in file using JSON schema.
214
215 :raises: skipException if,
216 1) storage inventory path is not provided in tempest execution
217 file.
218 2) storage inventory file is not found on given path.
219 :raises: RaidCleaningInventoryValidationFailed if,
220 validation of the storage inventory fails.
221 """
222 super(BaremetalIdracRaidCleaning, cls).skip_checks()
223 storage_inventory = CONF.baremetal.storage_inventory_file
224 if not storage_inventory:
225 raise cls.skipException("Storage inventory file path missing "
226 "in tempest configuration file. "
227 "Skipping Test case.")
228 try:
229 with open(storage_inventory, 'r') as storage_invent_fobj:
230 cls.storage_inventory_info = json.load(storage_invent_fobj)
231 except IOError:
232 msg = ("Storage Inventory file %(inventory)s is not found. "
233 "Skipping Test Case." %
234 {'inventory': storage_inventory})
235 raise cls.skipException(msg)
236 storage_inventory_schema = os.path.join(os.path.dirname(
237 __file__), 'storage_inventory_schema.json')
238 with open(storage_inventory_schema, 'r') as storage_schema_fobj:
239 schema = json.load(storage_schema_fobj)
240 try:
241 jsonschema.validate(cls.storage_inventory_info, schema)
242 except json_schema_exc.ValidationError as e:
243 error_msg = ("Storage Inventory validation error: %(error)s " %
244 {'error': e})
245 raise exceptions.RaidCleaningInventoryValidationFailed(error_msg)
246
247 def _validate_raid_type_and_drives_count(self, raid_type,
248 minimum_drives_required):
249 for controller in (self.storage_inventory_info[
250 'storage_inventory']['controllers']):
251 supported_raid_types = controller['supported_raid_types']
252 physical_disks = [pdisk['id'] for pdisk in (
253 controller['drives'])]
254 if raid_type in supported_raid_types and (
255 minimum_drives_required <= len(physical_disks)):
256 return controller
257 error_msg = ("No Controller present in storage inventory which "
258 "supports RAID type %(raid_type)s "
259 "and has at least %(disk_count)s drives." %
260 {'raid_type': raid_type,
261 'disk_count': minimum_drives_required})
262 raise exceptions.RaidCleaningInventoryValidationFailed(error_msg)
263
264 @decorators.idempotent_id('8a908a3c-f2af-48fb-8553-9163715aa403')
265 @utils.services('image', 'network')
266 def test_hardware_raid(self):
267 controller = self._validate_raid_type_and_drives_count(
268 raid_type='1', minimum_drives_required=2)
269 raid_config = {
270 "logical_disks": [
271 {
272 "size_gb": 40,
273 "raid_level": "1",
274 "controller": controller['id']
275 }
276 ]
277 }
278 self.build_raid_and_verify_node(
279 config=raid_config,
280 deploy_time=CONF.baremetal_feature_enabled.deploy_time_raid,
281 erase_device_metadata=False)
282 self.remove_root_device_hint()
283 self.terminate_node(self.node['uuid'], force_delete=True)
284
285 @decorators.idempotent_id('92fe534d-77f1-422d-84e4-e30fe9e3d928')
286 @utils.services('image', 'network')
287 def test_raid_cleaning_max_size_raid_10(self):
288 controller = self._validate_raid_type_and_drives_count(
289 raid_type='1+0', minimum_drives_required=4)
290 physical_disks = [pdisk['id'] for pdisk in (
291 controller['drives'])]
292 raid_config = {
293 "logical_disks": [
294 {
295 "size_gb": "MAX",
296 "raid_level": "1+0",
297 "controller": controller['id'],
298 "physical_disks": physical_disks
299 }
300 ]
301 }
302 self.build_raid_and_verify_node(
303 config=raid_config,
304 deploy_time=CONF.baremetal_feature_enabled.deploy_time_raid,
305 erase_device_metadata=False)
306 self.remove_root_device_hint()
307 self.terminate_node(self.node['uuid'], force_delete=True)
308
309
310 class BaremetalIdracRedfishRaidCleaning(
311 BaremetalIdracRaidCleaning):
312 raid_interface = 'idrac-redfish'
313
314
315 class BaremetalRedfishFirmwareUpdate(bsm.BaremetalStandaloneScenarioTest):
316
317 api_microversion = '1.68' # to support redfish firmware update
318 driver = 'redfish'
319 delete_node = False
320 image_ref = CONF.baremetal.whole_disk_image_ref
321 wholedisk_image = True
322
323 @classmethod
324 def skip_checks(cls):
325 super(BaremetalRedfishFirmwareUpdate, cls).skip_checks()
326 if not CONF.baremetal.firmware_image_url:
327 raise cls.skipException("Firmware image URL is not "
328 "provided. Skipping test case.")
329 if not CONF.baremetal.firmware_image_checksum:
330 raise cls.skipException("Firmware image SHA1 checksum is not "
331 "provided. Skipping test case.")
332
333 def _firmware_update(self, fw_image_url, fw_image_checksum):
334 steps = [
335 {
336 "interface": "management",
337 "step": "update_firmware",
338 "args": {
339 "firmware_images": [
340 {
341 "url": fw_image_url,
342 "checksum": fw_image_checksum,
343 "wait": 300
344 }
345 ]
346 }
347 }
348 ]
349 self.manual_cleaning(self.node, clean_steps=steps)
350
351 @utils.services('network')
352 @decorators.idempotent_id('360e0c0e-3c17-4d2e-b052-55a932c1a4c7')
353 def test_firmware_update(self):
354 # WARNING: Removing power from a server while it is in the process of
355 # updating firmware may result in devices in the server, or the server
356 # itself becoming inoperable.
357 # Execution of firmware test case needs careful execution as it
358 # changes state of server, may result in break down of server on
359 # interruption. As it deals with firmware of component, make sure
360 # to provide proper image url path while testing with correct SHA1
361 # checksum of image.
362 self._firmware_update(CONF.baremetal.firmware_image_url,
363 CONF.baremetal.firmware_image_checksum)
364 if (CONF.baremetal.firmware_rollback_image_url
365 and CONF.baremetal.firmware_rollback_image_checksum):
366 self.addCleanup(self._firmware_update,
367 CONF.baremetal.firmware_rollback_image_url,
368 CONF.baremetal.firmware_rollback_image_checksum)
369
370
371 class BaremetalIdracRedfishFirmwareUpdate(BaremetalRedfishFirmwareUpdate):
372
373 driver = 'idrac'
374 boot_interface = 'ipxe'
375 management_interface = 'idrac-redfish'
376 power_interface = 'idrac-redfish'
377
378
379 class BaremetalIdracRedfishConfigurationMolds(
380 bsm.BaremetalStandaloneScenarioTest):
381
382 api_microversion = '1.72' # to support configuration molds functionality
383 delete_node = False
384 image_ref = CONF.baremetal.whole_disk_image_ref
385 driver = 'idrac'
386 boot_interface = 'ipxe'
387 management_interface = 'idrac-redfish'
388 power_interface = 'idrac-redfish'
389 wholedisk_image = True
390
391 @utils.services('network')
392 @decorators.idempotent_id('69386cf6-bbf2-451e-b927-f68c66075f02')
393 def test_configuration_molds_export(self):
394 if not CONF.baremetal.export_location:
395 raise self.skipException("Export configuration location path "
396 "is not provided. Skipping test case. "
397 "Make sure to provide correct "
398 "configuration path in which "
399 "configuration would be exported. "
400 "In case of Swift object storage, "
401 "make to sure to provide proper "
402 "container path.")
403
404 steps = [
405 {
406 "interface": "management",
407 "step": "export_configuration",
408 "args": {
409 "export_configuration_location":
410 CONF.baremetal.export_location
411 }
412 }
413 ]
414 self.manual_cleaning(self.node, clean_steps=steps)
415
416 @utils.services('network')
417 @decorators.idempotent_id('cad15719-c293-4338-8fa9-986ef02b4682')
418 def test_configuration_molds_import(self):
419 if not CONF.baremetal.import_location:
420 raise self.skipException("Import configuration JSON file location "
421 "is not provided. Make sure to provide "
422 "correct configuration file with proper "
423 "configuration which needs to be tested "
424 "during execution of this test. "
425 "Skipping test case.")
426 steps = [
427 {
428 "interface": "management",
429 "step": "import_configuration",
430 "args": {
431 "import_configuration_location":
432 CONF.baremetal.import_location
433 }
434 }
435 ]
436 self.manual_cleaning(self.node, clean_steps=steps)
437 if CONF.baremetal.rollback_import_location:
438 rollback_steps = [
439 {
440 "interface": "management",
441 "step": "import_configuration",
442 "args": {
443 "import_configuration_location":
444 CONF.baremetal.rollback_import_location
445 }
446 }
447 ]
448 self.addCleanup(self.manual_cleaning, self.node,
449 clean_steps=rollback_steps)