Add Keystone ec2-credentials scenarios

This submission adds methods to basic.py and utils.py
under rally/plugins/openstack/scenarios/keystone

Add configuration files for ec2-credentials
operations
1) create-and-list-ec2credentials.json
2) create-and-list-ec2credentials.yaml
3) create-and-delete-ec2credential.json
4) create-and-delete-ec2credential.yaml

Add unittests to test_utils.py and test_basic.py

Co-Authored-By: Ravikumar Venkatesan <ravikumar.venkatesan@hp.com>
Co-Authored-By: Roman Vasilets <rvasilets@mirantis.com>

Change-Id: Icdc786a144a42e983c79f70262e1f785dbe99e44
This commit is contained in:
ravikumar-venkatesan 2015-04-28 07:09:24 +00:00 committed by Roman Vasilets
parent 0028f571ae
commit df216c9537
9 changed files with 191 additions and 2 deletions

View File

@ -200,6 +200,34 @@
failure_rate:
max: 0
KeystoneBasic.create_and_list_ec2credentials:
-
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
KeystoneBasic.create_and_delete_ec2credential:
-
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CeilometerAlarms.create_alarm:
-
args:

View File

@ -206,3 +206,19 @@ class KeystoneBasic(kutils.KeystoneScenario):
"""
self._service_create(name, service_type, description)
self._list_services()
@validation.required_openstack(users=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_and_list_ec2credentials(self):
"""Create and List all keystone ec2-credentials."""
self._create_ec2credentials(self.context["user"]["id"],
self.context["tenant"]["id"])
self._list_ec2credentials(self.context["user"]["id"])
@validation.required_openstack(users=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_and_delete_ec2credential(self):
"""Create and delete keystone ec2-credential."""
creds = self._create_ec2credentials(self.context["user"]["id"],
self.context["tenant"]["id"])
self._delete_ec2credential(self.context["user"]["id"], creds.access)

View File

@ -218,3 +218,33 @@ class KeystoneScenario(base.Scenario):
"""
self.admin_clients("keystone").users.update_password(user_id,
password)
@base.atomic_action_timer("keystone.create_ec2creds")
def _create_ec2credentials(self, user_id, tenant_id):
"""Create ec2credentials.
:param user_id: User ID for which to create credentials
:param tenant_id: Tenant ID for which to create credentials
:returns: Created ec2-credentials object
"""
return self.clients("keystone").ec2.create(user_id, tenant_id)
@base.atomic_action_timer("keystone.list_ec2creds")
def _list_ec2credentials(self, user_id):
"""List of access/secret pairs for a user_id.
:param user_id: List all ec2-credentials for User ID
:returns: Return ec2-credentials list
"""
return self.clients("keystone").ec2.list(user_id)
@base.atomic_action_timer("keystone.delete_ec2creds")
def _delete_ec2credential(self, user_id, access):
"""Delete ec2credential.
:param user_id: User ID for which to delete credential
:param access: access key for ec2credential to delete
"""
self.clients("keystone").ec2.delete(user_id, access)

View File

@ -0,0 +1,17 @@
{
"KeystoneBasic.create_and_delete_ec2credential": [
{
"runner": {
"type": "constant",
"times": 10,
"concurrency": 5
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}

View File

@ -0,0 +1,12 @@
---
KeystoneBasic.create_and_delete_ec2credential:
-
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2

View File

@ -0,0 +1,17 @@
{
"KeystoneBasic.create_and_list_ec2credentials": [
{
"runner": {
"type": "constant",
"times": 10,
"concurrency": 5
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}

View File

@ -0,0 +1,12 @@
---
KeystoneBasic.create_and_list_ec2credentials:
-
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2

View File

@ -27,8 +27,8 @@ class KeystoneBasicTestCase(test.TestCase):
@staticmethod
def _get_context():
return {
"user": {"id": "fake"},
"tenant": {"id": "fake"}
"user": {"id": "fake_user_id"},
"tenant": {"id": "fake_tenant_id"}
}
@mock.patch("rally.common.utils.generate_random_name")
@ -248,3 +248,26 @@ class KeystoneBasicTestCase(test.TestCase):
service_type,
description)
scenario._list_services.assert_called_once_with()
def test_create_and_list_ec2credentials(self):
context = self._get_context()
scenario = basic.KeystoneBasic(context)
scenario._create_ec2credentials = mock.MagicMock()
scenario._list_ec2credentials = mock.MagicMock()
scenario.create_and_list_ec2credentials()
scenario._create_ec2credentials.assert_called_once_with(
"fake_user_id", "fake_tenant_id")
scenario._list_ec2credentials.assert_called_with("fake_user_id")
def test_create_and_delete_ec2credential(self):
fake_creds = mock.MagicMock()
context = self._get_context()
scenario = basic.KeystoneBasic(context)
scenario._create_ec2credentials = mock.MagicMock(
return_value=fake_creds)
scenario._delete_ec2credential = mock.MagicMock()
scenario.create_and_delete_ec2credential()
scenario._create_ec2credentials.assert_called_once_with(
"fake_user_id", "fake_tenant_id")
scenario._delete_ec2credential.assert_called_once_with(
"fake_user_id", fake_creds.access)

View File

@ -278,3 +278,37 @@ class KeystoneScenarioTestCase(test.ClientsTestCase):
scenario._list_services = mock.Mock(return_value=[svc_foo, svc_bar])
self.assertEqual(scenario._get_service_by_name(svc_bar.name), svc_bar)
self.assertIsNone(scenario._get_service_by_name("spam"))
@mock.patch(UTILS + "KeystoneScenario.clients")
def test_create_ec2credentials(self, mock_clients):
scenario = utils.KeystoneScenario()
creds = mock.Mock()
mock_clients("keystone").ec2.create.return_value = creds
create_creds = scenario._create_ec2credentials("user_id",
"tenant_id")
self.assertEqual(create_creds, creds)
mock_clients("keystone").ec2.create.assert_called_once_with(
"user_id", "tenant_id")
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.create_ec2creds")
@mock.patch(UTILS + "KeystoneScenario.clients")
def test_list_ec2credentials(self, mock_clients):
scenario = utils.KeystoneScenario()
creds_list = mock.Mock()
mock_clients("keystone").ec2.list.return_value = creds_list
list_creds = scenario._list_ec2credentials("user_id")
self.assertEqual(list_creds, creds_list)
mock_clients("keystone").ec2.list.assert_called_once_with("user_id")
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.list_ec2creds")
@mock.patch(UTILS + "KeystoneScenario.clients")
def test_delete_ec2credentials(self, mock_clients):
scenario = utils.KeystoneScenario()
mock_clients("keystone").ec2.delete = mock.MagicMock()
scenario._delete_ec2credential("user_id", "access")
mock_clients("keystone").ec2.delete.assert_called_once_with("user_id",
"access")
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.delete_ec2creds")