Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 1 | # 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 | |
John L. Villalovos | 2c22aad | 2017-10-12 14:56:24 -0700 | [diff] [blame^] | 13 | from ironic_tempest_plugin.tests.scenario import baremetal_manager |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 14 | from tempest.config import CONF |
ghanshyam | 159fe89 | 2017-01-27 06:35:37 +0000 | [diff] [blame] | 15 | from tempest.lib import decorators |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 16 | from tempest import test # noqa |
| 17 | |
| 18 | from ironic_inspector.test.inspector_tempest_plugin.tests import manager |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 19 | |
| 20 | |
| 21 | class InspectorBasicTest(manager.InspectorScenarioTest): |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 22 | |
| 23 | def verify_node_introspection_data(self, node): |
| 24 | self.assertEqual('yes', node['extra']['rule_success']) |
| 25 | data = self.introspection_data(node['uuid']) |
| 26 | self.assertEqual(data['cpu_arch'], |
| 27 | self.flavor['properties']['cpu_arch']) |
| 28 | self.assertEqual(int(data['memory_mb']), |
| 29 | int(self.flavor['ram'])) |
| 30 | self.assertEqual(int(data['cpus']), int(self.flavor['vcpus'])) |
| 31 | |
| 32 | def verify_node_flavor(self, node): |
| 33 | expected_cpus = self.flavor['vcpus'] |
| 34 | expected_memory_mb = self.flavor['ram'] |
| 35 | expected_cpu_arch = self.flavor['properties']['cpu_arch'] |
| 36 | disk_size = self.flavor['disk'] |
| 37 | ephemeral_size = self.flavor['OS-FLV-EXT-DATA:ephemeral'] |
| 38 | expected_local_gb = disk_size + ephemeral_size |
| 39 | |
| 40 | self.assertEqual(expected_cpus, |
| 41 | int(node['properties']['cpus'])) |
| 42 | self.assertEqual(expected_memory_mb, |
| 43 | int(node['properties']['memory_mb'])) |
| 44 | self.assertEqual(expected_local_gb, |
| 45 | int(node['properties']['local_gb'])) |
| 46 | self.assertEqual(expected_cpu_arch, |
| 47 | node['properties']['cpu_arch']) |
| 48 | |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 49 | def verify_introspection_aborted(self, uuid): |
| 50 | status = self.introspection_status(uuid) |
| 51 | |
| 52 | self.assertEqual('Canceled by operator', status['error']) |
| 53 | self.assertTrue(status['finished']) |
| 54 | |
| 55 | self.wait_provisioning_state( |
| 56 | uuid, 'inspect failed', |
| 57 | timeout=CONF.baremetal.active_timeout, |
| 58 | interval=self.wait_provisioning_state_interval) |
| 59 | |
ghanshyam | 159fe89 | 2017-01-27 06:35:37 +0000 | [diff] [blame] | 60 | @decorators.idempotent_id('03bf7990-bee0-4dd7-bf74-b97ad7b52a4b') |
dparalen | 63404e2 | 2016-12-19 14:05:33 +0100 | [diff] [blame] | 61 | @test.services('compute', 'image', 'network', 'object_storage') |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 62 | def test_baremetal_introspection(self): |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 63 | """This smoke test case follows this set of operations: |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 64 | |
| 65 | * Fetches expected properties from baremetal flavor |
| 66 | * Removes all properties from nodes |
| 67 | * Sets nodes to manageable state |
| 68 | * Imports introspection rule basic_ops_rule.json |
| 69 | * Inspects nodes |
| 70 | * Verifies all properties are inspected |
| 71 | * Verifies introspection data |
| 72 | * Sets node to available state |
| 73 | * Creates a keypair |
| 74 | * Boots an instance using the keypair |
| 75 | * Deletes the instance |
| 76 | |
| 77 | """ |
| 78 | # prepare introspection rule |
| 79 | rule_path = self.get_rule_path("basic_ops_rule.json") |
| 80 | self.rule_import(rule_path) |
| 81 | self.addCleanup(self.rule_purge) |
| 82 | |
| 83 | for node_id in self.node_ids: |
| 84 | self.introspect_node(node_id) |
| 85 | |
| 86 | # settle down introspection |
| 87 | self.wait_for_introspection_finished(self.node_ids) |
| 88 | for node_id in self.node_ids: |
| 89 | self.wait_provisioning_state( |
| 90 | node_id, 'manageable', |
| 91 | timeout=CONF.baremetal_introspection.ironic_sync_timeout, |
| 92 | interval=self.wait_provisioning_state_interval) |
| 93 | |
| 94 | for node_id in self.node_ids: |
| 95 | node = self.node_show(node_id) |
| 96 | self.verify_node_introspection_data(node) |
| 97 | self.verify_node_flavor(node) |
| 98 | |
| 99 | for node_id in self.node_ids: |
| 100 | self.baremetal_client.set_node_provision_state(node_id, 'provide') |
| 101 | |
| 102 | for node_id in self.node_ids: |
| 103 | self.wait_provisioning_state( |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 104 | node_id, baremetal_manager.BaremetalProvisionStates.AVAILABLE, |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 105 | timeout=CONF.baremetal.active_timeout, |
| 106 | interval=self.wait_provisioning_state_interval) |
| 107 | |
| 108 | self.wait_for_nova_aware_of_bvms() |
| 109 | self.add_keypair() |
Anton Arefiev | 84a09c6 | 2016-07-19 19:35:18 +0300 | [diff] [blame] | 110 | ins, _node = self.boot_instance() |
| 111 | self.terminate_instance(ins) |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 112 | |
ghanshyam | 159fe89 | 2017-01-27 06:35:37 +0000 | [diff] [blame] | 113 | @decorators.idempotent_id('70ca3070-184b-4b7d-8892-e977d2bc2870') |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 114 | def test_introspection_abort(self): |
| 115 | """This smoke test case follows this very basic set of operations: |
| 116 | |
| 117 | * Start nodes introspection |
| 118 | * Wait until nodes power on |
| 119 | * Abort introspection |
| 120 | * Verifies nodes status and power state |
| 121 | |
| 122 | """ |
| 123 | # start nodes introspection |
| 124 | for node_id in self.node_ids: |
| 125 | self.introspect_node(node_id, remove_props=False) |
| 126 | |
| 127 | # wait for nodes power on |
| 128 | for node_id in self.node_ids: |
| 129 | self.wait_power_state( |
| 130 | node_id, |
| 131 | baremetal_manager.BaremetalPowerStates.POWER_ON) |
| 132 | |
| 133 | # abort introspection |
| 134 | for node_id in self.node_ids: |
| 135 | self.introspection_abort(node_id) |
| 136 | |
| 137 | # wait for nodes power off |
| 138 | for node_id in self.node_ids: |
| 139 | self.wait_power_state( |
| 140 | node_id, |
| 141 | baremetal_manager.BaremetalPowerStates.POWER_OFF) |
| 142 | |
| 143 | # verify nodes status and provision state |
| 144 | for node_id in self.node_ids: |
| 145 | self.verify_introspection_aborted(node_id) |
| 146 | |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 147 | |
| 148 | class InspectorSmokeTest(manager.InspectorScenarioTest): |
| 149 | |
ghanshyam | 159fe89 | 2017-01-27 06:35:37 +0000 | [diff] [blame] | 150 | @decorators.idempotent_id('a702d1f1-88e4-42ce-88ef-cba2d9e3312e') |
Ngo Quoc Cuong | 5d84570 | 2017-05-22 13:23:20 +0700 | [diff] [blame] | 151 | @decorators.attr(type='smoke') |
dparalen | 63404e2 | 2016-12-19 14:05:33 +0100 | [diff] [blame] | 152 | @test.services('object_storage') |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 153 | def test_baremetal_introspection(self): |
| 154 | """This smoke test case follows this very basic set of operations: |
| 155 | |
| 156 | * Fetches expected properties from baremetal flavor |
| 157 | * Removes all properties from one node |
| 158 | * Sets the node to manageable state |
| 159 | * Inspects the node |
| 160 | * Sets the node to available state |
| 161 | |
| 162 | """ |
| 163 | # NOTE(dtantsur): we can't silently skip this test because it runs in |
| 164 | # grenade with several other tests, and we won't have any indication |
| 165 | # that it was not run. |
| 166 | assert self.node_ids, "No available nodes" |
| 167 | node_id = next(iter(self.node_ids)) |
| 168 | self.introspect_node(node_id) |
| 169 | |
| 170 | # settle down introspection |
| 171 | self.wait_for_introspection_finished([node_id]) |
| 172 | self.wait_provisioning_state( |
| 173 | node_id, 'manageable', |
| 174 | timeout=CONF.baremetal_introspection.ironic_sync_timeout, |
| 175 | interval=self.wait_provisioning_state_interval) |