Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 1 | # Copyright 2013 NEC Corporation |
| 2 | # All Rights Reserved. |
| 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 | |
Attila Fazekas | d72ccdb | 2014-02-24 07:02:55 +0100 | [diff] [blame] | 16 | from tempest.common import debug |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 17 | from tempest import config |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 18 | from tempest.openstack.common import log as logging |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 19 | from tempest.scenario import manager |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 20 | from tempest import test |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 21 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 22 | CONF = config.CONF |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 23 | |
| 24 | LOG = logging.getLogger(__name__) |
| 25 | |
| 26 | |
| 27 | class TestMinimumBasicScenario(manager.OfficialClientTest): |
| 28 | |
| 29 | """ |
| 30 | This is a basic minimum scenario test. |
| 31 | |
| 32 | This test below: |
| 33 | * across the multiple components |
| 34 | * as a regular user |
| 35 | * with and without optional parameters |
| 36 | * check command outputs |
| 37 | |
| 38 | """ |
| 39 | |
| 40 | def _wait_for_server_status(self, status): |
| 41 | server_id = self.server.id |
| 42 | self.status_timeout( |
| 43 | self.compute_client.servers, server_id, status) |
| 44 | |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 45 | def nova_keypair_add(self): |
Ken'ichi Ohmichi | 599d1b8 | 2013-08-19 18:48:37 +0900 | [diff] [blame] | 46 | self.keypair = self.create_keypair() |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 47 | |
| 48 | def nova_boot(self): |
Ken'ichi Ohmichi | 61f272b | 2013-08-15 15:58:53 +0900 | [diff] [blame] | 49 | create_kwargs = {'key_name': self.keypair.name} |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 50 | self.server = self.create_server(image=self.image, |
Ken'ichi Ohmichi | 61f272b | 2013-08-15 15:58:53 +0900 | [diff] [blame] | 51 | create_kwargs=create_kwargs) |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 52 | |
| 53 | def nova_list(self): |
| 54 | servers = self.compute_client.servers.list() |
| 55 | LOG.debug("server_list:%s" % servers) |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 56 | self.assertIn(self.server, servers) |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 57 | |
| 58 | def nova_show(self): |
| 59 | got_server = self.compute_client.servers.get(self.server) |
| 60 | LOG.debug("got server:%s" % got_server) |
| 61 | self.assertEqual(self.server, got_server) |
| 62 | |
| 63 | def cinder_create(self): |
Ken'ichi Ohmichi | 70672df | 2013-08-19 18:35:19 +0900 | [diff] [blame] | 64 | self.volume = self.create_volume() |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 65 | |
| 66 | def cinder_list(self): |
| 67 | volumes = self.volume_client.volumes.list() |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 68 | self.assertIn(self.volume, volumes) |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 69 | |
| 70 | def cinder_show(self): |
| 71 | volume = self.volume_client.volumes.get(self.volume.id) |
| 72 | self.assertEqual(self.volume, volume) |
| 73 | |
| 74 | def nova_volume_attach(self): |
| 75 | attach_volume_client = self.compute_client.volumes.create_server_volume |
| 76 | volume = attach_volume_client(self.server.id, |
| 77 | self.volume.id, |
| 78 | '/dev/vdb') |
| 79 | self.assertEqual(self.volume.id, volume.id) |
Masayuki Igawa | 5cf3190 | 2014-02-21 17:30:25 +0900 | [diff] [blame] | 80 | self.wait_for_volume_status('in-use') |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 81 | |
| 82 | def nova_reboot(self): |
| 83 | self.server.reboot() |
| 84 | self._wait_for_server_status('ACTIVE') |
| 85 | |
| 86 | def nova_floating_ip_create(self): |
| 87 | self.floating_ip = self.compute_client.floating_ips.create() |
| 88 | self.addCleanup(self.floating_ip.delete) |
| 89 | |
| 90 | def nova_floating_ip_add(self): |
| 91 | self.server.add_floating_ip(self.floating_ip) |
| 92 | |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 93 | def ssh_to_server(self): |
Nachi Ueno | 95b4128 | 2014-01-15 06:54:21 -0800 | [diff] [blame] | 94 | try: |
| 95 | self.linux_client = self.get_remote_client(self.floating_ip.ip) |
Attila Fazekas | 28c2520 | 2014-02-08 18:51:38 +0100 | [diff] [blame] | 96 | self.linux_client.validate_authentication() |
Nachi Ueno | 95b4128 | 2014-01-15 06:54:21 -0800 | [diff] [blame] | 97 | except Exception: |
| 98 | LOG.exception('ssh to server failed') |
| 99 | self._log_console_output() |
Attila Fazekas | d72ccdb | 2014-02-24 07:02:55 +0100 | [diff] [blame] | 100 | debug.log_ip_ns() |
Nachi Ueno | 95b4128 | 2014-01-15 06:54:21 -0800 | [diff] [blame] | 101 | raise |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 102 | |
| 103 | def check_partitions(self): |
| 104 | partitions = self.linux_client.get_partitions() |
| 105 | self.assertEqual(1, partitions.count('vdb')) |
| 106 | |
| 107 | def nova_volume_detach(self): |
| 108 | detach_volume_client = self.compute_client.volumes.delete_server_volume |
| 109 | detach_volume_client(self.server.id, self.volume.id) |
Masayuki Igawa | 5cf3190 | 2014-02-21 17:30:25 +0900 | [diff] [blame] | 110 | self.wait_for_volume_status('available') |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 111 | |
| 112 | volume = self.volume_client.volumes.get(self.volume.id) |
| 113 | self.assertEqual('available', volume.status) |
| 114 | |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 115 | @test.services('compute', 'volume', 'image', 'network') |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 116 | def test_minimum_basic_scenario(self): |
| 117 | self.glance_image_create() |
| 118 | self.nova_keypair_add() |
| 119 | self.nova_boot() |
| 120 | self.nova_list() |
| 121 | self.nova_show() |
| 122 | self.cinder_create() |
| 123 | self.cinder_list() |
| 124 | self.cinder_show() |
| 125 | self.nova_volume_attach() |
john-griffith | 5462b33 | 2013-12-13 10:04:43 -0500 | [diff] [blame] | 126 | self.addCleanup(self.nova_volume_detach) |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 127 | self.cinder_show() |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 128 | |
| 129 | self.nova_floating_ip_create() |
| 130 | self.nova_floating_ip_add() |
Yair Fried | eb69f3f | 2013-10-10 13:18:16 +0300 | [diff] [blame] | 131 | self._create_loginable_secgroup_rule_nova() |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 132 | self.ssh_to_server() |
Attila Fazekas | 28c2520 | 2014-02-08 18:51:38 +0100 | [diff] [blame] | 133 | self.nova_reboot() |
| 134 | self.ssh_to_server() |
Masayuki Igawa | 73d9f3a | 2013-05-24 10:30:01 +0900 | [diff] [blame] | 135 | self.check_partitions() |