diff --git a/rally-jobs/rally-neutron.yaml b/rally-jobs/rally-neutron.yaml index 01bab0b2..486e302d 100644 --- a/rally-jobs/rally-neutron.yaml +++ b/rally-jobs/rally-neutron.yaml @@ -475,3 +475,30 @@ tenants: 2 users_per_tenant: 2 network: {} + + VMTasks.boot_runcommand_delete_custom_image: + - + args: + command: + remote_path: "./dd_test.sh" + flavor: + name: "m1.tiny" + username: "cirros" + runner: + type: "constant" + times: 1 + concurrency: 1 + context: + image_command_customizer: + command: + local_path: "/home/jenkins/.rally/extra/script_benchmark.sh" + remote_path: "./script_benchmark.sh" + flavor: + name: "m1.tiny" + image: + name: {{image_name}} + username: "cirros" + users: + tenants: 1 + users_per_tenant: 1 + network: {} diff --git a/rally/plugins/openstack/scenarios/vm/vmtasks.py b/rally/plugins/openstack/scenarios/vm/vmtasks.py index 631807f5..f36ca678 100644 --- a/rally/plugins/openstack/scenarios/vm/vmtasks.py +++ b/rally/plugins/openstack/scenarios/vm/vmtasks.py @@ -179,3 +179,23 @@ class VMTasks(vm_utils.VMScenario): force_delete=force_delete) return {"data": data, "errors": err} + + @types.set(image=types.ImageResourceType, + flavor=types.FlavorResourceType) + @validation.number("port", minval=1, maxval=65535, nullable=True, + integer_only=True) + @validation.valid_command("command") + @validation.external_network_exists("floating_network") + @validation.required_services(consts.Service.NOVA, consts.Service.CINDER) + @validation.required_openstack(users=True) + @validation.required_contexts("image_command_customizer") + @scenario.configure(context={"cleanup": ["nova", "cinder"], + "keypair": {}, "allow_ssh": {}}) + def boot_runcommand_delete_custom_image(self, **kwargs): + """Boot a server from a custom image, run a command that outputs JSON. + + Example Script in rally-jobs/extra/script_benchmark.sh + """ + + return self.boot_runcommand_delete( + image=self.context["tenant"]["custom_image"]["id"], **kwargs) diff --git a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py index 585db266..ce2dac52 100644 --- a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py +++ b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py @@ -116,3 +116,31 @@ class VMTasksTestCase(test.TestCase): "foo_script", "foo_username") self.scenario._delete_server_with_fip.assert_called_once_with( "foo_server", self.ip, force_delete=False) + + def test_boot_runcommand_delete_custom_image(self): + context = { + "user": { + "tenant_id": "tenant_id", + "endpoint": mock.Mock() + }, + "tenant": { + "custom_image": {"id": "image_id"} + } + } + scenario = vmtasks.VMTasks(context) + + scenario.boot_runcommand_delete = mock.Mock() + + scenario.boot_runcommand_delete_custom_image( + flavor="flavor_id", + command={ + "script_file": "foo_script", + "interpreter": "bar_interpreter"}, + username="username") + + scenario.boot_runcommand_delete.assert_called_once_with( + image="image_id", flavor="flavor_id", username="username", + command={ + "script_file": "foo_script", + "interpreter": "bar_interpreter"} + )