blob: 82c6b5d842faaf172339629341892a63ef3f2766 [file] [log] [blame]
Adam Gandelman4a48a602014-03-20 18:23:18 -07001#
2# Copyright 2014 Hewlett-Packard Development Company, L.P.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest import config
17from tempest.openstack.common import log as logging
18from tempest.scenario import manager
19from tempest import test
20
21CONF = config.CONF
22
23LOG = logging.getLogger(__name__)
24
25
David Shrewsbury06f7f8a2014-05-20 13:55:57 -040026class BaremetalBasicOpsPXESSH(manager.BaremetalScenarioTest):
Adam Gandelman4a48a602014-03-20 18:23:18 -070027 """
28 This smoke test tests the pxe_ssh Ironic driver. It follows this basic
29 set of operations:
30 * Creates a keypair
31 * Boots an instance using the keypair
32 * Monitors the associated Ironic node for power and
33 expected state transitions
34 * Validates Ironic node's driver_info has been properly
35 updated
36 * Validates Ironic node's port data has been properly updated
37 * Verifies SSH connectivity using created keypair via fixed IP
38 * Associates a floating ip
39 * Verifies SSH connectivity using created keypair via floating IP
40 * Deletes instance
41 * Monitors the associated Ironic node for power and
42 expected state transitions
43 """
Adam Gandelman4a48a602014-03-20 18:23:18 -070044 def add_floating_ip(self):
45 floating_ip = self.compute_client.floating_ips.create()
46 self.instance.add_floating_ip(floating_ip)
47 return floating_ip.ip
48
Adam Gandelman4a48a602014-03-20 18:23:18 -070049 def validate_driver_info(self):
50 f_id = self.instance.flavor['id']
51 flavor_extra = self.compute_client.flavors.get(f_id).get_keys()
52 driver_info = self.node.driver_info
53 self.assertEqual(driver_info['pxe_deploy_kernel'],
54 flavor_extra['baremetal:deploy_kernel_id'])
55 self.assertEqual(driver_info['pxe_deploy_ramdisk'],
56 flavor_extra['baremetal:deploy_ramdisk_id'])
57 self.assertEqual(driver_info['pxe_image_source'],
58 self.instance.image['id'])
59
60 def validate_ports(self):
61 for port in self.get_ports(self.node.uuid):
62 n_port_id = port.extra['vif_port_id']
63 n_port = self.network_client.show_port(n_port_id)['port']
64 self.assertEqual(n_port['device_id'], self.instance.id)
65 self.assertEqual(n_port['mac_address'], port.address)
66
Adam Gandelman4a48a602014-03-20 18:23:18 -070067 @test.services('baremetal', 'compute', 'image', 'network')
68 def test_baremetal_server_ops(self):
69 self.add_keypair()
70 self.boot_instance()
71 self.validate_driver_info()
72 self.validate_ports()
73 self.verify_connectivity()
74 floating_ip = self.add_floating_ip()
75 self.verify_connectivity(ip=floating_ip)
76 self.terminate_instance()