From 945c697c5abf1d7c7312472febb5caebd23501bf Mon Sep 17 00:00:00 2001 From: zhangzhang Date: Tue, 18 Oct 2016 02:08:08 -0400 Subject: [PATCH] Add cinder.ListAndGetVolume scenario Create a volume and get the volume detailed information. Measure the "cinder show" command performance. Change-Id: I3d29c257c21cf4367c85e2739387201263ccd527 --- rally-jobs/cinder.yaml | 48 ++++++++++++++++++ .../openstack/scenarios/cinder/utils.py | 9 ++++ .../openstack/scenarios/cinder/volumes.py | 29 +++++++++++ .../cinder/create-and-get-volume.json | 49 +++++++++++++++++++ .../cinder/create-and-get-volume.yaml | 32 ++++++++++++ .../openstack/scenarios/cinder/test_utils.py | 7 +++ .../scenarios/cinder/test_volumes.py | 9 ++++ 7 files changed, 183 insertions(+) create mode 100644 samples/tasks/scenarios/cinder/create-and-get-volume.json create mode 100644 samples/tasks/scenarios/cinder/create-and-get-volume.yaml diff --git a/rally-jobs/cinder.yaml b/rally-jobs/cinder.yaml index b6ca3df2..fd2cdba0 100755 --- a/rally-jobs/cinder.yaml +++ b/rally-jobs/cinder.yaml @@ -217,6 +217,54 @@ failure_rate: max: 0 + CinderVolumes.create_and_get_volume: + - + args: + size: 1 + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + - + args: + size: + min: 1 + max: 3 + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + - + args: + size: 1 + image: + name: {{image_name}} + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + CinderVolumes.list_volumes: - args: diff --git a/rally/plugins/openstack/scenarios/cinder/utils.py b/rally/plugins/openstack/scenarios/cinder/utils.py index 3a042196..a152cb63 100644 --- a/rally/plugins/openstack/scenarios/cinder/utils.py +++ b/rally/plugins/openstack/scenarios/cinder/utils.py @@ -59,6 +59,15 @@ class CinderScenario(scenario.OpenStackScenario): return self.clients("cinder").volumes.list(detailed) + @atomic.action_timer("cinder.get_volume") + def _get_volume(self, volume_id): + """get volume detailed information. + + :param volume_id: id of volume + :returns: class:`Volume` + """ + return self.clients("cinder").volumes.get(volume_id) + @atomic.action_timer("cinder.list_snapshots") def _list_snapshots(self, detailed=True): """Returns user snapshots list.""" diff --git a/rally/plugins/openstack/scenarios/cinder/volumes.py b/rally/plugins/openstack/scenarios/cinder/volumes.py index 7a8e650c..e3698fa1 100755 --- a/rally/plugins/openstack/scenarios/cinder/volumes.py +++ b/rally/plugins/openstack/scenarios/cinder/volumes.py @@ -67,6 +67,35 @@ class CreateAndListVolume(cinder_utils.CinderScenario, self._list_volumes(detailed) +@types.convert(image={"type": "glance_image"}) +@validation.image_exists("image", nullable=True) +@validation.required_services(consts.Service.CINDER) +@validation.required_openstack(users=True) +@scenario.configure(context={"cleanup": ["cinder"]}, + name="CinderVolumes.create_and_get_volume") +class CreateAndGetVolume(cinder_utils.CinderScenario, + nova_utils.NovaScenario, + glance_utils.GlanceScenario): + + def run(self, size, image=None, **kwargs): + """Create a volume and get the volume. + + Measure the "cinder show" command performance. + + :param size: volume size (integer, in GB) or + dictionary, must contain two values: + min - minimum size volumes will be created as; + max - maximum size volumes will be created as. + :param image: image to be used to create volume + :param kwargs: optional args to create a volume + """ + if image: + kwargs["imageRef"] = image + + volume = self._create_volume(size, **kwargs) + self._get_volume(volume.id) + + @validation.required_services(consts.Service.CINDER) @validation.required_openstack(users=True) @scenario.configure(context={"cleanup": ["cinder"]}, diff --git a/samples/tasks/scenarios/cinder/create-and-get-volume.json b/samples/tasks/scenarios/cinder/create-and-get-volume.json new file mode 100644 index 00000000..1825b876 --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-get-volume.json @@ -0,0 +1,49 @@ +{ + "CinderVolumes.create_and_get_volume": [ + { + "args": { + "size": 1 + }, + "runner": { + "type": "constant", + "times": 5, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 2 + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + }, + { + "args": { + "size": { + "min": 1, + "max": 5 + } + }, + "runner": { + "type": "constant", + "times": 5, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 2 + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/cinder/create-and-get-volume.yaml b/samples/tasks/scenarios/cinder/create-and-get-volume.yaml new file mode 100644 index 00000000..f320e958 --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-get-volume.yaml @@ -0,0 +1,32 @@ +--- + CinderVolumes.create_and_get_volume: + - + args: + size: 1 + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + - + args: + size: + min: 1 + max: 5 + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py index 012f4166..f62bfb56 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py @@ -52,6 +52,13 @@ class CinderScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(self.scenario.atomic_actions(), "cinder.list_types") + def test__get_volume(self): + volume = fakes.FakeVolume() + self.assertEqual(self.clients("cinder").volumes.get.return_value, + self.scenario._get_volume(volume.id)) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "cinder.get_volume") + def test__list_snapshots(self): return_snapshots_list = self.scenario._list_snapshots() self.assertEqual( diff --git a/tests/unit/plugins/openstack/scenarios/cinder/test_volumes.py b/tests/unit/plugins/openstack/scenarios/cinder/test_volumes.py index 8e1f55e4..ac77e59e 100755 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volumes.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volumes.py @@ -48,6 +48,15 @@ class CinderServersTestCase(test.ScenarioTestCase): scenario._create_volume.assert_called_once_with(1, fakearg="f") scenario._list_volumes.assert_called_once_with(True) + def test_create_and_get_volume(self): + scenario = volumes.CreateAndGetVolume(self.context) + scenario._create_volume = mock.MagicMock() + scenario._get_volume = mock.MagicMock() + scenario.run(1, fakearg="f") + scenario._create_volume.assert_called_once_with(1, fakearg="f") + scenario._get_volume.assert_called_once_with( + scenario._create_volume.return_value.id) + def test_list_volumes(self): scenario = volumes.ListVolumes(self.context) scenario._list_volumes = mock.MagicMock()