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 | |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 13 | from tempest.config import CONF |
| 14 | from tempest import test # noqa |
| 15 | |
| 16 | from ironic_inspector.test.inspector_tempest_plugin.tests import manager |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 17 | from ironic_tempest_plugin.tests.scenario import baremetal_manager |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 18 | |
| 19 | |
| 20 | class InspectorBasicTest(manager.InspectorScenarioTest): |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 21 | |
| 22 | def verify_node_introspection_data(self, node): |
| 23 | self.assertEqual('yes', node['extra']['rule_success']) |
| 24 | data = self.introspection_data(node['uuid']) |
| 25 | self.assertEqual(data['cpu_arch'], |
| 26 | self.flavor['properties']['cpu_arch']) |
| 27 | self.assertEqual(int(data['memory_mb']), |
| 28 | int(self.flavor['ram'])) |
| 29 | self.assertEqual(int(data['cpus']), int(self.flavor['vcpus'])) |
| 30 | |
| 31 | def verify_node_flavor(self, node): |
| 32 | expected_cpus = self.flavor['vcpus'] |
| 33 | expected_memory_mb = self.flavor['ram'] |
| 34 | expected_cpu_arch = self.flavor['properties']['cpu_arch'] |
| 35 | disk_size = self.flavor['disk'] |
| 36 | ephemeral_size = self.flavor['OS-FLV-EXT-DATA:ephemeral'] |
| 37 | expected_local_gb = disk_size + ephemeral_size |
| 38 | |
| 39 | self.assertEqual(expected_cpus, |
| 40 | int(node['properties']['cpus'])) |
| 41 | self.assertEqual(expected_memory_mb, |
| 42 | int(node['properties']['memory_mb'])) |
| 43 | self.assertEqual(expected_local_gb, |
| 44 | int(node['properties']['local_gb'])) |
| 45 | self.assertEqual(expected_cpu_arch, |
| 46 | node['properties']['cpu_arch']) |
| 47 | |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 48 | def verify_introspection_aborted(self, uuid): |
| 49 | status = self.introspection_status(uuid) |
| 50 | |
| 51 | self.assertEqual('Canceled by operator', status['error']) |
| 52 | self.assertTrue(status['finished']) |
| 53 | |
| 54 | self.wait_provisioning_state( |
| 55 | uuid, 'inspect failed', |
| 56 | timeout=CONF.baremetal.active_timeout, |
| 57 | interval=self.wait_provisioning_state_interval) |
| 58 | |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 59 | @test.idempotent_id('03bf7990-bee0-4dd7-bf74-b97ad7b52a4b') |
| 60 | @test.services('baremetal', 'compute', 'image', |
| 61 | 'network', 'object_storage') |
| 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 | |
Sergii Nozhka | 1eb13cf | 2016-11-04 17:15:50 +0200 | [diff] [blame] | 113 | @test.idempotent_id('70ca3070-184b-4b7d-8892-e977d2bc2870') |
| 114 | @test.services('baremetal') |
| 115 | def test_introspection_abort(self): |
| 116 | """This smoke test case follows this very basic set of operations: |
| 117 | |
| 118 | * Start nodes introspection |
| 119 | * Wait until nodes power on |
| 120 | * Abort introspection |
| 121 | * Verifies nodes status and power state |
| 122 | |
| 123 | """ |
| 124 | # start nodes introspection |
| 125 | for node_id in self.node_ids: |
| 126 | self.introspect_node(node_id, remove_props=False) |
| 127 | |
| 128 | # wait for nodes power on |
| 129 | for node_id in self.node_ids: |
| 130 | self.wait_power_state( |
| 131 | node_id, |
| 132 | baremetal_manager.BaremetalPowerStates.POWER_ON) |
| 133 | |
| 134 | # abort introspection |
| 135 | for node_id in self.node_ids: |
| 136 | self.introspection_abort(node_id) |
| 137 | |
| 138 | # wait for nodes power off |
| 139 | for node_id in self.node_ids: |
| 140 | self.wait_power_state( |
| 141 | node_id, |
| 142 | baremetal_manager.BaremetalPowerStates.POWER_OFF) |
| 143 | |
| 144 | # verify nodes status and provision state |
| 145 | for node_id in self.node_ids: |
| 146 | self.verify_introspection_aborted(node_id) |
| 147 | |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 148 | |
| 149 | class InspectorSmokeTest(manager.InspectorScenarioTest): |
| 150 | |
| 151 | @test.idempotent_id('a702d1f1-88e4-42ce-88ef-cba2d9e3312e') |
| 152 | @test.attr(type='smoke') |
Dmitry Tantsur | b317e11 | 2016-09-09 11:03:27 +0200 | [diff] [blame] | 153 | @test.services('baremetal', 'object_storage') |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 154 | def test_baremetal_introspection(self): |
| 155 | """This smoke test case follows this very basic set of operations: |
| 156 | |
| 157 | * Fetches expected properties from baremetal flavor |
| 158 | * Removes all properties from one node |
| 159 | * Sets the node to manageable state |
| 160 | * Inspects the node |
| 161 | * Sets the node to available state |
| 162 | |
| 163 | """ |
| 164 | # NOTE(dtantsur): we can't silently skip this test because it runs in |
| 165 | # grenade with several other tests, and we won't have any indication |
| 166 | # that it was not run. |
| 167 | assert self.node_ids, "No available nodes" |
| 168 | node_id = next(iter(self.node_ids)) |
| 169 | self.introspect_node(node_id) |
| 170 | |
| 171 | # settle down introspection |
| 172 | self.wait_for_introspection_finished([node_id]) |
| 173 | self.wait_provisioning_state( |
| 174 | node_id, 'manageable', |
| 175 | timeout=CONF.baremetal_introspection.ironic_sync_timeout, |
| 176 | interval=self.wait_provisioning_state_interval) |