blob: 7d9cc72d1df37d603fc0bd571b152b5b59375f56 [file] [log] [blame]
Anton Arefiev44f678c2016-03-17 12:11:30 +02001# 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 Arefiev44f678c2016-03-17 12:11:30 +020013from tempest.config import CONF
14from tempest import test # noqa
15
16from ironic_inspector.test.inspector_tempest_plugin.tests import manager
Sergii Nozhka1eb13cf2016-11-04 17:15:50 +020017from ironic_tempest_plugin.tests.scenario import baremetal_manager
Anton Arefiev44f678c2016-03-17 12:11:30 +020018
19
20class InspectorBasicTest(manager.InspectorScenarioTest):
Anton Arefiev44f678c2016-03-17 12:11:30 +020021
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 Nozhka1eb13cf2016-11-04 17:15:50 +020048 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 Arefiev44f678c2016-03-17 12:11:30 +020059 @test.idempotent_id('03bf7990-bee0-4dd7-bf74-b97ad7b52a4b')
dparalen63404e22016-12-19 14:05:33 +010060 @test.services('compute', 'image', 'network', 'object_storage')
Anton Arefiev44f678c2016-03-17 12:11:30 +020061 def test_baremetal_introspection(self):
Dmitry Tantsur290c96b2016-07-01 14:22:51 +020062 """This smoke test case follows this set of operations:
Anton Arefiev44f678c2016-03-17 12:11:30 +020063
64 * Fetches expected properties from baremetal flavor
65 * Removes all properties from nodes
66 * Sets nodes to manageable state
67 * Imports introspection rule basic_ops_rule.json
68 * Inspects nodes
69 * Verifies all properties are inspected
70 * Verifies introspection data
71 * Sets node to available state
72 * Creates a keypair
73 * Boots an instance using the keypair
74 * Deletes the instance
75
76 """
77 # prepare introspection rule
78 rule_path = self.get_rule_path("basic_ops_rule.json")
79 self.rule_import(rule_path)
80 self.addCleanup(self.rule_purge)
81
82 for node_id in self.node_ids:
83 self.introspect_node(node_id)
84
85 # settle down introspection
86 self.wait_for_introspection_finished(self.node_ids)
87 for node_id in self.node_ids:
88 self.wait_provisioning_state(
89 node_id, 'manageable',
90 timeout=CONF.baremetal_introspection.ironic_sync_timeout,
91 interval=self.wait_provisioning_state_interval)
92
93 for node_id in self.node_ids:
94 node = self.node_show(node_id)
95 self.verify_node_introspection_data(node)
96 self.verify_node_flavor(node)
97
98 for node_id in self.node_ids:
99 self.baremetal_client.set_node_provision_state(node_id, 'provide')
100
101 for node_id in self.node_ids:
102 self.wait_provisioning_state(
Sergii Nozhka1eb13cf2016-11-04 17:15:50 +0200103 node_id, baremetal_manager.BaremetalProvisionStates.AVAILABLE,
Anton Arefiev44f678c2016-03-17 12:11:30 +0200104 timeout=CONF.baremetal.active_timeout,
105 interval=self.wait_provisioning_state_interval)
106
107 self.wait_for_nova_aware_of_bvms()
108 self.add_keypair()
Anton Arefiev84a09c62016-07-19 19:35:18 +0300109 ins, _node = self.boot_instance()
110 self.terminate_instance(ins)
Dmitry Tantsur290c96b2016-07-01 14:22:51 +0200111
Sergii Nozhka1eb13cf2016-11-04 17:15:50 +0200112 @test.idempotent_id('70ca3070-184b-4b7d-8892-e977d2bc2870')
Sergii Nozhka1eb13cf2016-11-04 17:15:50 +0200113 def test_introspection_abort(self):
114 """This smoke test case follows this very basic set of operations:
115
116 * Start nodes introspection
117 * Wait until nodes power on
118 * Abort introspection
119 * Verifies nodes status and power state
120
121 """
122 # start nodes introspection
123 for node_id in self.node_ids:
124 self.introspect_node(node_id, remove_props=False)
125
126 # wait for nodes power on
127 for node_id in self.node_ids:
128 self.wait_power_state(
129 node_id,
130 baremetal_manager.BaremetalPowerStates.POWER_ON)
131
132 # abort introspection
133 for node_id in self.node_ids:
134 self.introspection_abort(node_id)
135
136 # wait for nodes power off
137 for node_id in self.node_ids:
138 self.wait_power_state(
139 node_id,
140 baremetal_manager.BaremetalPowerStates.POWER_OFF)
141
142 # verify nodes status and provision state
143 for node_id in self.node_ids:
144 self.verify_introspection_aborted(node_id)
145
Dmitry Tantsur290c96b2016-07-01 14:22:51 +0200146
147class InspectorSmokeTest(manager.InspectorScenarioTest):
148
149 @test.idempotent_id('a702d1f1-88e4-42ce-88ef-cba2d9e3312e')
150 @test.attr(type='smoke')
dparalen63404e22016-12-19 14:05:33 +0100151 @test.services('object_storage')
Dmitry Tantsur290c96b2016-07-01 14:22:51 +0200152 def test_baremetal_introspection(self):
153 """This smoke test case follows this very basic set of operations:
154
155 * Fetches expected properties from baremetal flavor
156 * Removes all properties from one node
157 * Sets the node to manageable state
158 * Inspects the node
159 * Sets the node to available state
160
161 """
162 # NOTE(dtantsur): we can't silently skip this test because it runs in
163 # grenade with several other tests, and we won't have any indication
164 # that it was not run.
165 assert self.node_ids, "No available nodes"
166 node_id = next(iter(self.node_ids))
167 self.introspect_node(node_id)
168
169 # settle down introspection
170 self.wait_for_introspection_finished([node_id])
171 self.wait_provisioning_state(
172 node_id, 'manageable',
173 timeout=CONF.baremetal_introspection.ironic_sync_timeout,
174 interval=self.wait_provisioning_state_interval)