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 |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 17 | from ironic_tempest_plugin.tests.scenario.baremetal_manager import \ |
| 18 | BaremetalProvisionStates |
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 | |
| 49 | @test.idempotent_id('03bf7990-bee0-4dd7-bf74-b97ad7b52a4b') |
| 50 | @test.services('baremetal', 'compute', 'image', |
| 51 | 'network', 'object_storage') |
| 52 | def test_baremetal_introspection(self): |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 53 | """This smoke test case follows this set of operations: |
Anton Arefiev | 44f678c | 2016-03-17 12:11:30 +0200 | [diff] [blame] | 54 | |
| 55 | * Fetches expected properties from baremetal flavor |
| 56 | * Removes all properties from nodes |
| 57 | * Sets nodes to manageable state |
| 58 | * Imports introspection rule basic_ops_rule.json |
| 59 | * Inspects nodes |
| 60 | * Verifies all properties are inspected |
| 61 | * Verifies introspection data |
| 62 | * Sets node to available state |
| 63 | * Creates a keypair |
| 64 | * Boots an instance using the keypair |
| 65 | * Deletes the instance |
| 66 | |
| 67 | """ |
| 68 | # prepare introspection rule |
| 69 | rule_path = self.get_rule_path("basic_ops_rule.json") |
| 70 | self.rule_import(rule_path) |
| 71 | self.addCleanup(self.rule_purge) |
| 72 | |
| 73 | for node_id in self.node_ids: |
| 74 | self.introspect_node(node_id) |
| 75 | |
| 76 | # settle down introspection |
| 77 | self.wait_for_introspection_finished(self.node_ids) |
| 78 | for node_id in self.node_ids: |
| 79 | self.wait_provisioning_state( |
| 80 | node_id, 'manageable', |
| 81 | timeout=CONF.baremetal_introspection.ironic_sync_timeout, |
| 82 | interval=self.wait_provisioning_state_interval) |
| 83 | |
| 84 | for node_id in self.node_ids: |
| 85 | node = self.node_show(node_id) |
| 86 | self.verify_node_introspection_data(node) |
| 87 | self.verify_node_flavor(node) |
| 88 | |
| 89 | for node_id in self.node_ids: |
| 90 | self.baremetal_client.set_node_provision_state(node_id, 'provide') |
| 91 | |
| 92 | for node_id in self.node_ids: |
| 93 | self.wait_provisioning_state( |
| 94 | node_id, BaremetalProvisionStates.AVAILABLE, |
| 95 | timeout=CONF.baremetal.active_timeout, |
| 96 | interval=self.wait_provisioning_state_interval) |
| 97 | |
| 98 | self.wait_for_nova_aware_of_bvms() |
| 99 | self.add_keypair() |
Anton Arefiev | 84a09c6 | 2016-07-19 19:35:18 +0300 | [diff] [blame] | 100 | ins, _node = self.boot_instance() |
| 101 | self.terminate_instance(ins) |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 102 | |
| 103 | |
| 104 | class InspectorSmokeTest(manager.InspectorScenarioTest): |
| 105 | |
| 106 | @test.idempotent_id('a702d1f1-88e4-42ce-88ef-cba2d9e3312e') |
| 107 | @test.attr(type='smoke') |
Dmitry Tantsur | b317e11 | 2016-09-09 11:03:27 +0200 | [diff] [blame] | 108 | @test.services('baremetal', 'object_storage') |
Dmitry Tantsur | 290c96b | 2016-07-01 14:22:51 +0200 | [diff] [blame] | 109 | def test_baremetal_introspection(self): |
| 110 | """This smoke test case follows this very basic set of operations: |
| 111 | |
| 112 | * Fetches expected properties from baremetal flavor |
| 113 | * Removes all properties from one node |
| 114 | * Sets the node to manageable state |
| 115 | * Inspects the node |
| 116 | * Sets the node to available state |
| 117 | |
| 118 | """ |
| 119 | # NOTE(dtantsur): we can't silently skip this test because it runs in |
| 120 | # grenade with several other tests, and we won't have any indication |
| 121 | # that it was not run. |
| 122 | assert self.node_ids, "No available nodes" |
| 123 | node_id = next(iter(self.node_ids)) |
| 124 | self.introspect_node(node_id) |
| 125 | |
| 126 | # settle down introspection |
| 127 | self.wait_for_introspection_finished([node_id]) |
| 128 | self.wait_provisioning_state( |
| 129 | node_id, 'manageable', |
| 130 | timeout=CONF.baremetal_introspection.ironic_sync_timeout, |
| 131 | interval=self.wait_provisioning_state_interval) |