Merge "Implement new random name generator for keystone scenarios"
This commit is contained in:
commit
f871de8422
@ -18,8 +18,6 @@
|
||||
|
||||
KeystoneBasic.create_and_list_tenants:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
context:
|
||||
{{ user_context(tenants_amount, users_amount, use_existing_users) }}
|
||||
runner:
|
||||
@ -56,11 +54,9 @@
|
||||
|
||||
KeystoneBasic.create_update_and_delete_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
context:
|
||||
{{ user_context(tenants_amount, users_amount, use_existing_users) }}
|
||||
runner:
|
||||
{{ constant_runner(15*controllers_amount,60*controllers_amount) }}
|
||||
sla:
|
||||
{{ no_failures_sla() }}
|
||||
{{ no_failures_sla() }}
|
||||
|
@ -84,9 +84,7 @@ As an example, let's edit our configuration file from :ref:`step 1 <tutorial_ste
|
||||
],
|
||||
"KeystoneBasic.create_delete_user": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
|
@ -262,8 +262,7 @@ As an example, let us make up a task file that will create new users with increa
|
||||
KeystoneBasic.create_user:
|
||||
{% for i in range(2, 11, 2) %}
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -289,8 +288,7 @@ In this case, you don’t need to pass any arguments via *--task-args/--task-arg
|
||||
KeystoneBasic.create_user:
|
||||
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -300,8 +298,7 @@ In this case, you don’t need to pass any arguments via *--task-args/--task-arg
|
||||
max: 0
|
||||
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -311,8 +308,7 @@ In this case, you don’t need to pass any arguments via *--task-args/--task-arg
|
||||
max: 0
|
||||
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -322,8 +318,7 @@ In this case, you don’t need to pass any arguments via *--task-args/--task-arg
|
||||
max: 0
|
||||
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -333,8 +328,7 @@ In this case, you don’t need to pass any arguments via *--task-args/--task-arg
|
||||
max: 0
|
||||
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
KeystoneBasic.create_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
@ -14,8 +13,7 @@
|
||||
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
@ -26,8 +24,7 @@
|
||||
|
||||
KeystoneBasic.create_and_list_tenants:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
@ -38,8 +35,7 @@
|
||||
|
||||
KeystoneBasic.create_and_list_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
@ -50,8 +46,7 @@
|
||||
|
||||
KeystoneBasic.create_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
@ -63,7 +58,6 @@
|
||||
KeystoneBasic.create_tenant_with_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
users_per_tenant: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
@ -78,8 +72,7 @@
|
||||
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -13,8 +12,7 @@
|
||||
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -47,8 +45,7 @@
|
||||
|
||||
KeystoneBasic.create_and_list_tenants:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -127,8 +124,7 @@
|
||||
|
||||
KeystoneBasic.create_and_list_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -139,8 +135,7 @@
|
||||
|
||||
KeystoneBasic.create_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -152,7 +147,6 @@
|
||||
KeystoneBasic.create_tenant_with_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
users_per_tenant: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
@ -167,9 +161,7 @@
|
||||
|
||||
KeystoneBasic.create_user_update_password:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
password_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -180,8 +172,7 @@
|
||||
|
||||
KeystoneBasic.create_update_and_delete_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
@ -192,8 +183,7 @@
|
||||
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
|
@ -22,29 +22,25 @@ from rally.task import validation
|
||||
class KeystoneBasic(kutils.KeystoneScenario):
|
||||
"""Basic benchmark scenarios for Keystone."""
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_user(self, name_length=10, **kwargs):
|
||||
def create_user(self, **kwargs):
|
||||
"""Create a keystone user with random name.
|
||||
|
||||
:param name_length: length of the random part of user name
|
||||
:param kwargs: Other optional parameters to create users like
|
||||
"tenant_id", "enabled".
|
||||
"""
|
||||
self._user_create(name_length=name_length, **kwargs)
|
||||
self._user_create(**kwargs)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_delete_user(self, name_length=10, **kwargs):
|
||||
def create_delete_user(self, **kwargs):
|
||||
"""Create a keystone user with random name and then delete it.
|
||||
|
||||
:param name_length: length of the random part of user name
|
||||
:param kwargs: Other optional parameters to create users like
|
||||
"tenant_id", "enabled".
|
||||
"""
|
||||
user = self._user_create(name_length=name_length, **kwargs)
|
||||
user = self._user_create(**kwargs)
|
||||
self._resource_delete(user)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
@ -61,57 +57,47 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
self._update_user_enabled(user, not enabled)
|
||||
self._resource_delete(user)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_tenant(self, name_length=10, **kwargs):
|
||||
def create_tenant(self, **kwargs):
|
||||
"""Create a keystone tenant with random name.
|
||||
|
||||
:param name_length: length of the random part of tenant name
|
||||
:param kwargs: Other optional parameters
|
||||
"""
|
||||
self._tenant_create(name_length=name_length, **kwargs)
|
||||
self._tenant_create(**kwargs)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.number("users_per_tenant", minval=1)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_tenant_with_users(self, users_per_tenant, name_length=10,
|
||||
**kwargs):
|
||||
def create_tenant_with_users(self, users_per_tenant, **kwargs):
|
||||
"""Create a keystone tenant and several users belonging to it.
|
||||
|
||||
:param name_length: length of the random part of tenant/user name
|
||||
:param users_per_tenant: number of users to create for the tenant
|
||||
:param kwargs: Other optional parameters for tenant creation
|
||||
:returns: keystone tenant instance
|
||||
"""
|
||||
tenant = self._tenant_create(name_length=name_length, **kwargs)
|
||||
self._users_create(tenant, users_per_tenant=users_per_tenant,
|
||||
name_length=name_length)
|
||||
tenant = self._tenant_create(**kwargs)
|
||||
self._users_create(tenant, users_per_tenant=users_per_tenant)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_and_list_users(self, name_length=10, **kwargs):
|
||||
def create_and_list_users(self, **kwargs):
|
||||
"""Create a keystone user with random name and list all users.
|
||||
|
||||
:param name_length: length of the random part of user name
|
||||
:param kwargs: Other optional parameters to create users like
|
||||
"tenant_id", "enabled".
|
||||
"""
|
||||
self._user_create(name_length=name_length, **kwargs)
|
||||
self._user_create(**kwargs)
|
||||
self._list_users()
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_and_list_tenants(self, name_length=10, **kwargs):
|
||||
def create_and_list_tenants(self, **kwargs):
|
||||
"""Create a keystone tenant with random name and list all tenants.
|
||||
|
||||
:param name_length: length of the random part of tenant name
|
||||
:param kwargs: Other optional parameters
|
||||
"""
|
||||
self._tenant_create(name_length=name_length, **kwargs)
|
||||
self._tenant_create(**kwargs)
|
||||
self._list_tenants()
|
||||
|
||||
@validation.required_openstack(admin=True, users=True)
|
||||
@ -157,8 +143,8 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
None, to create an ephemeral service and
|
||||
get it by ID.
|
||||
"""
|
||||
tenant = self._tenant_create(name_length=5)
|
||||
user = self._user_create(name_length=10)
|
||||
tenant = self._tenant_create()
|
||||
user = self._user_create()
|
||||
role = self._role_create()
|
||||
self._get_tenant(tenant.id)
|
||||
self._get_user(user.id)
|
||||
@ -184,31 +170,23 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
service = self._service_create(service_type, description)
|
||||
self._delete_service(service.id)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_update_and_delete_tenant(self, name_length=10, **kwargs):
|
||||
def create_update_and_delete_tenant(self, **kwargs):
|
||||
"""Create, update and delete tenant.
|
||||
|
||||
:param name_length: length of the random part of tenant name
|
||||
:param kwargs: Other optional parameters for tenant creation
|
||||
"""
|
||||
tenant = self._tenant_create(name_length=name_length, **kwargs)
|
||||
tenant = self._tenant_create(**kwargs)
|
||||
self._update_tenant(tenant)
|
||||
self._resource_delete(tenant)
|
||||
|
||||
@validation.number("password_length", minval=10)
|
||||
@validation.number("name_length", minval=10)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||
def create_user_update_password(self, name_length=10, password_length=10):
|
||||
"""Create user and update password for that user.
|
||||
|
||||
:param name_length: length of the user name
|
||||
:param password_length: length of the password
|
||||
"""
|
||||
password = self._generate_random_name(length=password_length)
|
||||
user = self._user_create(name_length=name_length)
|
||||
def create_user_update_password(self):
|
||||
"""Create user and update password for that user."""
|
||||
password = self.generate_random_name()
|
||||
user = self._user_create()
|
||||
self._update_user_password(user.id, password)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
|
@ -15,29 +15,27 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from rally.common import utils
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task import atomic
|
||||
|
||||
|
||||
def is_temporary(resource):
|
||||
return resource.name.startswith(KeystoneScenario.RESOURCE_NAME_PREFIX)
|
||||
return utils.name_matches_object(resource.name, KeystoneScenario)
|
||||
|
||||
|
||||
class KeystoneScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Keystone scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_keystone_"
|
||||
|
||||
@atomic.action_timer("keystone.create_user")
|
||||
def _user_create(self, name_length=10, email=None, **kwargs):
|
||||
def _user_create(self, email=None, **kwargs):
|
||||
"""Creates keystone user with random name.
|
||||
|
||||
:param name_length: length of generated (random) part of name
|
||||
:param kwargs: Other optional parameters to create users like
|
||||
"tenant_id", "enabled".
|
||||
:returns: keystone user instance
|
||||
"""
|
||||
name = self._generate_random_name(length=name_length)
|
||||
name = self.generate_random_name()
|
||||
# NOTE(boris-42): password and email parameters are required by
|
||||
# keystone client v2.0. This should be cleanuped
|
||||
# when we switch to v3.
|
||||
@ -63,14 +61,13 @@ class KeystoneScenario(scenario.OpenStackScenario):
|
||||
resource.delete()
|
||||
|
||||
@atomic.action_timer("keystone.create_tenant")
|
||||
def _tenant_create(self, name_length=10, **kwargs):
|
||||
def _tenant_create(self, **kwargs):
|
||||
"""Creates keystone tenant with random name.
|
||||
|
||||
:param name_length: length of generated (random) part of name
|
||||
:param kwargs: Other optional parameters
|
||||
:returns: keystone tenant instance
|
||||
"""
|
||||
name = self._generate_random_name(length=name_length)
|
||||
name = self.generate_random_name()
|
||||
return self.admin_clients("keystone").tenants.create(name, **kwargs)
|
||||
|
||||
@atomic.action_timer("keystone.create_service")
|
||||
@ -78,41 +75,37 @@ class KeystoneScenario(scenario.OpenStackScenario):
|
||||
description=None):
|
||||
"""Creates keystone service with random name.
|
||||
|
||||
:param name: name of the service
|
||||
:param service_type: type of the service
|
||||
:param description: description of the service
|
||||
:returns: keystone service instance
|
||||
"""
|
||||
description = description or self._generate_random_name(
|
||||
prefix="rally_test_service_description_")
|
||||
description = description or self.generate_random_name()
|
||||
return self.admin_clients("keystone").services.create(
|
||||
self._generate_random_name(),
|
||||
self.generate_random_name(),
|
||||
service_type, description)
|
||||
|
||||
@atomic.action_timer("keystone.create_users")
|
||||
def _users_create(self, tenant, users_per_tenant, name_length=10):
|
||||
def _users_create(self, tenant, users_per_tenant):
|
||||
"""Adds users to a tenant.
|
||||
|
||||
:param tenant: tenant object
|
||||
:param users_per_tenant: number of users in per tenant
|
||||
:param name_length: length of generated (random) part of name for user
|
||||
"""
|
||||
for i in range(users_per_tenant):
|
||||
name = self._generate_random_name(length=name_length)
|
||||
name = self.generate_random_name()
|
||||
password = name
|
||||
email = (name + "@rally.me")
|
||||
email = name + "@rally.me"
|
||||
self.admin_clients("keystone").users.create(
|
||||
name, password=password, email=email, tenant_id=tenant.id)
|
||||
|
||||
@atomic.action_timer("keystone.create_role")
|
||||
def _role_create(self, name_length=5):
|
||||
def _role_create(self):
|
||||
"""Creates keystone user role with random name.
|
||||
|
||||
:param name_length: length of generated (random) part of role name
|
||||
:returns: keystone user role instance
|
||||
"""
|
||||
role = self.admin_clients("keystone").roles.create(
|
||||
self._generate_random_name(length=name_length))
|
||||
self.generate_random_name())
|
||||
return role
|
||||
|
||||
@atomic.action_timer("keystone.list_users")
|
||||
@ -207,15 +200,14 @@ class KeystoneScenario(scenario.OpenStackScenario):
|
||||
self.admin_clients("keystone").services.delete(service_id)
|
||||
|
||||
@atomic.action_timer("keystone.update_tenant")
|
||||
def _update_tenant(self, tenant, name=None, description=None):
|
||||
def _update_tenant(self, tenant, description=None):
|
||||
"""Update tenant name and description.
|
||||
|
||||
:param tenant: tenant to be updated
|
||||
:param name: tenant name to be set
|
||||
:param description: tenant description to be set
|
||||
"""
|
||||
name = name or (tenant.name + "_updated")
|
||||
description = description or (tenant.name + "_description_updated")
|
||||
name = self.generate_random_name()
|
||||
description = description or self.generate_random_name()
|
||||
self.admin_clients("keystone").tenants.update(tenant.id,
|
||||
name, description)
|
||||
|
||||
|
@ -93,23 +93,30 @@ class ConfigurePluginMeta(type):
|
||||
@six.add_metaclass(ConfigurePluginMeta)
|
||||
class Scenario(plugin.Plugin,
|
||||
atomic.ActionTimerMixin,
|
||||
functional.FunctionalMixin):
|
||||
functional.FunctionalMixin,
|
||||
utils.RandomNameGeneratorMixin):
|
||||
"""This is base class for any benchmark scenario.
|
||||
|
||||
You should create subclass of this class. And your test scenarios will
|
||||
be auto discoverable and you will be able to specify it in test config.
|
||||
"""
|
||||
# NOTE(stpierre): Old random name generator parameters, to be
|
||||
# removed in a subsequent commit
|
||||
RESOURCE_NAME_PREFIX = "rally_"
|
||||
RESOURCE_NAME_LENGTH = 10
|
||||
|
||||
RESOURCE_NAME_FORMAT = "s_rally_XXXXXXXX_XXXXXXXX"
|
||||
|
||||
def __init__(self, context=None):
|
||||
super(Scenario, self).__init__()
|
||||
self.context = context
|
||||
self.context = context or {}
|
||||
self.task = self.context.get("task", {})
|
||||
self._idle_duration = 0
|
||||
|
||||
# TODO(amaretskiy): consider about prefix part of benchmark uuid
|
||||
@classmethod
|
||||
def _generate_random_name(cls, prefix=None, length=None):
|
||||
# NOTE(stpierre): Old random name generator function, to be
|
||||
# removed in a subsequent commit
|
||||
prefix = cls.RESOURCE_NAME_PREFIX if prefix is None else prefix
|
||||
length = length or cls.RESOURCE_NAME_LENGTH
|
||||
return utils.generate_random_name(prefix, length)
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_delete_user": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_and_list_tenants": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_and_list_tenants:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_and_list_users": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_and_list_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -2,7 +2,6 @@
|
||||
"KeystoneBasic.create_tenant_with_users": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10,
|
||||
"users_per_tenant": 10
|
||||
},
|
||||
"runner": {
|
||||
|
@ -2,7 +2,6 @@
|
||||
KeystoneBasic.create_tenant_with_users:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
users_per_tenant: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_tenant": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_update_and_delete_tenant": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_update_and_delete_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_user": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -1,10 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_user_update_password": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10,
|
||||
"password_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
@ -12,4 +9,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
---
|
||||
KeystoneBasic.create_user_update_password:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
password_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
concurrency: 10
|
||||
concurrency: 10
|
||||
|
@ -1,9 +1,7 @@
|
||||
{
|
||||
"KeystoneBasic.create_delete_user": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 100,
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
KeystoneBasic.create_delete_user:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
|
@ -722,7 +722,7 @@ class SLATestCase(unittest.TestCase):
|
||||
"KeystoneBasic.create_and_list_users": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
"enabled": True
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
|
@ -36,27 +36,23 @@ class KeystoneBasicTestCase(test.ScenarioTestCase):
|
||||
})
|
||||
return context
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_user(self, mock_generate_random_name):
|
||||
def test_create_user(self):
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
scenario._user_create = mock.MagicMock()
|
||||
scenario.create_user(name_length=20, password="tttt", tenant_id="id")
|
||||
scenario._user_create.assert_called_once_with(name_length=20,
|
||||
password="tttt",
|
||||
scenario.create_user(password="tttt", tenant_id="id")
|
||||
scenario._user_create.assert_called_once_with(password="tttt",
|
||||
tenant_id="id")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_delete_user(self, mock_generate_random_name):
|
||||
def test_create_delete_user(self):
|
||||
create_result = mock.MagicMock()
|
||||
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
scenario._user_create = mock.MagicMock(return_value=create_result)
|
||||
scenario._resource_delete = mock.MagicMock()
|
||||
|
||||
scenario.create_delete_user(name_length=30, email="abcd", enabled=True)
|
||||
scenario.create_delete_user(email="abcd", enabled=True)
|
||||
|
||||
scenario._user_create.assert_called_once_with(name_length=30,
|
||||
email="abcd",
|
||||
scenario._user_create.assert_called_once_with(email="abcd",
|
||||
enabled=True)
|
||||
scenario._resource_delete.assert_called_once_with(create_result)
|
||||
|
||||
@ -75,48 +71,37 @@ class KeystoneBasicTestCase(test.ScenarioTestCase):
|
||||
scenario._resource_delete.assert_called_once_with(
|
||||
scenario._user_create.return_value)
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_tenant(self, mock_generate_random_name):
|
||||
def test_create_tenant(self):
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
scenario._tenant_create = mock.MagicMock()
|
||||
scenario.create_tenant(name_length=20, enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(name_length=20,
|
||||
enabled=True)
|
||||
scenario.create_tenant(enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(enabled=True)
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_tenant_with_users(self, mock_generate_random_name):
|
||||
def test_create_tenant_with_users(self):
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
fake_tenant = mock.MagicMock()
|
||||
scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
|
||||
scenario._users_create = mock.MagicMock()
|
||||
scenario.create_tenant_with_users(users_per_tenant=1, name_length=20,
|
||||
enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(name_length=20,
|
||||
enabled=True)
|
||||
scenario.create_tenant_with_users(users_per_tenant=1, enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(enabled=True)
|
||||
scenario._users_create.assert_called_once_with(fake_tenant,
|
||||
users_per_tenant=1,
|
||||
name_length=20)
|
||||
users_per_tenant=1)
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_and_list_users(self, mock_generate_random_name):
|
||||
def test_create_and_list_users(self):
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
scenario._user_create = mock.MagicMock()
|
||||
scenario._list_users = mock.MagicMock()
|
||||
scenario.create_and_list_users(name_length=20, password="tttt",
|
||||
tenant_id="id")
|
||||
scenario._user_create.assert_called_once_with(name_length=20,
|
||||
password="tttt",
|
||||
scenario.create_and_list_users(password="tttt", tenant_id="id")
|
||||
scenario._user_create.assert_called_once_with(password="tttt",
|
||||
tenant_id="id")
|
||||
scenario._list_users.assert_called_once_with()
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_and_list_tenants(self, mock_generate_random_name):
|
||||
def test_create_and_list_tenants(self):
|
||||
scenario = basic.KeystoneBasic(self.context)
|
||||
scenario._tenant_create = mock.MagicMock()
|
||||
scenario._list_tenants = mock.MagicMock()
|
||||
scenario.create_and_list_tenants(name_length=20, enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(name_length=20,
|
||||
enabled=True)
|
||||
scenario.create_and_list_tenants(enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(enabled=True)
|
||||
scenario._list_tenants.assert_called_with()
|
||||
|
||||
def test_assign_and_remove_user_role(self):
|
||||
@ -187,8 +172,8 @@ class KeystoneBasicTestCase(test.ScenarioTestCase):
|
||||
|
||||
scenario.get_entities(service_name)
|
||||
|
||||
scenario._tenant_create.assert_called_once_with(name_length=5)
|
||||
scenario._user_create.assert_called_once_with(name_length=10)
|
||||
scenario._tenant_create.assert_called_once_with()
|
||||
scenario._user_create.assert_called_once_with()
|
||||
scenario._role_create.assert_called_once_with()
|
||||
|
||||
scenario._get_tenant.assert_called_once_with(fake_tenant.id)
|
||||
@ -240,13 +225,13 @@ class KeystoneBasicTestCase(test.ScenarioTestCase):
|
||||
fake_password = "pswd"
|
||||
fake_user = mock.MagicMock()
|
||||
scenario._user_create = mock.MagicMock(return_value=fake_user)
|
||||
scenario._generate_random_name = mock.MagicMock(
|
||||
scenario.generate_random_name = mock.MagicMock(
|
||||
return_value=fake_password)
|
||||
scenario._update_user_password = mock.MagicMock()
|
||||
|
||||
scenario.create_user_update_password(name_length=9, password_length=9)
|
||||
scenario._generate_random_name.assert_called_once_with(length=9)
|
||||
scenario._user_create.assert_called_once_with(name_length=9)
|
||||
scenario.create_user_update_password()
|
||||
scenario.generate_random_name.assert_called_once_with()
|
||||
scenario._user_create.assert_called_once_with()
|
||||
scenario._update_user_password.assert_called_once_with(fake_user.id,
|
||||
fake_password)
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from rally.plugins.openstack.scenarios.keystone import utils
|
||||
from tests.unit import fakes
|
||||
@ -25,33 +24,21 @@ UTILS = "rally.plugins.openstack.scenarios.keystone.utils."
|
||||
|
||||
class KeystoneUtilsTestCase(test.TestCase):
|
||||
|
||||
def test_RESOURCE_NAME_PREFIX(self):
|
||||
self.assertIsInstance(utils.KeystoneScenario.RESOURCE_NAME_PREFIX,
|
||||
six.string_types)
|
||||
# Prefix must be long enough to guarantee that resource
|
||||
# to be recognized as created by rally
|
||||
self.assertTrue(
|
||||
len(utils.KeystoneScenario.RESOURCE_NAME_PREFIX) > 7)
|
||||
|
||||
def test_is_temporary(self):
|
||||
prefix = utils.KeystoneScenario.RESOURCE_NAME_PREFIX
|
||||
tests = [
|
||||
(fakes.FakeResource(name=prefix + "abc"), True),
|
||||
(fakes.FakeResource(name="another"), False),
|
||||
(fakes.FakeResource(name=prefix[:-3] + "abc"), False)
|
||||
]
|
||||
|
||||
for resource, is_valid in tests:
|
||||
self.assertEqual(utils.is_temporary(resource), is_valid)
|
||||
@mock.patch("rally.common.utils.name_matches_object")
|
||||
def test_is_temporary(self, mock_name_matches_object):
|
||||
resource = mock.Mock()
|
||||
self.assertEqual(utils.is_temporary(resource),
|
||||
mock_name_matches_object.return_value)
|
||||
mock_name_matches_object.assert_called_once_with(
|
||||
resource.name, utils.KeystoneScenario)
|
||||
|
||||
|
||||
class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
@mock.patch(UTILS + "uuid.uuid4", return_value="pwd")
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="foobarov")
|
||||
def test_user_create(self, mock_generate_random_name, mock_uuid4):
|
||||
@mock.patch("uuid.uuid4", return_value="pwd")
|
||||
def test_user_create(self, mock_uuid4):
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario.generate_random_name = mock.Mock(return_value="foobarov")
|
||||
result = scenario._user_create()
|
||||
|
||||
self.assertEqual(
|
||||
@ -77,15 +64,15 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.update_user_enabled")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_role_create(self, mock_generate_random_name):
|
||||
def test_role_create(self):
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario.generate_random_name = mock.Mock()
|
||||
result = scenario._role_create()
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").roles.create.return_value, result)
|
||||
self.admin_clients("keystone").roles.create.assert_called_once_with(
|
||||
mock_generate_random_name.return_value)
|
||||
scenario.generate_random_name.return_value)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_role")
|
||||
|
||||
@ -142,24 +129,23 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.remove_role")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_tenant_create(self, mock_generate_random_name):
|
||||
def test_tenant_create(self):
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario.generate_random_name = mock.Mock()
|
||||
result = scenario._tenant_create()
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").tenants.create.return_value, result)
|
||||
self.admin_clients("keystone").tenants.create.assert_called_once_with(
|
||||
mock_generate_random_name.return_value)
|
||||
scenario.generate_random_name.return_value)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_tenant")
|
||||
|
||||
def test_service_create(self):
|
||||
service_type = "service_type"
|
||||
description = "_description"
|
||||
|
||||
description = "description"
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario._generate_random_name = mock.Mock()
|
||||
scenario.generate_random_name = mock.Mock()
|
||||
|
||||
result = scenario._service_create(service_type=service_type,
|
||||
description=description)
|
||||
@ -168,18 +154,17 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
self.admin_clients("keystone").services.create.return_value,
|
||||
result)
|
||||
self.admin_clients("keystone").services.create.assert_called_once_with(
|
||||
scenario._generate_random_name.return_value,
|
||||
scenario.generate_random_name.return_value,
|
||||
service_type, description)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_service")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="foobarov")
|
||||
def test_tenant_create_with_users(self, mock_generate_random_name):
|
||||
def test_tenant_create_with_users(self):
|
||||
tenant = mock.MagicMock()
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario.generate_random_name = mock.Mock(return_value="foobarov")
|
||||
|
||||
scenario._users_create(tenant, users_per_tenant=1, name_length=10)
|
||||
scenario._users_create(tenant, users_per_tenant=1)
|
||||
|
||||
self.admin_clients("keystone").users.create.assert_called_once_with(
|
||||
"foobarov", password="foobarov", email="foobarov@rally.me",
|
||||
@ -261,14 +246,15 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
|
||||
def test_update_tenant(self):
|
||||
tenant = mock.MagicMock()
|
||||
description = tenant.name + "_description_updated_test"
|
||||
name = tenant.name + "test_updated_test"
|
||||
description = "new description"
|
||||
|
||||
scenario = utils.KeystoneScenario(self.context)
|
||||
scenario._update_tenant(tenant=tenant, name=name,
|
||||
description=description)
|
||||
scenario.generate_random_name = mock.Mock()
|
||||
scenario._update_tenant(tenant=tenant, description=description)
|
||||
|
||||
self.admin_clients("keystone").tenants.update.assert_called_once_with(
|
||||
tenant.id, name, description)
|
||||
tenant.id, scenario.generate_random_name.return_value,
|
||||
description)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.update_tenant")
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
import traceback
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
@ -219,55 +218,3 @@ class ScenarioTestCase(test.TestCase):
|
||||
print(traceback.format_exc())
|
||||
self.assertTrue(False,
|
||||
"Scenario `%s` has wrong context" % scenario)
|
||||
|
||||
def test_RESOURCE_NAME_PREFIX(self):
|
||||
self.assertIsInstance(scenario.Scenario.RESOURCE_NAME_PREFIX,
|
||||
six.string_types)
|
||||
|
||||
def test_RESOURCE_NAME_LENGTH(self):
|
||||
self.assertIsInstance(scenario.Scenario.RESOURCE_NAME_LENGTH, int)
|
||||
self.assertTrue(scenario.Scenario.RESOURCE_NAME_LENGTH > 4)
|
||||
|
||||
def test_generate_random_name(self):
|
||||
set_by_length = lambda lst: set(map(len, lst))
|
||||
len_by_prefix = (lambda lst, prefix:
|
||||
len([i.startswith(prefix) for i in lst]))
|
||||
range_num = 50
|
||||
|
||||
# Defaults
|
||||
result = [scenario.Scenario._generate_random_name()
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([(len(
|
||||
scenario.Scenario.RESOURCE_NAME_PREFIX) +
|
||||
scenario.Scenario.RESOURCE_NAME_LENGTH)]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, scenario.Scenario.RESOURCE_NAME_PREFIX),
|
||||
range_num)
|
||||
|
||||
# Custom prefix
|
||||
prefix = "another_prefix_"
|
||||
result = [scenario.Scenario._generate_random_name(prefix)
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([len(prefix) + scenario.Scenario.RESOURCE_NAME_LENGTH]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, prefix), range_num)
|
||||
|
||||
# Custom length
|
||||
name_length = 12
|
||||
result = [
|
||||
scenario.Scenario._generate_random_name(length=name_length)
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([len(
|
||||
scenario.Scenario.RESOURCE_NAME_PREFIX) + name_length]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, scenario.Scenario.RESOURCE_NAME_PREFIX),
|
||||
range_num)
|
||||
|
Loading…
Reference in New Issue
Block a user