From 8a291b0d33ab5ec66284f2e52a34fc5d8857b3d1 Mon Sep 17 00:00:00 2001 From: Yaroslav Lobankov Date: Mon, 30 Nov 2015 21:38:38 +0300 Subject: [PATCH] [Verify] Fixing issue with failures of Heat tests If you take a look at one of latest full runs of Tempest tests, you will see that about 15 Heat tests fail. It is because of misconfigured option "instance_type" in the orchestration section and incorrect values of "max_template_size" and "max_resources_per_stack" options in config.ini. These options should have the same values like these ones have in the heat-api.conf file. So it will be better to leave the default values for them that are suitable for many deployments. So now "instance_type" option is configured, and "max_template_size" and "max_resources_per_stack" options were removed. Change-Id: I0f46e9b365cfd59905986ceb0229e85984548b5e --- rally/verification/tempest/config.ini | 3 +- rally/verification/tempest/config.py | 48 ++++++++++++++++---------- tests/unit/verification/test_config.py | 15 +++++--- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/rally/verification/tempest/config.ini b/rally/verification/tempest/config.ini index 6795b00070..7103e6d83f 100644 --- a/rally/verification/tempest/config.ini +++ b/rally/verification/tempest/config.ini @@ -43,8 +43,7 @@ ipv6 = True [oslo_concurrency] [orchestration] -max_template_size = 5440000 -max_resources_per_stack = 20000 +instance_type = [scenario] large_ops_number = 2 diff --git a/rally/verification/tempest/config.py b/rally/verification/tempest/config.py index 43714c871a..b0a36026a3 100644 --- a/rally/verification/tempest/config.py +++ b/rally/verification/tempest/config.py @@ -284,10 +284,12 @@ class TempestResourcesContext(object): def __enter__(self): self._create_tempest_roles() - self._configure_option("image_ref", self._create_image) - self._configure_option("image_ref_alt", self._create_image) - self._configure_option("flavor_ref", self._create_flavor, 64) - self._configure_option("flavor_ref_alt", self._create_flavor, 128) + self._configure_option("compute", "image_ref", self._create_image) + self._configure_option("compute", "image_ref_alt", self._create_image) + self._configure_option("compute", + "flavor_ref", self._create_flavor, 64) + self._configure_option("compute", + "flavor_ref_alt", self._create_flavor, 128) if "neutron" in self.available_services: neutronclient = self.clients.neutron() if neutronclient.list_networks(shared=True)["networks"]: @@ -300,8 +302,11 @@ class TempestResourcesContext(object): # resources. LOG.debug("Shared networks found. " "'fixed_network_name' option should be configured") - self._configure_option("fixed_network_name", + self._configure_option("compute", "fixed_network_name", self._create_network_resources) + if "heat" in self.available_services: + self._configure_option("orchestration", "instance_type", + self._create_flavor, 64) _write_config(self.conf_path, self.conf) @@ -332,15 +337,18 @@ class TempestResourcesContext(object): LOG.debug("Creating role '%s'" % role) self._created_roles.append(keystoneclient.roles.create(role)) - def _configure_option(self, option, create_method, *args, **kwargs): - option_value = self.conf.get("compute", option) + def _configure_option(self, section, option, + create_method, *args, **kwargs): + option_value = self.conf.get(section, option) if not option_value: - LOG.debug("Option '%s' is not configured" % option) + LOG.debug("Option '%s' from '%s' section " + "is not configured" % (option, section)) resource = create_method(*args, **kwargs) - res_id = resource["name"] if "network" in option else resource.id - self.conf.set("compute", option, res_id) - LOG.debug("Option '{opt}' is configured. {opt} = {resource_id}" - .format(opt=option, resource_id=res_id)) + value = resource["name"] if "network" in option else resource.id + LOG.debug("Setting value '%s' for option '%s'" % (value, option)) + self.conf.set(section, option, value) + LOG.debug("Option '{opt}' is configured. " + "{opt} = {value}".format(opt=option, value=value)) else: LOG.debug("Option '{opt}' was configured manually " "in Tempest config file. {opt} = {opt_val}" @@ -397,24 +405,26 @@ class TempestResourcesContext(object): for image in self._created_images: LOG.debug("Deleting image '%s'" % image.name) glanceclient.images.delete(image.id) - self._remove_opt_value_from_config(image.id) + self._remove_opt_value_from_config("compute", image.id) def _cleanup_flavors(self): novaclient = self.clients.nova() for flavor in self._created_flavors: LOG.debug("Deleting flavor '%s'" % flavor.name) novaclient.flavors.delete(flavor.id) - self._remove_opt_value_from_config(flavor.id) + self._remove_opt_value_from_config("compute", flavor.id) + self._remove_opt_value_from_config("orchestration", flavor.id) def _cleanup_network_resources(self): neutron_wrapper = network.NeutronWrapper(self.clients, self) for net in self._created_networks: LOG.debug("Deleting network resources: router, subnet, network") neutron_wrapper.delete_network(net) - self._remove_opt_value_from_config(net["name"]) + self._remove_opt_value_from_config("compute", net["name"]) - def _remove_opt_value_from_config(self, opt_value): - for option, value in self.conf.items("compute"): + def _remove_opt_value_from_config(self, section, opt_value): + for option, value in self.conf.items(section): if opt_value == value: - LOG.debug("Removing '%s' from Tempest config file" % opt_value) - self.conf.set("compute", option, "") + LOG.debug("Removing value '%s' for option '%s' " + "from Tempest config file" % (opt_value, option)) + self.conf.set(section, option, "") diff --git a/tests/unit/verification/test_config.py b/tests/unit/verification/test_config.py index 2ab9170325..bcaec42006 100644 --- a/tests/unit/verification/test_config.py +++ b/tests/unit/verification/test_config.py @@ -314,19 +314,21 @@ class TempestResourcesContextTestCase(test.TestCase): self.context = config.TempestResourcesContext("fake_deployment", "/fake/path/to/config") self.context.conf.add_section("compute") + self.context.conf.add_section("orchestration") @mock.patch("rally.plugins.openstack.wrappers." "network.NeutronWrapper.create_network") @mock.patch("six.moves.builtins.open", side_effect=mock.mock_open()) def test_options_configured_manually( self, mock_open, mock_neutron_wrapper_create_network): - self.context.available_services = ["glance", "nova", "neutron"] + self.context.available_services = ["glance", "heat", "nova", "neutron"] self.context.conf.set("compute", "image_ref", "id1") self.context.conf.set("compute", "image_ref_alt", "id2") self.context.conf.set("compute", "flavor_ref", "id3") self.context.conf.set("compute", "flavor_ref_alt", "id4") self.context.conf.set("compute", "fixed_network_name", "name1") + self.context.conf.set("orchestration", "instance_type", "id5") self.context.__enter__() @@ -363,7 +365,8 @@ class TempestResourcesContextTestCase(test.TestCase): create_method.side_effect = [fakes.FakeFlavor(id="id1")] self.context.conf.set("compute", "flavor_ref", "") - self.context._configure_option("flavor_ref", create_method, 64) + self.context._configure_option("compute", + "flavor_ref", create_method, 64) self.assertEqual(create_method.call_count, 1) result = self.context.conf.get("compute", "flavor_ref") @@ -420,18 +423,22 @@ class TempestResourcesContextTestCase(test.TestCase): def test__cleanup_flavors(self): self.context._created_flavors = [fakes.FakeFlavor(id="id1"), - fakes.FakeFlavor(id="id2")] + fakes.FakeFlavor(id="id2"), + fakes.FakeFlavor(id="id3")] self.context.conf.set("compute", "flavor_ref", "id1") self.context.conf.set("compute", "flavor_ref_alt", "id2") + self.context.conf.set("orchestration", "instance_type", "id3") self.context._cleanup_flavors() client = self.context.clients.nova() - self.assertEqual(client.flavors.delete.call_count, 2) + self.assertEqual(client.flavors.delete.call_count, 3) self.assertEqual("", self.context.conf.get("compute", "flavor_ref")) self.assertEqual("", self.context.conf.get("compute", "flavor_ref_alt")) + self.assertEqual("", self.context.conf.get("orchestration", + "instance_type")) @mock.patch("rally.plugins.openstack.wrappers." "network.NeutronWrapper.delete_network")