diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cf2bcdd4..12716f06 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,15 @@ Changelog .. Release notes for existing releases are MUTABLE! If there is something that was missed or can be improved, feel free to change it! +unreleased +---------- + +Changed +~~~~~~~ + +* Improved logging message for the number of used threads while creating + keystone users and projects/tenants at *users@openstack* context. + [1.5.0] - 2019-05-29 -------------------- @@ -243,8 +252,8 @@ Fixed [1.0.0] - 2018-03-28 -------------------- -Start a fork of `rally/plugins/openstack module of original OpenStack Rally -project +A start of a fork from `rally/plugins/openstack module of original OpenStack +Rally project `_ Added @@ -271,7 +280,7 @@ Changed `_. These actions should be performed via neutronclient now. It is not as simple as it was via Nova-API and you can find more neutron-related atomic actions - in results of scenarios. + in results of workloads. Removed ~~~~~~~ diff --git a/rally_openstack/contexts/keystone/users.py b/rally_openstack/contexts/keystone/users.py index c3a3fbe4..198ad440 100644 --- a/rally_openstack/contexts/keystone/users.py +++ b/rally_openstack/contexts/keystone/users.py @@ -161,9 +161,7 @@ class UserGenerator(context.Context): if default: clients.neutron().delete_security_group(default[0]["id"]) - def _create_tenants(self): - threads = self.config["resource_management_workers"] - + def _create_tenants(self, threads): tenants = collections.deque() def publish(queue): @@ -189,9 +187,8 @@ class UserGenerator(context.Context): return tenants_dict - def _create_users(self): + def _create_users(self, threads): # NOTE(msdubov): This should be called after _create_tenants(). - threads = self.config["resource_management_workers"] users_per_tenant = self.config["users_per_tenant"] default_role = cfg.CONF.openstack.keystone_default_role @@ -274,11 +271,13 @@ class UserGenerator(context.Context): def create_users(self): """Create tenants and users, using the broker pattern.""" - threads = self.config["resource_management_workers"] + + threads = min(self.config["resource_management_workers"], + self.config["tenants"]) LOG.debug("Creating %(tenants)d tenants using %(threads)s threads" % {"tenants": self.config["tenants"], "threads": threads}) - self.context["tenants"] = self._create_tenants() + self.context["tenants"] = self._create_tenants(threads) if len(self.context["tenants"]) < self.config["tenants"]: raise exceptions.ContextSetupFailure( @@ -286,9 +285,10 @@ class UserGenerator(context.Context): msg="Failed to create the requested number of tenants.") users_num = self.config["users_per_tenant"] * self.config["tenants"] + threads = min(self.config["resource_management_workers"], users_num) LOG.debug("Creating %(users)d users using %(threads)s threads" % {"users": users_num, "threads": threads}) - self.context["users"] = self._create_users() + self.context["users"] = self._create_users(threads) for user in self.context["users"]: self.context["tenants"][user["tenant_id"]]["users"].append(user) diff --git a/tests/unit/contexts/keystone/test_users.py b/tests/unit/contexts/keystone/test_users.py index 159f4a8d..24fca9aa 100644 --- a/tests/unit/contexts/keystone/test_users.py +++ b/tests/unit/contexts/keystone/test_users.py @@ -345,7 +345,7 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase): def test__create_tenants(self, mock_identity): self.context["config"]["users"]["tenants"] = 1 user_generator = users.UserGenerator(self.context) - tenants = user_generator._create_tenants() + tenants = user_generator._create_tenants(1) self.assertEqual(1, len(tenants)) id, tenant = tenants.popitem() self.assertIn("name", tenant) @@ -356,7 +356,7 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase): user_generator = users.UserGenerator(self.context) user_generator.context["tenants"] = {"t1": {"id": "t1", "name": "t1"}, "t2": {"id": "t2", "name": "t2"}} - users_ = user_generator._create_users() + users_ = user_generator._create_users(4) self.assertEqual(4, len(users_)) for user in users_: self.assertIn("id", user) @@ -369,7 +369,7 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase): user_generator = users.UserGenerator(self.context) user_generator.context["tenants"] = {"t1": {"id": "t1", "name": "t1"}, "t2": {"id": "t2", "name": "t2"}} - users_ = user_generator._create_users() + users_ = user_generator._create_users(4) self.assertEqual(4, len(users_)) for user in users_: self.assertIn("id", user) @@ -517,7 +517,7 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase): } user_generator = users.UserGenerator(config) - users_ = user_generator._create_users() + users_ = user_generator._create_users(2) for user in users_: self.assertEqual("internal", user["credential"].endpoint_type) @@ -540,7 +540,7 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase): } user_generator = users.UserGenerator(config) - users_ = user_generator._create_users() + users_ = user_generator._create_users(2) for user in users_: self.assertEqual("public", user["credential"].endpoint_type)