From bbb69e755be6ebfbe55f78ef0c52724ddcd7f8a6 Mon Sep 17 00:00:00 2001 From: Giulio Fidente Date: Tue, 18 Jun 2013 16:06:24 +0200 Subject: [PATCH] Add a volume create/delete stress test Simply performs a create/delete operation, in a while loop for the duration passed to run_stress.py Change-Id: I006f3754f1fc1cabfbb90ed72704b2185dcc4e5f Fixes: bug #1192227 --- .../stress/actions/volume_create_delete.py | 30 +++++++++++++++++++ tempest/stress/cleanup.py | 13 ++++++++ .../stress/etc/volume-create-delete-test.json | 7 +++++ 3 files changed, 50 insertions(+) create mode 100644 tempest/stress/actions/volume_create_delete.py create mode 100644 tempest/stress/etc/volume-create-delete-test.json diff --git a/tempest/stress/actions/volume_create_delete.py b/tempest/stress/actions/volume_create_delete.py new file mode 100644 index 0000000000..e0c95b56d3 --- /dev/null +++ b/tempest/stress/actions/volume_create_delete.py @@ -0,0 +1,30 @@ +# 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.data_utils import rand_name + + +def create_delete(manager, logger): + while True: + name = rand_name("volume") + logger.info("creating %s" % name) + resp, volume = manager.volumes_client.create_volume(size=1, + display_name=name) + assert(resp.status == 200) + manager.volumes_client.wait_for_volume_status(volume['id'], + 'available') + logger.info("created %s" % volume['id']) + logger.info("deleting %s" % name) + resp, _ = manager.volumes_client.delete_volume(volume['id']) + assert(resp.status == 202) + manager.volumes_client.wait_for_resource_deletion(volume['id']) + logger.info("deleted %s" % volume['id']) diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py index b2cb70a21c..3b1c871a46 100644 --- a/tempest/stress/cleanup.py +++ b/tempest/stress/cleanup.py @@ -58,3 +58,16 @@ def cleanup(): for tenant in tenants: if tenant['name'].startswith("stress_tenant"): admin_manager.identity_client.delete_tenant(tenant['id']) + + _, vols = admin_manager.volumes_client.list_volumes({"all_tenants": True}) + for v in vols: + try: + admin_manager.volumes_client.delete_volume(v['id']) + except Exception: + pass + + for v in vols: + try: + admin_manager.volumes_client.wait_for_resource_deletion(v['id']) + except Exception: + pass diff --git a/tempest/stress/etc/volume-create-delete-test.json b/tempest/stress/etc/volume-create-delete-test.json new file mode 100644 index 0000000000..ed0aaeb009 --- /dev/null +++ b/tempest/stress/etc/volume-create-delete-test.json @@ -0,0 +1,7 @@ +[{"action": "tempest.stress.actions.volume_create_delete.create_delete", + "threads": 4, + "use_admin": false, + "use_isolated_tenants": false, + "kwargs": {} + } +]