summaryrefslogtreecommitdiff
path: root/tempest/stress/actions/volume_create_delete.py
blob: 4e75be07ffdae72ef5479b9f0c40ca99a8afe527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from tempest.common.utils import data_utils
import tempest.stress.stressaction as stressaction


class VolumeCreateDeleteTest(stressaction.StressAction):

    def run(self):
        name = data_utils.rand_name("volume")
        self.logger.info("creating %s" % name)
        volumes_client = self.manager.volumes_client
        resp, volume = volumes_client.create_volume(size=1,
                                                    display_name=name)
        assert(resp.status == 200)
        vol_id = volume['id']
        volumes_client.wait_for_volume_status(vol_id, 'available')
        self.logger.info("created %s" % volume['id'])
        self.logger.info("deleting %s" % name)
        resp, _ = volumes_client.delete_volume(vol_id)
        assert(resp.status == 202)
        volumes_client.wait_for_resource_deletion(vol_id)
        self.logger.info("deleted %s" % vol_id)