diff --git a/rally/plugins/openstack/context/cinder/volumes.py b/rally/plugins/openstack/context/cinder/volumes.py index e407dcbe..1dba40d6 100644 --- a/rally/plugins/openstack/context/cinder/volumes.py +++ b/rally/plugins/openstack/context/cinder/volumes.py @@ -85,4 +85,4 @@ class VolumeGenerator(context.Context): users=self.context.get("users", []), api_versions=self.context["config"].get("api_versions"), superclass=self.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/cleanup/admin.py b/rally/plugins/openstack/context/cleanup/admin.py index 1f7bd4f5..af40279e 100644 --- a/rally/plugins/openstack/context/cleanup/admin.py +++ b/rally/plugins/openstack/context/cleanup/admin.py @@ -52,4 +52,4 @@ class AdminCleanup(base.CleanupMixin, context.Context): users=self.context.get("users", []), api_versions=self.context["config"].get("api_versions"), superclass=scenario.OpenStackScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/cleanup/user.py b/rally/plugins/openstack/context/cleanup/user.py index d8b4a966..692210d2 100644 --- a/rally/plugins/openstack/context/cleanup/user.py +++ b/rally/plugins/openstack/context/cleanup/user.py @@ -51,5 +51,5 @@ class UserCleanup(base.CleanupMixin, context.Context): users=self.context.get("users", []), api_versions=self.context["config"].get("api_versions"), superclass=scenario.OpenStackScenario, - task_id=self.context["task"]["uuid"] + task_id=self.get_owner_id() ) diff --git a/rally/plugins/openstack/context/dataplane/heat.py b/rally/plugins/openstack/context/dataplane/heat.py index 8e879631..829e0449 100644 --- a/rally/plugins/openstack/context/dataplane/heat.py +++ b/rally/plugins/openstack/context/dataplane/heat.py @@ -134,7 +134,8 @@ class HeatDataplane(context.Context): if "key_name" not in parameters: parameters["key_name"] = user["keypair"]["name"] heat_scenario = heat_utils.HeatScenario( - {"user": user, "task": self.context["task"]}) + {"user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"]}) self.context["tenants"][tenant_id]["stack_dataplane"] = [] for i in range(self.config["stacks_per_tenant"]): stack = heat_scenario._create_stack(template, files=files, @@ -146,4 +147,6 @@ class HeatDataplane(context.Context): @logging.log_task_wrapper(LOG.info, _("Exit context: `HeatDataplane`")) def cleanup(self): resource_manager.cleanup(names=["heat.stacks"], - users=self.context.get("users", [])) + users=self.context.get("users", []), + superclass=heat_utils.HeatScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/designate/zones.py b/rally/plugins/openstack/context/designate/zones.py index 53c50be2..8b78586a 100644 --- a/rally/plugins/openstack/context/designate/zones.py +++ b/rally/plugins/openstack/context/designate/zones.py @@ -51,7 +51,8 @@ class ZoneGenerator(context.Context): self.context["tenants"][tenant_id].setdefault("zones", []) designate_util = utils.DesignateScenario( {"user": user, - "task": self.context["task"]}) + "task": self.context["task"], + "owner_id": self.context["owner_id"]}) for i in range(self.config["zones_per_tenant"]): zone = designate_util._create_zone() self.context["tenants"][tenant_id]["zones"].append(zone) @@ -61,4 +62,4 @@ class ZoneGenerator(context.Context): resource_manager.cleanup(names=["designate.zones"], users=self.context.get("users", []), superclass=utils.DesignateScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/ec2/servers.py b/rally/plugins/openstack/context/ec2/servers.py index d35314a8..8fb49be4 100644 --- a/rally/plugins/openstack/context/ec2/servers.py +++ b/rally/plugins/openstack/context/ec2/servers.py @@ -75,8 +75,10 @@ class EC2ServerGenerator(context.Context): self.context["users"]): LOG.debug("Booting servers for tenant %s " % (user["tenant_id"])) - user_clients = osclients.Clients(user["credential"]) - ec2_scenario = ec2_utils.EC2Scenario(clients=user_clients) + ec2_scenario = ec2_utils.EC2Scenario({ + "user": user, + "task": self.context["task"], + "owner_id": self.context["owner_id"]}) LOG.debug( "Calling _boot_servers with " @@ -97,4 +99,4 @@ class EC2ServerGenerator(context.Context): resource_manager.cleanup(names=["ec2.servers"], users=self.context.get("users", []), superclass=ec2_utils.EC2Scenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/glance/images.py b/rally/plugins/openstack/context/glance/images.py index 5a36b7db..5a2c63ce 100644 --- a/rally/plugins/openstack/context/glance/images.py +++ b/rally/plugins/openstack/context/glance/images.py @@ -175,4 +175,4 @@ class ImageGenerator(context.Context): api_versions=self.context["config"].get( "api_versions"), superclass=self.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/heat/stacks.py b/rally/plugins/openstack/context/heat/stacks.py index 826c5213..9c10fb56 100644 --- a/rally/plugins/openstack/context/heat/stacks.py +++ b/rally/plugins/openstack/context/heat/stacks.py @@ -77,7 +77,8 @@ class StackGenerator(context.Context): for user, tenant_id in rutils.iterate_per_tenants( self.context["users"]): heat_scenario = heat_utils.HeatScenario( - {"user": user, "task": self.context["task"]}) + {"user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"]}) self.context["tenants"][tenant_id]["stacks"] = [] for i in range(self.config["stacks_per_tenant"]): stack = heat_scenario._create_stack(template) @@ -88,4 +89,4 @@ class StackGenerator(context.Context): resource_manager.cleanup(names=["heat.stacks"], users=self.context.get("users", []), superclass=heat_utils.HeatScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/magnum/cluster_templates.py b/rally/plugins/openstack/context/magnum/cluster_templates.py index 3bd6df0b..1443b58a 100644 --- a/rally/plugins/openstack/context/magnum/cluster_templates.py +++ b/rally/plugins/openstack/context/magnum/cluster_templates.py @@ -109,6 +109,7 @@ class ClusterTemplateGenerator(context.Context): nova_scenario = nova_utils.NovaScenario({ "user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"], "config": {"api_versions": self.context["config"].get( "api_versions", [])} }) @@ -117,6 +118,7 @@ class ClusterTemplateGenerator(context.Context): magnum_scenario = magnum_utils.MagnumScenario({ "user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"], "config": {"api_versions": self.context["config"].get( "api_versions", [])} }) @@ -130,5 +132,12 @@ class ClusterTemplateGenerator(context.Context): @logging.log_task_wrapper(LOG.info, _("Exit context: `ClusterTemplate`")) def cleanup(self): resource_manager.cleanup( - names=["magnum.cluster_templates", "nova.keypairs"], - users=self.context.get("users", [])) + names=["nova.keypairs"], + users=self.context.get("users", []), + superclass=nova_utils.NovaScenario, + task_id=self.get_owner_id()) + resource_manager.cleanup( + names=["magnum.cluster_templates"], + users=self.context.get("users", []), + superclass=magnum_utils.MagnumScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/magnum/clusters.py b/rally/plugins/openstack/context/magnum/clusters.py index 946ff294..73848d8d 100644 --- a/rally/plugins/openstack/context/magnum/clusters.py +++ b/rally/plugins/openstack/context/magnum/clusters.py @@ -53,6 +53,7 @@ class ClusterGenerator(context.Context): magnum_scenario = magnum_utils.MagnumScenario({ "user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"], "config": {"api_versions": self.context["config"].get( "api_versions", [])} }) @@ -71,4 +72,6 @@ class ClusterGenerator(context.Context): def cleanup(self): resource_manager.cleanup( names=["magnum.clusters"], - users=self.context.get("users", [])) + users=self.context.get("users", []), + superclass=magnum_utils.MagnumScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/manila/manila_security_services.py b/rally/plugins/openstack/context/manila/manila_security_services.py index 04e2bffa..c832ae18 100644 --- a/rally/plugins/openstack/context/manila/manila_security_services.py +++ b/rally/plugins/openstack/context/manila/manila_security_services.py @@ -76,6 +76,7 @@ class SecurityServices(context.Context): if self.config["security_services"]: manila_scenario = manila_utils.ManilaScenario({ "task": self.task, + "owner_id": self.context["owner_id"], "user": user, "config": { "api_versions": self.context["config"].get( @@ -92,4 +93,5 @@ class SecurityServices(context.Context): resource_manager.cleanup( names=["manila.security_services"], users=self.context.get("users", []), - ) + superclass=manila_utils.ManilaScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/manila/manila_shares.py b/rally/plugins/openstack/context/manila/manila_shares.py index 86d39d87..804773c6 100644 --- a/rally/plugins/openstack/context/manila/manila_shares.py +++ b/rally/plugins/openstack/context/manila/manila_shares.py @@ -86,6 +86,7 @@ class Shares(context.Context): utils.iterate_per_tenants(self.context.get("users", []))): manila_scenario = manila_utils.ManilaScenario({ "task": self.task, + "owner_id": self.context["owner_id"], "user": user, "config": { "api_versions": self.context["config"].get( @@ -104,4 +105,5 @@ class Shares(context.Context): resource_manager.cleanup( names=["manila.shares"], users=self.context.get("users", []), - ) + superclass=manila_utils.ManilaScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/murano/murano_environments.py b/rally/plugins/openstack/context/murano/murano_environments.py index def583f5..80af1364 100644 --- a/rally/plugins/openstack/context/murano/murano_environments.py +++ b/rally/plugins/openstack/context/murano/murano_environments.py @@ -52,6 +52,7 @@ class EnvironmentGenerator(context.Context): murano_util = murano_utils.MuranoScenario( {"user": user, "task": self.context["task"], + "owner_id": self.context["owner_id"], "config": self.context["config"]}) env = murano_util._create_environment() self.context["tenants"][tenant_id]["environments"].append(env) @@ -60,4 +61,6 @@ class EnvironmentGenerator(context.Context): _("Exit context: `Murano environments`")) def cleanup(self): resource_manager.cleanup(names=["murano.environments"], - users=self.context.get("users", [])) + users=self.context.get("users", []), + superclass=murano_utils.MuranoScenario, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/murano/murano_packages.py b/rally/plugins/openstack/context/murano/murano_packages.py index dbf59a05..1f6152f2 100644 --- a/rally/plugins/openstack/context/murano/murano_packages.py +++ b/rally/plugins/openstack/context/murano/murano_packages.py @@ -25,7 +25,6 @@ from rally import consts from rally import exceptions from rally import osclients from rally.plugins.openstack.cleanup import manager as resource_manager -from rally.plugins.openstack.scenarios.murano import utils as murano_utils from rally.task import context @@ -69,6 +68,7 @@ class PackageGenerator(context.Context): self.context["tenants"][tenant_id]["packages"] = [] if is_config_app_dir: self.context["tenants"][tenant_id]["murano_ctx"] = zip_name + # TODO(astudenov): use self.generate_random_name() package = clients.murano().packages.create( {"categories": ["Web"], "tags": ["tag"]}, {"file": open(zip_name)}) @@ -79,5 +79,5 @@ class PackageGenerator(context.Context): def cleanup(self): resource_manager.cleanup(names=["murano.packages"], users=self.context.get("users", []), - superclass=murano_utils.MuranoScenario, - task_id=self.context["task"]["uuid"]) + superclass=self.__class__, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/nova/keypairs.py b/rally/plugins/openstack/context/nova/keypairs.py index 2d544ff7..8c20926e 100644 --- a/rally/plugins/openstack/context/nova/keypairs.py +++ b/rally/plugins/openstack/context/nova/keypairs.py @@ -59,4 +59,4 @@ class Keypair(context.Context): resource_manager.cleanup(names=["nova.keypairs"], users=self.context.get("users", []), superclass=self.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/nova/servers.py b/rally/plugins/openstack/context/nova/servers.py index f135d722..e60d6a5e 100755 --- a/rally/plugins/openstack/context/nova/servers.py +++ b/rally/plugins/openstack/context/nova/servers.py @@ -107,6 +107,7 @@ class ServerGenerator(context.Context): tmp_context = {"user": user, "tenant": self.context["tenants"][tenant_id], "task": self.context["task"], + "owner_id": self.context["owner_id"], "iteration": iter_} nova_scenario = nova_utils.NovaScenario(tmp_context) @@ -135,4 +136,4 @@ class ServerGenerator(context.Context): resource_manager.cleanup(names=["nova.servers"], users=self.context.get("users", []), superclass=nova_utils.NovaScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/sahara/sahara_cluster.py b/rally/plugins/openstack/context/sahara/sahara_cluster.py index c836b071..832d6381 100644 --- a/rally/plugins/openstack/context/sahara/sahara_cluster.py +++ b/rally/plugins/openstack/context/sahara/sahara_cluster.py @@ -115,7 +115,8 @@ class SaharaCluster(context.Context): temporary_context = { "user": user, "tenant": self.context["tenants"][tenant_id], - "task": self.context["task"] + "task": self.context["task"], + "owner_id": self.context["owner_id"] } scenario = utils.SaharaScenario(context=temporary_context) @@ -179,4 +180,4 @@ class SaharaCluster(context.Context): resource_manager.cleanup(names=["sahara.clusters"], users=self.context.get("users", []), superclass=utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/sahara/sahara_image.py b/rally/plugins/openstack/context/sahara/sahara_image.py index 02fb80fe..995c676e 100644 --- a/rally/plugins/openstack/context/sahara/sahara_image.py +++ b/rally/plugins/openstack/context/sahara/sahara_image.py @@ -130,4 +130,4 @@ class SaharaImage(context.Context): resource_manager.cleanup(names=["glance.images"], users=self.context.get("users", []), superclass=self.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py b/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py index b480c455..f9e373e6 100644 --- a/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py +++ b/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py @@ -22,7 +22,6 @@ from rally.common import utils as rutils from rally import consts from rally import osclients from rally.plugins.openstack.cleanup import manager as resource_manager -from rally.plugins.openstack.cleanup import resources as res_cleanup from rally.plugins.openstack.scenarios.sahara import utils from rally.plugins.openstack.scenarios.swift import utils as swift_utils from rally.task import context @@ -100,6 +99,7 @@ class SaharaInputDataSources(context.Context): swift_files, username, password): swift_scenario = swift_utils.SwiftScenario(clients=clients, context=self.context) + # TODO(astudenov): use self.generate_random_name() container_name = "rally_" + parse.urlparse(input_url).netloc.rstrip( ".sahara") self.context["sahara"]["container_name"] = ( @@ -121,14 +121,13 @@ class SaharaInputDataSources(context.Context): @logging.log_task_wrapper(LOG.info, _("Exit context: `Sahara Input Data" "Sources`")) def cleanup(self): - resources = ["data_sources"] - for swift_object in self.context["sahara"]["swift_objects"]: - res_cleanup.SwiftObject(resource=swift_object[1]) - res_cleanup.SwiftContainer( - resource=self.context["sahara"]["container_name"]) - resource_manager.cleanup( - names=["sahara.%s" % res for res in resources], + names=["swift.object", "swift.container"], users=self.context.get("users", []), - superclass=utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + superclass=swift_utils.SwiftScenario, + task_id=self.get_owner_id()) + resource_manager.cleanup( + names=["sahara.data_sources"], + users=self.context.get("users", []), + superclass=self.__class__, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py b/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py index 41a379b5..827a61d6 100644 --- a/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py +++ b/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py @@ -99,9 +99,13 @@ class SaharaOutputDataSources(context.Context): @logging.log_task_wrapper(LOG.info, _("Exit context: `Sahara Output Data Sources`")) def cleanup(self): - resources = ["data_sources"] resource_manager.cleanup( - names=["sahara.%s" % res for res in resources], + names=["swift.object", "swift.container"], users=self.context.get("users", []), - superclass=utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + superclass=self.__class__, + task_id=self.get_owner_id()) + resource_manager.cleanup( + names=["sahara.data_sources"], + users=self.context.get("users", []), + superclass=self.__class__, + task_id=self.get_owner_id()) diff --git a/rally/plugins/openstack/context/watcher/audit_templates.py b/rally/plugins/openstack/context/watcher/audit_templates.py index 3f7a7d28..06ae3e7d 100644 --- a/rally/plugins/openstack/context/watcher/audit_templates.py +++ b/rally/plugins/openstack/context/watcher/audit_templates.py @@ -79,6 +79,7 @@ class AuditTemplateGenerator(context.Context): def setup(self): watcher_scenario = watcher_utils.WatcherScenario( {"admin": self.context["admin"], "task": self.context["task"], + "owner_id": self.context["owner_id"], "config": { "api_versions": self.context["config"].get( "api_versions", [])} @@ -109,4 +110,6 @@ class AuditTemplateGenerator(context.Context): def cleanup(self): resource_manager.cleanup(names=["watcher.action_plan", "watcher.audit_template"], - admin=self.context.get("admin", [])) + admin=self.context.get("admin", []), + superclass=watcher_utils.WatcherScenario, + task_id=self.get_owner_id()) diff --git a/tests/unit/plugins/openstack/context/cinder/test_volumes.py b/tests/unit/plugins/openstack/context/cinder/test_volumes.py index 8d86b618..68ea1bbe 100644 --- a/tests/unit/plugins/openstack/context/cinder/test_volumes.py +++ b/tests/unit/plugins/openstack/context/cinder/test_volumes.py @@ -144,7 +144,7 @@ class VolumeGeneratorTestCase(test.ScenarioTestCase): mock_cleanup.assert_called_once_with( names=["cinder.volumes"], users=self.context["users"], api_versions=None, superclass=volumes_ctx.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) @mock.patch("%s.cinder.volumes.resource_manager.cleanup" % CTX) def test_cleanup_api_versions(self, mock_cleanup): @@ -198,4 +198,4 @@ class VolumeGeneratorTestCase(test.ScenarioTestCase): users=self.context["users"], api_versions=api_version, superclass=volumes_ctx.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/designate/test_zones.py b/tests/unit/plugins/openstack/context/designate/test_zones.py index 64134580..76b2b218 100644 --- a/tests/unit/plugins/openstack/context/designate/test_zones.py +++ b/tests/unit/plugins/openstack/context/designate/test_zones.py @@ -129,4 +129,4 @@ class ZoneGeneratorTestCase(test.ScenarioTestCase): names=["designate.zones"], users=self.context["users"], superclass=utils.DesignateScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/ec2/test_servers.py b/tests/unit/plugins/openstack/context/ec2/test_servers.py index 44e1a10b..5f20c6ee 100644 --- a/tests/unit/plugins/openstack/context/ec2/test_servers.py +++ b/tests/unit/plugins/openstack/context/ec2/test_servers.py @@ -55,6 +55,7 @@ class EC2ServerGeneratorTestCase(test.TestCase): }, "admin": {"credential": mock.MagicMock()}, "task": mock.MagicMock(), + "owner_id": "foo_uuid", "users": users, "tenants": tenants } @@ -110,4 +111,4 @@ class EC2ServerGeneratorTestCase(test.TestCase): names=["ec2.servers"], users=context["users"], superclass=ec2_utils.EC2Scenario, - task_id=context["task"]["uuid"]) + task_id="foo_uuid") diff --git a/tests/unit/plugins/openstack/context/glance/test_images.py b/tests/unit/plugins/openstack/context/glance/test_images.py index 31997cf9..231c90e1 100644 --- a/tests/unit/plugins/openstack/context/glance/test_images.py +++ b/tests/unit/plugins/openstack/context/glance/test_images.py @@ -208,4 +208,4 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): users=self.context["users"], api_versions=self.context["config"].get("api_versions"), superclass=images_ctx.__class__, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/heat/test_stacks.py b/tests/unit/plugins/openstack/context/heat/test_stacks.py index d311228f..1a5e1c7a 100644 --- a/tests/unit/plugins/openstack/context/heat/test_stacks.py +++ b/tests/unit/plugins/openstack/context/heat/test_stacks.py @@ -95,4 +95,4 @@ class TestStackGenerator(test.ScenarioTestCase): names=["heat.stacks"], users=self.context["users"], superclass=heat_utils.HeatScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/magnum/test_cluster_templates.py b/tests/unit/plugins/openstack/context/magnum/test_cluster_templates.py index 8aa572bb..64debe45 100644 --- a/tests/unit/plugins/openstack/context/magnum/test_cluster_templates.py +++ b/tests/unit/plugins/openstack/context/magnum/test_cluster_templates.py @@ -13,6 +13,8 @@ import mock from rally.plugins.openstack.context.magnum import cluster_templates +from rally.plugins.openstack.scenarios.magnum import utils as magnum_utils +from rally.plugins.openstack.scenarios.nova import utils as nova_utils from tests.unit import fakes from tests.unit import test @@ -103,6 +105,14 @@ class ClusterTemplatesGeneratorTestCase(test.ScenarioTestCase): }) ct_ctx = cluster_templates.ClusterTemplateGenerator(self.context) ct_ctx.cleanup() - mock_cleanup.assert_called_once_with(names=["magnum.cluster_templates", - "nova.keypairs"], - users=self.context["users"]) + mock_cleanup.assert_has_calls(( + mock.call( + names=["nova.keypairs"], + users=self.context["users"], + superclass=nova_utils.NovaScenario, + task_id=self.context["owner_id"]), + mock.call( + names=["magnum.cluster_templates"], + users=self.context["users"], + superclass=magnum_utils.MagnumScenario, + task_id=self.context["owner_id"]))) diff --git a/tests/unit/plugins/openstack/context/magnum/test_clusters.py b/tests/unit/plugins/openstack/context/magnum/test_clusters.py index c777e148..b66190eb 100644 --- a/tests/unit/plugins/openstack/context/magnum/test_clusters.py +++ b/tests/unit/plugins/openstack/context/magnum/test_clusters.py @@ -18,6 +18,7 @@ import copy import mock from rally.plugins.openstack.context.magnum import clusters +from rally.plugins.openstack.scenarios.magnum import utils as magnum_utils from tests.unit import test CTX = "rally.plugins.openstack.context.magnum" @@ -147,4 +148,6 @@ class ClustersGeneratorTestCase(test.ScenarioTestCase): clusters_ctx.cleanup() mock_cleanup.assert_called_once_with( names=["magnum.clusters"], - users=self.context["users"]) + users=self.context["users"], + superclass=magnum_utils.MagnumScenario, + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/manila/test_manila_security_services.py b/tests/unit/plugins/openstack/context/manila/test_manila_security_services.py index 3e1a1a10..534fef1e 100644 --- a/tests/unit/plugins/openstack/context/manila/test_manila_security_services.py +++ b/tests/unit/plugins/openstack/context/manila/test_manila_security_services.py @@ -19,6 +19,7 @@ import six from rally.plugins.openstack.context.manila import consts from rally.plugins.openstack.context.manila import manila_security_services +from rally.plugins.openstack.scenarios.manila import utils as manila_utils from tests.unit import test CONTEXT_NAME = consts.SECURITY_SERVICES_CONTEXT_NAME @@ -71,6 +72,7 @@ class SecurityServicesTestCase(test.ScenarioTestCase): "endpoint": mock.MagicMock(), }, "task": mock.MagicMock(), + "owner_id": "foo_uuid", "users": users, "tenants": tenants, } @@ -108,6 +110,7 @@ class SecurityServicesTestCase(test.ScenarioTestCase): mock_manila_scenario.call_args_list, [mock.call({ "task": inst.task, + "owner_id": "foo_uuid", "config": {"api_versions": []}, "user": user}) for user in inst.context["users"] if user["id"] == 0] @@ -162,4 +165,7 @@ class SecurityServicesTestCase(test.ScenarioTestCase): inst.cleanup() mock_resource_manager.cleanup.assert_called_once_with( - names=["manila.security_services"], users=ctxt["users"]) + names=["manila.security_services"], + users=ctxt["users"], + superclass=manila_utils.ManilaScenario, + task_id="foo_uuid") diff --git a/tests/unit/plugins/openstack/context/manila/test_manila_shares.py b/tests/unit/plugins/openstack/context/manila/test_manila_shares.py index 3fcd9c06..6f023533 100644 --- a/tests/unit/plugins/openstack/context/manila/test_manila_shares.py +++ b/tests/unit/plugins/openstack/context/manila/test_manila_shares.py @@ -22,6 +22,7 @@ import six from rally import consts as rally_consts from rally.plugins.openstack.context.manila import consts from rally.plugins.openstack.context.manila import manila_shares +from rally.plugins.openstack.scenarios.manila import utils as manila_utils from tests.unit import test MANILA_UTILS_PATH = ( @@ -80,6 +81,7 @@ class SharesTestCase(test.TestCase): "credential": mock.MagicMock(), }, "task": mock.MagicMock(), + "owner_id": "foo_uuid", "users": users, "tenants": tenants, } @@ -199,4 +201,5 @@ class SharesTestCase(test.TestCase): mock_cleanup_manager_cleanup.assert_called_once_with( names=["manila.shares"], users=inst.context.get("users", []), - ) + superclass=manila_utils.ManilaScenario, + task_id="foo_uuid") diff --git a/tests/unit/plugins/openstack/context/murano/test_murano_environments.py b/tests/unit/plugins/openstack/context/murano/test_murano_environments.py index 40eed37f..69fe47fb 100644 --- a/tests/unit/plugins/openstack/context/murano/test_murano_environments.py +++ b/tests/unit/plugins/openstack/context/murano/test_murano_environments.py @@ -16,6 +16,7 @@ import mock from rally.plugins.openstack.context.murano import murano_environments +from rally.plugins.openstack.scenarios.murano import utils as murano_utils from tests.unit import test CTX = "rally.plugins.openstack.context.murano.murano_environments" @@ -44,6 +45,7 @@ class MuranoEnvironmentGeneratorTestCase(test.TestCase): "credential": mock.MagicMock() }, "task": mock.MagicMock(), + "owner_id": "foo_uuid", "users": [ { "id": "user_0", @@ -82,5 +84,8 @@ class MuranoEnvironmentGeneratorTestCase(test.TestCase): murano_ctx.setup() murano_ctx.cleanup() - mock_cleanup.assert_called_once_with(names=["murano.environments"], - users=murano_ctx.context["users"]) + mock_cleanup.assert_called_once_with( + names=["murano.environments"], + users=murano_ctx.context["users"], + superclass=murano_utils.MuranoScenario, + task_id="foo_uuid") diff --git a/tests/unit/plugins/openstack/context/murano/test_murano_packages.py b/tests/unit/plugins/openstack/context/murano/test_murano_packages.py index 0815e27c..200c7c60 100644 --- a/tests/unit/plugins/openstack/context/murano/test_murano_packages.py +++ b/tests/unit/plugins/openstack/context/murano/test_murano_packages.py @@ -16,7 +16,6 @@ import mock from rally.plugins.openstack.context.murano import murano_packages -from rally.plugins.openstack.scenarios.murano import utils as murano_utils from tests.unit import test CTX = "rally.plugins.openstack.context.murano.murano_packages" @@ -47,6 +46,7 @@ class MuranoPackageGeneratorTestCase(test.TestCase): "credential": mock.MagicMock() }, "task": mock.MagicMock(), + "owner_id": "foo_uuid", "users": [ { "id": "user_0", @@ -93,8 +93,8 @@ class MuranoPackageGeneratorTestCase(test.TestCase): mock_cleanup.assert_called_once_with( names=["murano.packages"], users=murano_ctx.context["users"], - superclass=murano_utils.MuranoScenario, - task_id=murano_ctx.context["task"]["uuid"]) + superclass=murano_packages.PackageGenerator, + task_id="foo_uuid") @mock.patch("%s.osclients" % CTX) @mock.patch("%s.resource_manager.cleanup" % CTX) @@ -114,5 +114,5 @@ class MuranoPackageGeneratorTestCase(test.TestCase): mock_cleanup.assert_called_once_with( names=["murano.packages"], users=murano_ctx.context["users"], - superclass=murano_utils.MuranoScenario, - task_id=ctx_dict["task"]["uuid"]) + superclass=murano_packages.PackageGenerator, + task_id="foo_uuid") diff --git a/tests/unit/plugins/openstack/context/nova/test_servers.py b/tests/unit/plugins/openstack/context/nova/test_servers.py index 2bddcc09..f8675041 100755 --- a/tests/unit/plugins/openstack/context/nova/test_servers.py +++ b/tests/unit/plugins/openstack/context/nova/test_servers.py @@ -174,4 +174,4 @@ class ServerGeneratorTestCase(test.ScenarioTestCase): names=["nova.servers"], users=self.context["users"], superclass=nova_utils.NovaScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) diff --git a/tests/unit/plugins/openstack/context/sahara/test_sahara_cluster.py b/tests/unit/plugins/openstack/context/sahara/test_sahara_cluster.py index df81caaa..2d310c8c 100644 --- a/tests/unit/plugins/openstack/context/sahara/test_sahara_cluster.py +++ b/tests/unit/plugins/openstack/context/sahara/test_sahara_cluster.py @@ -111,7 +111,7 @@ class SaharaClusterTestCase(test.ScenarioTestCase): names=["sahara.clusters"], users=self.context["users"], superclass=sahara_utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + task_id=self.context["owner_id"]) @mock.patch("%s.sahara_cluster.utils.SaharaScenario._launch_cluster" % CTX, return_value=mock.MagicMock(id=42)) diff --git a/tests/unit/plugins/openstack/context/sahara/test_sahara_image.py b/tests/unit/plugins/openstack/context/sahara/test_sahara_image.py index cb8a4d3d..6414db46 100644 --- a/tests/unit/plugins/openstack/context/sahara/test_sahara_image.py +++ b/tests/unit/plugins/openstack/context/sahara/test_sahara_image.py @@ -133,7 +133,7 @@ class SaharaImageTestCase(test.ScenarioTestCase): names=["glance.images"], users=ctx["users"], superclass=sahara_ctx.__class__, - task_id=ctx["task"]["uuid"]) + task_id=ctx["owner_id"]) @mock.patch("%s.glance.utils.GlanceScenario._create_image" % SCN, return_value=mock.MagicMock(id=42)) diff --git a/tests/unit/plugins/openstack/context/sahara/test_sahara_input_data_sources.py b/tests/unit/plugins/openstack/context/sahara/test_sahara_input_data_sources.py index 47d45c7f..9bad8706 100644 --- a/tests/unit/plugins/openstack/context/sahara/test_sahara_input_data_sources.py +++ b/tests/unit/plugins/openstack/context/sahara/test_sahara_input_data_sources.py @@ -15,7 +15,7 @@ import mock from rally.plugins.openstack.context.sahara import sahara_input_data_sources -from rally.plugins.openstack.scenarios.sahara import utils as sahara_utils +from rally.plugins.openstack.scenarios.swift import utils as swift_utils from tests.unit import test CTX = "rally.plugins.openstack.context.sahara" @@ -88,11 +88,16 @@ class SaharaInputDataSourcesTestCase(test.ScenarioTestCase): sahara_ctx.cleanup() - mock_cleanup.assert_called_once_with( - names=["sahara.data_sources"], - users=self.context["users"], - superclass=sahara_utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + mock_cleanup.assert_has_calls(( + mock.call(names=["swift.object", "swift.container"], + users=self.context["users"], + superclass=swift_utils.SwiftScenario, + task_id=self.context["owner_id"]), + mock.call( + names=["sahara.data_sources"], + users=self.context["users"], + superclass=sahara_input_data_sources.SaharaInputDataSources, + task_id=self.context["owner_id"]))) @mock.patch("requests.get") @mock.patch("%s.sahara_input_data_sources.osclients" % CTX) @@ -156,8 +161,13 @@ class SaharaInputDataSourcesTestCase(test.ScenarioTestCase): sahara_ctx.cleanup() - mock_resource_manager.cleanup.assert_called_once_with( - names=["sahara.data_sources"], - users=self.context["users"], - superclass=sahara_utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + mock_resource_manager.cleanup.assert_has_calls(( + mock.call(names=["swift.object", "swift.container"], + users=self.context["users"], + superclass=mock_swift_utils.SwiftScenario, + task_id=self.context["owner_id"]), + mock.call( + names=["sahara.data_sources"], + users=self.context["users"], + superclass=sahara_input_data_sources.SaharaInputDataSources, + task_id=self.context["owner_id"]))) diff --git a/tests/unit/plugins/openstack/context/sahara/test_sahara_output_data_sources.py b/tests/unit/plugins/openstack/context/sahara/test_sahara_output_data_sources.py index 0659e154..e4839000 100644 --- a/tests/unit/plugins/openstack/context/sahara/test_sahara_output_data_sources.py +++ b/tests/unit/plugins/openstack/context/sahara/test_sahara_output_data_sources.py @@ -16,7 +16,6 @@ import mock from rally.plugins.openstack.context.sahara import sahara_output_data_sources from rally.plugins.openstack import credential as oscredential -from rally.plugins.openstack.scenarios.sahara import utils as sahara_utils from tests.unit import test CTX = "rally.plugins.openstack.context.sahara" @@ -98,11 +97,17 @@ class SaharaOutputDataSourcesTestCase(test.ScenarioTestCase): sahara_ctx.cleanup() - mock_cleanup.assert_called_once_with( - names=["sahara.data_sources"], - users=self.context["users"], - superclass=sahara_utils.SaharaScenario, - task_id=self.context["task"]["uuid"]) + mock_cleanup.assert_has_calls(( + mock.call( + names=["swift.object", "swift.container"], + users=self.context["users"], + superclass=sahara_output_data_sources.SaharaOutputDataSources, + task_id=self.context["owner_id"]), + mock.call( + names=["sahara.data_sources"], + users=self.context["users"], + superclass=sahara_output_data_sources.SaharaOutputDataSources, + task_id=self.context["owner_id"]))) @mock.patch("%s.sahara_output_data_sources.osclients" % CTX) def test_setup_inputs_swift(self, mock_osclients): diff --git a/tests/unit/plugins/openstack/context/watcher/test_audit_templates.py b/tests/unit/plugins/openstack/context/watcher/test_audit_templates.py index 31b95421..751373c0 100644 --- a/tests/unit/plugins/openstack/context/watcher/test_audit_templates.py +++ b/tests/unit/plugins/openstack/context/watcher/test_audit_templates.py @@ -15,6 +15,7 @@ import mock from rally.plugins.openstack.context.watcher import audit_templates +from rally.plugins.openstack.scenarios.watcher import utils as watcher_utils from tests.unit import fakes from tests.unit import test @@ -91,4 +92,6 @@ class AuditTemplateTestCase(test.ScenarioTestCase): audit_templates_ctx.cleanup() mock_cleanup.assert_called_once_with( names=["watcher.action_plan", "watcher.audit_template"], - admin=self.context["admin"]) + admin=self.context["admin"], + superclass=watcher_utils.WatcherScenario, + task_id=self.context["owner_id"]) diff --git a/tests/unit/test.py b/tests/unit/test.py index 865c5d58..558820e3 100644 --- a/tests/unit/test.py +++ b/tests/unit/test.py @@ -208,4 +208,5 @@ class FakeClientsScenarioTestCase(ScenarioTestCase): def get_test_context(**kwargs): kwargs["task"] = {"uuid": str(uuid.uuid4())} + kwargs["owner_id"] = str(uuid.uuid4()) return kwargs