|
0 |
# Copyright 2022 Red Hat, Inc.
|
|
1 |
# 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 |
|
|
15 |
from tempest.common import waiters
|
|
16 |
from tempest import config
|
|
17 |
from tempest.lib import decorators
|
|
18 |
|
|
19 |
from cinder_tempest_plugin.api.volume import base
|
|
20 |
|
|
21 |
CONF = config.CONF
|
|
22 |
|
|
23 |
|
|
24 |
class CreateVolumesFromSnapshotTest(base.CreateMultipleResourceTest):
|
|
25 |
|
|
26 |
@decorators.idempotent_id('3b879ad1-d861-4ad3-b2c8-c89162e867c3')
|
|
27 |
def test_create_multiple_volume_from_snapshot(self):
|
|
28 |
"""Create multiple volumes from a snapshot."""
|
|
29 |
|
|
30 |
volume = self.create_volume()
|
|
31 |
snapshot = self.create_snapshot(volume_id=volume['id'])
|
|
32 |
kwargs_create = {"'snapshot_id": snapshot['id'], "wait_until": None}
|
|
33 |
res = self._create_multiple_resource(self.create_volume,
|
|
34 |
**kwargs_create)
|
|
35 |
kwargs_wait = {"client": self.volumes_client, "status": "available"}
|
|
36 |
self._wait_for_multiple_resources(
|
|
37 |
waiters.wait_for_volume_resource_status, res, **kwargs_wait)
|
|
38 |
|
|
39 |
|
|
40 |
class CreateVolumesFromSourceVolumeTest(base.CreateMultipleResourceTest):
|
|
41 |
|
|
42 |
@decorators.idempotent_id('b4a250d1-3ffd-4727-a2f5-9d858b298558')
|
|
43 |
def test_create_multiple_volume_from_source_volume(self):
|
|
44 |
"""Create multiple volumes from a source volume.
|
|
45 |
|
|
46 |
The purpose of this test is to check the synchronization
|
|
47 |
of driver clone method with simultaneous requests.
|
|
48 |
"""
|
|
49 |
|
|
50 |
volume = self.create_volume()
|
|
51 |
kwargs_create = {"'source_volid": volume['id'], "wait_until": None}
|
|
52 |
res = self._create_multiple_resource(self.create_volume,
|
|
53 |
**kwargs_create)
|
|
54 |
kwargs_wait = {"client": self.volumes_client, "status": "available"}
|
|
55 |
self._wait_for_multiple_resources(
|
|
56 |
waiters.wait_for_volume_resource_status, res, **kwargs_wait)
|
|
57 |
|
|
58 |
|
|
59 |
class CreateVolumesFromBackupTest(base.CreateMultipleResourceTest):
|
|
60 |
|
|
61 |
@classmethod
|
|
62 |
def skip_checks(cls):
|
|
63 |
super(CreateVolumesFromBackupTest, cls).skip_checks()
|
|
64 |
if not CONF.volume_feature_enabled.backup:
|
|
65 |
raise cls.skipException("Cinder backup feature disabled")
|
|
66 |
|
|
67 |
@decorators.idempotent_id('9db67083-bf1a-486c-8f77-3778467f39a1')
|
|
68 |
def test_create_multiple_volume_from_backup(self):
|
|
69 |
"""Create multiple volumes from a backup."""
|
|
70 |
|
|
71 |
volume = self.create_volume()
|
|
72 |
backup = self.create_backup(volume_id=volume['id'])
|
|
73 |
kwargs_create = {"'backup_id": backup['id'], "wait_until": None}
|
|
74 |
res = self._create_multiple_resource(self.create_volume,
|
|
75 |
**kwargs_create)
|
|
76 |
kwargs_wait = {"client": self.volumes_client, "status": "available"}
|
|
77 |
self._wait_for_multiple_resources(
|
|
78 |
waiters.wait_for_volume_resource_status, res, **kwargs_wait)
|
|
79 |
|
|
80 |
|
|
81 |
class CreateVolumesFromImageTest(base.CreateMultipleResourceTest):
|
|
82 |
|
|
83 |
@classmethod
|
|
84 |
def skip_checks(cls):
|
|
85 |
super(CreateVolumesFromImageTest, cls).skip_checks()
|
|
86 |
if not CONF.service_available.glance:
|
|
87 |
raise cls.skipException("Glance service is disabled")
|
|
88 |
|
|
89 |
@decorators.idempotent_id('8976a11b-1ddc-49b6-b66f-8c26adf3fa9e')
|
|
90 |
def test_create_from_image_multiple(self):
|
|
91 |
"""Create a handful of volumes from the same image at once.
|
|
92 |
|
|
93 |
The purpose of this test is to stress volume drivers,
|
|
94 |
image download, the image cache, etc., within Cinder.
|
|
95 |
"""
|
|
96 |
|
|
97 |
img_uuid = CONF.compute.image_ref
|
|
98 |
|
|
99 |
kwargs_create = {"'imageRef": img_uuid, "wait_until": None}
|
|
100 |
res = self._create_multiple_resource(self.create_volume,
|
|
101 |
**kwargs_create)
|
|
102 |
kwargs_wait = {"client": self.volumes_client, "status": "available"}
|
|
103 |
self._wait_for_multiple_resources(
|
|
104 |
waiters.wait_for_volume_resource_status, res, **kwargs_wait)
|