From 99f165395ada1b1f7006d482974f51688b2d7b69 Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Mon, 7 Mar 2016 16:45:56 +0800 Subject: [PATCH] unify *_kwargs name in scenarios When running a scenario, `kwargs` is used as default key-word arguments. But in some scenarios, there are more and one services being called, and we use xxx_kwargs for this case. However, some xxx_kwargs are not unifed for same usage[0]. Unifying these could avoid midleading for end users. Another improvement is to add xxx_kwargs with empty settings for scenario config files. [0] http://paste.openstack.org/show/489505/ Change-Id: I80f49be5c1cd21812d6b2d56b0f4279f0cf4f402 --- rally/plugins/openstack/scenarios/nova/keypairs.py | 9 +++++---- .../tasks/scenarios/cinder/create-and-update-volume.json | 1 + .../tasks/scenarios/cinder/create-and-update-volume.yaml | 1 + .../nova/boot-and-delete-server-with-keypairs.json | 3 ++- .../nova/boot-and-delete-server-with-keypairs.yaml | 1 + ...ot-server-attach-created-volume-and-live-migrate.json | 4 +++- ...ot-server-attach-created-volume-and-live-migrate.yaml | 2 ++ .../plugins/openstack/scenarios/nova/test_keypairs.py | 2 +- 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/rally/plugins/openstack/scenarios/nova/keypairs.py b/rally/plugins/openstack/scenarios/nova/keypairs.py index 47fd88b6..ab20a629 100644 --- a/rally/plugins/openstack/scenarios/nova/keypairs.py +++ b/rally/plugins/openstack/scenarios/nova/keypairs.py @@ -58,7 +58,7 @@ class NovaKeypair(utils.NovaScenario): @validation.required_openstack(users=True) @scenario.configure(context={"cleanup": ["nova"]}) def boot_and_delete_server_with_keypair(self, image, flavor, - server_kwargs=None, + boot_server_kwargs=None, **kwargs): """Boot and delete server with keypair. @@ -70,15 +70,16 @@ class NovaKeypair(utils.NovaScenario): :param image: ID of the image to be used for server creation :param flavor: ID of the flavor to be used for server creation - :param server_kwargs: Optional additional arguments for VM creation + :param boot_server_kwargs: Optional additional arguments for VM + creation :param kwargs: Optional additional arguments for keypair creation """ - server_kwargs = server_kwargs or {} + boot_server_kwargs = boot_server_kwargs or {} keypair = self._create_keypair(**kwargs) server = self._boot_server(image, flavor, key_name=keypair, - **server_kwargs) + **boot_server_kwargs) self._delete_server(server) self._delete_keypair(keypair) diff --git a/samples/tasks/scenarios/cinder/create-and-update-volume.json b/samples/tasks/scenarios/cinder/create-and-update-volume.json index 215ec44e..50e49ac7 100644 --- a/samples/tasks/scenarios/cinder/create-and-update-volume.json +++ b/samples/tasks/scenarios/cinder/create-and-update-volume.json @@ -2,6 +2,7 @@ "CinderVolumes.create_and_update_volume": [ { "args": { + "create_volume_kwargs": {}, "update_volume_kwargs": { "display_name": "name_updated", "display_description": "desc_updated" diff --git a/samples/tasks/scenarios/cinder/create-and-update-volume.yaml b/samples/tasks/scenarios/cinder/create-and-update-volume.yaml index bce928f1..05867c78 100644 --- a/samples/tasks/scenarios/cinder/create-and-update-volume.yaml +++ b/samples/tasks/scenarios/cinder/create-and-update-volume.yaml @@ -5,6 +5,7 @@ update_volume_kwargs: display_name: "name_updated" display_description: "desc_updated" + create_volume_kwargs: {} size: 1 runner: type: "constant" diff --git a/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.json b/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.json index 097144cc..b6e9dc9b 100644 --- a/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.json +++ b/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.json @@ -8,7 +8,8 @@ }, "image": { "name": "^cirros.*uec$" - } + }, + "boot_server_kwargs": {} }, "runner": { "type": "constant", diff --git a/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.yaml b/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.yaml index 3cfa388f..f28be813 100644 --- a/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.yaml +++ b/samples/tasks/scenarios/nova/boot-and-delete-server-with-keypairs.yaml @@ -7,6 +7,7 @@ name: "{{flavor_name}}" image: name: "^cirros.*uec$" + boot_server_kwargs: {} runner: type: "constant" times: 5 diff --git a/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.json b/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.json index 62e34641..4b0aad88 100644 --- a/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.json +++ b/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.json @@ -10,7 +10,9 @@ }, "flavor": { "name": "{{flavor_name}}" - } + }, + "boot_server_kwargs": {}, + "create_volume_kwargs": {} }, "runner": { "type": "constant", diff --git a/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.yaml b/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.yaml index 3c8bc1da..42c9f99c 100644 --- a/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.yaml +++ b/samples/tasks/scenarios/nova/boot-server-attach-created-volume-and-live-migrate.yaml @@ -8,6 +8,8 @@ NovaServers.boot_server_attach_created_volume_and_live_migrate: name: "^cirros.*uec$" size: 10 block_migration: false + boot_server_kwargs: {} + create_volume_kwargs: {} runner: type: "constant" times: 5 diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_keypairs.py b/tests/unit/plugins/openstack/scenarios/nova/test_keypairs.py index fe4c7464..9b6e2758 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_keypairs.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_keypairs.py @@ -57,7 +57,7 @@ class NovaKeypairTestCase(test.ScenarioTestCase): } scenario.boot_and_delete_server_with_keypair( - "img", 1, server_kwargs=fake_server_args, + "img", 1, boot_server_kwargs=fake_server_args, fake_arg1="foo", fake_arg2="bar") scenario._create_keypair.assert_called_once_with(