blob: e09f4a88eb3a1b811a01ca5bed9f981ad27a7029 [file] [log] [blame]
ivan-zhub4b20602013-11-25 15:49:38 +08001# Copyright 2012 OpenStack Foundation
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
16from tempest.api.compute import base
17from tempest.common.utils import data_utils
ivan-zhuf0bf3012013-11-25 16:03:42 +080018from tempest import test
ivan-zhub4b20602013-11-25 15:49:38 +080019
20
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090021class ServersV3Test(base.BaseV3ComputeTest):
ivan-zhub4b20602013-11-25 15:49:38 +080022
23 @classmethod
Andrea Frittoli3d3efba2014-09-15 12:36:30 +010024 def resource_setup(cls):
25 super(ServersV3Test, cls).resource_setup()
ivan-zhub4b20602013-11-25 15:49:38 +080026 cls.client = cls.servers_client
27
28 def tearDown(self):
29 self.clear_servers()
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090030 super(ServersV3Test, self).tearDown()
ivan-zhub4b20602013-11-25 15:49:38 +080031
ivan-zhuf0bf3012013-11-25 16:03:42 +080032 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +080033 def test_create_server_with_admin_password(self):
34 # If an admin password is provided on server creation, the server's
35 # root password should be set to that password.
ivan-zhuf0bf3012013-11-25 16:03:42 +080036 resp, server = self.create_test_server(admin_password='testpassword')
ivan-zhub4b20602013-11-25 15:49:38 +080037
38 # Verify the password is set correctly in the response
ivan-zhuf0bf3012013-11-25 16:03:42 +080039 self.assertEqual('testpassword', server['admin_password'])
ivan-zhub4b20602013-11-25 15:49:38 +080040
ivan-zhuf0bf3012013-11-25 16:03:42 +080041 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +080042 def test_create_with_existing_server_name(self):
43 # Creating a server with a name that already exists is allowed
44
45 # TODO(sdague): clear out try, we do cleanup one layer up
46 server_name = data_utils.rand_name('server')
47 resp, server = self.create_test_server(name=server_name,
48 wait_until='ACTIVE')
49 id1 = server['id']
50 resp, server = self.create_test_server(name=server_name,
51 wait_until='ACTIVE')
52 id2 = server['id']
53 self.assertNotEqual(id1, id2, "Did not create a new server")
54 resp, server = self.client.get_server(id1)
55 name1 = server['name']
56 resp, server = self.client.get_server(id2)
57 name2 = server['name']
58 self.assertEqual(name1, name2)
59
ivan-zhuf0bf3012013-11-25 16:03:42 +080060 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +080061 def test_create_specify_keypair(self):
62 # Specify a keypair while creating a server
63
64 key_name = data_utils.rand_name('key')
65 resp, keypair = self.keypairs_client.create_keypair(key_name)
66 resp, body = self.keypairs_client.list_keypairs()
67 resp, server = self.create_test_server(key_name=key_name)
68 self.assertEqual('202', resp['status'])
69 self.client.wait_for_server_status(server['id'], 'ACTIVE')
70 resp, server = self.client.get_server(server['id'])
71 self.assertEqual(key_name, server['key_name'])
72
ivan-zhuf0bf3012013-11-25 16:03:42 +080073 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +080074 def test_update_server_name(self):
75 # The server name should be changed to the the provided value
76 resp, server = self.create_test_server(wait_until='ACTIVE')
77
78 # Update the server with a new name
79 resp, server = self.client.update_server(server['id'],
80 name='newname')
81 self.assertEqual(200, resp.status)
82 self.client.wait_for_server_status(server['id'], 'ACTIVE')
83
84 # Verify the name of the server has changed
85 resp, server = self.client.get_server(server['id'])
86 self.assertEqual('newname', server['name'])
87
ivan-zhuf0bf3012013-11-25 16:03:42 +080088 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +080089 def test_update_access_server_address(self):
90 # The server's access addresses should reflect the provided values
91 resp, server = self.create_test_server(wait_until='ACTIVE')
92
93 # Update the IPv4 and IPv6 access addresses
94 resp, body = self.client.update_server(server['id'],
ivan-zhuf0bf3012013-11-25 16:03:42 +080095 access_ip_v4='1.1.1.1',
96 access_ip_v6='::babe:202:202')
ivan-zhub4b20602013-11-25 15:49:38 +080097 self.assertEqual(200, resp.status)
98 self.client.wait_for_server_status(server['id'], 'ACTIVE')
99
100 # Verify the access addresses have been updated
101 resp, server = self.client.get_server(server['id'])
ivan-zhuf0bf3012013-11-25 16:03:42 +0800102 self.assertEqual('1.1.1.1', server['os-access-ips:access_ip_v4'])
103 self.assertEqual('::babe:202:202',
104 server['os-access-ips:access_ip_v6'])
ivan-zhub4b20602013-11-25 15:49:38 +0800105
ivan-zhuf0bf3012013-11-25 16:03:42 +0800106 @test.attr(type='gate')
ivan-zhub4b20602013-11-25 15:49:38 +0800107 def test_create_server_with_ipv6_addr_only(self):
108 # Create a server without an IPv4 address(only IPv6 address).
ivan-zhuf0bf3012013-11-25 16:03:42 +0800109 resp, server = self.create_test_server(access_ip_v6='2001:2001::3')
ivan-zhub4b20602013-11-25 15:49:38 +0800110 self.assertEqual('202', resp['status'])
111 self.client.wait_for_server_status(server['id'], 'ACTIVE')
112 resp, server = self.client.get_server(server['id'])
ivan-zhuf0bf3012013-11-25 16:03:42 +0800113 self.assertEqual('2001:2001::3', server['os-access-ips:access_ip_v6'])