blob: 06b089385a7adfa07a7696bff6700d0de6989180 [file] [log] [blame]
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -07001# Copyright 2016 NEC Corporation. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.api.compute import base
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070016from tempest import config
Ken'ichi Ohmichi757833a2017-03-10 10:30:30 -080017from tempest.lib.common.utils import data_utils
Ken'ichi Ohmichiebbfd1c2017-01-27 16:37:00 -080018from tempest.lib import decorators
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070019from tempest.lib import exceptions as lib_exc
20from tempest import test
21
22CONF = config.CONF
23
24
25class VolumesAdminNegativeTest(base.BaseV2ComputeAdminTest):
26
27 @classmethod
28 def skip_checks(cls):
29 super(VolumesAdminNegativeTest, cls).skip_checks()
30 if not CONF.service_available.cinder:
31 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
32 raise cls.skipException(skip_msg)
33
34 @classmethod
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070035 def resource_setup(cls):
36 super(VolumesAdminNegativeTest, cls).resource_setup()
37 cls.server = cls.create_test_server(wait_until='ACTIVE')
38
zhufl7b931042017-02-21 16:41:58 +080039 @test.attr(type=['negative'])
Ken'ichi Ohmichiebbfd1c2017-01-27 16:37:00 -080040 @decorators.idempotent_id('309b5ecd-0585-4a7e-a36f-d2b2bf55259d')
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070041 def test_update_attached_volume_with_nonexistent_volume_in_uri(self):
42 volume = self.create_volume()
43 nonexistent_volume = data_utils.rand_uuid()
44 self.assertRaises(lib_exc.NotFound,
zhufle5b62a62017-02-15 16:04:21 +080045 self.admin_servers_client.update_attached_volume,
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070046 self.server['id'], nonexistent_volume,
47 volumeId=volume['id'])
48
Ken'ichi Ohmichid4e4b6d2016-12-26 23:19:08 -080049 @test.related_bug('1629110', status_code=400)
zhufl7b931042017-02-21 16:41:58 +080050 @test.attr(type=['negative'])
Ken'ichi Ohmichiebbfd1c2017-01-27 16:37:00 -080051 @decorators.idempotent_id('7dcac15a-b107-46d3-a5f6-cb863f4e454a')
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070052 def test_update_attached_volume_with_nonexistent_volume_in_body(self):
53 volume = self.create_volume()
54 self.attach_volume(self.server, volume)
55
56 nonexistent_volume = data_utils.rand_uuid()
57 self.assertRaises(lib_exc.BadRequest,
zhufle5b62a62017-02-15 16:04:21 +080058 self.admin_servers_client.update_attached_volume,
Ken'ichi Ohmichi7ef0b8f2016-10-03 18:49:13 -070059 self.server['id'], volume['id'],
60 volumeId=nonexistent_volume)