blob: 39b776045b63fa892fc9a7e8daa50c326209f7e6 [file] [log] [blame]
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +09001# 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 Fazekasd72ccdb2014-02-24 07:02:55 +010016from tempest.common import debug
Matthew Treinish6c072292014-01-29 19:15:52 +000017from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040018from tempest.openstack.common import log as logging
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090019from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090020from tempest import test
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090021
Matthew Treinish6c072292014-01-29 19:15:52 +000022CONF = config.CONF
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090023
24LOG = logging.getLogger(__name__)
25
26
27class 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 Igawa73d9f3a2013-05-24 10:30:01 +090045 def nova_keypair_add(self):
Ken'ichi Ohmichi599d1b82013-08-19 18:48:37 +090046 self.keypair = self.create_keypair()
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090047
48 def nova_boot(self):
Ken'ichi Ohmichi61f272b2013-08-15 15:58:53 +090049 create_kwargs = {'key_name': self.keypair.name}
Giulio Fidente61cadca2013-09-24 18:33:37 +020050 self.server = self.create_server(image=self.image,
Ken'ichi Ohmichi61f272b2013-08-15 15:58:53 +090051 create_kwargs=create_kwargs)
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090052
53 def nova_list(self):
54 servers = self.compute_client.servers.list()
55 LOG.debug("server_list:%s" % servers)
Attila Fazekase191cb12013-07-29 06:41:52 +020056 self.assertIn(self.server, servers)
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090057
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 Ohmichi70672df2013-08-19 18:35:19 +090064 self.volume = self.create_volume()
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090065
66 def cinder_list(self):
67 volumes = self.volume_client.volumes.list()
Attila Fazekase191cb12013-07-29 06:41:52 +020068 self.assertIn(self.volume, volumes)
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090069
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 Igawa5cf31902014-02-21 17:30:25 +090080 self.wait_for_volume_status('in-use')
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +090081
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 Igawa73d9f3a2013-05-24 10:30:01 +090093 def ssh_to_server(self):
Nachi Ueno95b41282014-01-15 06:54:21 -080094 try:
95 self.linux_client = self.get_remote_client(self.floating_ip.ip)
Attila Fazekas28c25202014-02-08 18:51:38 +010096 self.linux_client.validate_authentication()
Nachi Ueno95b41282014-01-15 06:54:21 -080097 except Exception:
98 LOG.exception('ssh to server failed')
99 self._log_console_output()
Attila Fazekasd72ccdb2014-02-24 07:02:55 +0100100 debug.log_ip_ns()
Nachi Ueno95b41282014-01-15 06:54:21 -0800101 raise
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900102
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 Igawa5cf31902014-02-21 17:30:25 +0900110 self.wait_for_volume_status('available')
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900111
112 volume = self.volume_client.volumes.get(self.volume.id)
113 self.assertEqual('available', volume.status)
114
Masayuki Igawa4ded9f02014-02-17 15:05:59 +0900115 @test.services('compute', 'volume', 'image', 'network')
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900116 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-griffith5462b332013-12-13 10:04:43 -0500126 self.addCleanup(self.nova_volume_detach)
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900127 self.cinder_show()
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900128
129 self.nova_floating_ip_create()
130 self.nova_floating_ip_add()
Yair Friedeb69f3f2013-10-10 13:18:16 +0300131 self._create_loginable_secgroup_rule_nova()
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900132 self.ssh_to_server()
Attila Fazekas28c25202014-02-08 18:51:38 +0100133 self.nova_reboot()
134 self.ssh_to_server()
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900135 self.check_partitions()