Adds Designate server tests
This submission adds three methods to rally/benchmark/scenarios/designate/basic.py 1) def create_and_list_servers 2) def list_servers 3) def create_and_delete_servers Also, Adds methods to "utils.py" under "rally/benchmark/scenarios/designate" 1) def _create_server 2) def _list_servers 3) def _delete_server Added configuration files for server operations under samples/tasks/scenarios/designate 1) create-and-delete-servers.json 2) create-and-delete-servers.yaml 3) create-and-list-servers.json 4) create-and-list-servers.yaml Added unittests to test_utils.py, test_basic.py under tests/unit/benchmark/scenarios/designate Change-Id: I802b40b87aa064ac138b97395e3e56da40f33d74
This commit is contained in:
parent
11cc77b406
commit
f18816d474
@ -72,3 +72,31 @@
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
DesignateBasic.create_and_list_servers:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
DesignateBasic.create_and_delete_server:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
@ -270,11 +270,20 @@ class ZaqarQueues(SynchronizedDeletion, base.ResourceManager):
|
||||
|
||||
# DESIGNATE
|
||||
|
||||
@base.resource("designate", "domains", order=900)
|
||||
_designate_order = get_order(900)
|
||||
|
||||
|
||||
@base.resource("designate", "domains", order=next(_designate_order))
|
||||
class Designate(SynchronizedDeletion, base.ResourceManager):
|
||||
pass
|
||||
|
||||
|
||||
@base.resource("designate", "servers", order=next(_designate_order),
|
||||
admin_required=True, perform_for_admin_only=True)
|
||||
class DesignateServer(SynchronizedDeletion, base.ResourceManager):
|
||||
pass
|
||||
|
||||
|
||||
# KEYSTONE
|
||||
|
||||
_keystone_order = get_order(9000)
|
||||
|
@ -135,3 +135,30 @@ class DesignateBasic(utils.DesignateScenario):
|
||||
self._create_record(domain, atomic_action=False)
|
||||
|
||||
self._list_records(domain["id"])
|
||||
|
||||
@validation.required_services(consts.Service.DESIGNATE)
|
||||
@validation.required_openstack(admin=True)
|
||||
@base.scenario(context={"cleanup": ["designate"]})
|
||||
def create_and_list_servers(self):
|
||||
"""Create a Designate server and list all servers.
|
||||
|
||||
If you have only 1 user in your context, you will
|
||||
add 1 server on every iteration. So you will have more
|
||||
and more server and will be able to measure the
|
||||
performance of the "designate server-list" command depending on
|
||||
the number of servers owned by users.
|
||||
"""
|
||||
self._create_server()
|
||||
self._list_servers()
|
||||
|
||||
@validation.required_services(consts.Service.DESIGNATE)
|
||||
@validation.required_openstack(admin=True)
|
||||
@base.scenario(context={"cleanup": ["designate"]})
|
||||
def create_and_delete_server(self):
|
||||
"""Add and then delete a server.
|
||||
|
||||
Measure the performance of creating and deleting servers
|
||||
with different level of load.
|
||||
"""
|
||||
server = self._create_server()
|
||||
self._delete_server(server['id'])
|
||||
|
@ -95,3 +95,28 @@ class DesignateScenario(base.Scenario):
|
||||
client.records.create(domain_id, record_id)
|
||||
|
||||
client.records.delete(domain_id, record_id)
|
||||
|
||||
@base.atomic_action_timer("designate.create_server")
|
||||
def _create_server(self, server=None):
|
||||
"""Create server.
|
||||
|
||||
:param server: dict, POST /v1/servers request options
|
||||
:returns: designate server dict
|
||||
"""
|
||||
server = server or {}
|
||||
|
||||
server.setdefault("name", "name.%s." % self._generate_random_name())
|
||||
return self.admin_clients("designate").servers.create(server)
|
||||
|
||||
@base.atomic_action_timer("designate.list_servers")
|
||||
def _list_servers(self):
|
||||
"""Return user server list."""
|
||||
return self.admin_clients("designate").servers.list()
|
||||
|
||||
@base.atomic_action_timer("designate.delete_server")
|
||||
def _delete_server(self, server_id):
|
||||
"""Delete Server.
|
||||
|
||||
:param server_id: unicode server ID
|
||||
"""
|
||||
self.admin_clients("designate").servers.delete(server_id)
|
||||
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
"DesignateBasic.create_and_delete_server": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 1
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
DesignateBasic.create_and_delete_server:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
"DesignateBasic.create_and_list_servers": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 1
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
DesignateBasic.create_and_list_servers:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
@ -111,3 +111,26 @@ class DesignateBasicTestCase(test.TestCase):
|
||||
# Default options
|
||||
scenario.list_records("123")
|
||||
mock_list.assert_called_once_with("123")
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_servers")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_server")
|
||||
def test_create_and_list_servers(self, mock_create, mock_list):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_list_servers()
|
||||
mock_create.assert_called_once_with()
|
||||
mock_list.assert_called_once_with()
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._delete_server")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_server")
|
||||
def test_create_and_delete_server(self, mock_create, mock_delete):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
mock_create.return_value = {"id": "123"}
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_server()
|
||||
|
||||
mock_create.assert_called_once_with()
|
||||
mock_delete.assert_called_once_with("123")
|
||||
|
@ -28,6 +28,7 @@ class DesignateScenarioTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(DesignateScenarioTestCase, self).setUp()
|
||||
self.domain = mock.Mock()
|
||||
self.server = mock.Mock()
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario._generate_random_name")
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario.clients")
|
||||
@ -130,3 +131,40 @@ class DesignateScenarioTestCase(test.TestCase):
|
||||
scenario._delete_record(domain["id"], record["id"])
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"designate.delete_record")
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario._generate_random_name")
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario.admin_clients")
|
||||
def test_create_server(self, mock_clients, mock_random_name):
|
||||
scenario = utils.DesignateScenario()
|
||||
|
||||
random_name = "foo"
|
||||
explicit_name = "bar.io."
|
||||
|
||||
mock_random_name.return_value = random_name
|
||||
mock_clients("designate").servers.create.return_value = self.server
|
||||
|
||||
# Check that the defaults / randoms are used if nothing is specified
|
||||
server = scenario._create_server()
|
||||
mock_clients("designate").servers.create.assert_called_once_with(
|
||||
{"name": "name.%s." % random_name})
|
||||
self.assertEqual(self.server, server)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"designate.create_server")
|
||||
|
||||
mock_clients("designate").servers.create.reset_mock()
|
||||
|
||||
# Check that when specifying server name defaults are not used...
|
||||
data = {"name": explicit_name}
|
||||
server = scenario._create_server(data)
|
||||
mock_clients("designate").servers.create.assert_called_once_with(data)
|
||||
self.assertEqual(self.server, server)
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario.admin_clients")
|
||||
def test_delete_server(self, mock_clients):
|
||||
scenario = utils.DesignateScenario()
|
||||
|
||||
scenario._delete_server("foo_id")
|
||||
mock_clients("designate").servers.delete.assert_called_once_with(
|
||||
"foo_id")
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"designate.delete_server")
|
||||
|
Loading…
x
Reference in New Issue
Block a user