Add NovaServerGroups.create_and_get_server_group
Create a server group, then get its detailed information. Measure the "nova server-group-create" and "nova server-group-get" command performance. Change-Id: I865fda72b88af017caba96be1b11183d7ca804e9
This commit is contained in:
parent
3ace05f34a
commit
00a5b34787
@ -181,6 +181,25 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServerGroups.create_and_get_server_group:
|
||||
{% for s in (["affinity"], ["anti-affinity"]) %}
|
||||
-
|
||||
args:
|
||||
kwargs:
|
||||
policies: {{s}}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
{% endfor %}
|
||||
|
||||
NovaServerGroups.create_and_list_server_groups:
|
||||
{% for s in (["affinity"], ["anti-affinity"]) %}
|
||||
-
|
||||
|
@ -53,3 +53,26 @@ class CreateAndListServerGroups(utils.NovaScenario):
|
||||
"list of server groups: {}").format(server_group,
|
||||
server_groups_list)
|
||||
self.assertIn(server_group, server_groups_list, err_msg=msg)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaServerGroups.create_and_get_server_group")
|
||||
class CreateAndGetServerGroup(utils.NovaScenario):
|
||||
|
||||
def run(self, kwargs=None):
|
||||
"""Create a server group, then get its detailed information.
|
||||
|
||||
Measure the "nova server-group-create" and "nova server-group-get"
|
||||
command performance.
|
||||
|
||||
:param kwargs: Server group name and policy
|
||||
"""
|
||||
kwargs["name"] = self.generate_random_name()
|
||||
server_group = self._create_server_group(**kwargs)
|
||||
msg = ("Server Groups isn't created")
|
||||
self.assertTrue(server_group, err_msg=msg)
|
||||
|
||||
server_group_info = self._get_server_group(server_group.id)
|
||||
self.assertEqual(server_group.id, server_group_info.id)
|
||||
|
@ -466,6 +466,16 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.clients("nova").server_groups.create(**kwargs)
|
||||
|
||||
@atomic.action_timer("nova.get_server_group")
|
||||
def _get_server_group(self, id):
|
||||
"""Get a specific server group.
|
||||
|
||||
:param id: Unique ID of the server group to get
|
||||
|
||||
:rtype: :class:`ServerGroup`
|
||||
"""
|
||||
return self.clients("nova").server_groups.get(id)
|
||||
|
||||
@atomic.action_timer("nova.list_server_groups")
|
||||
def _list_server_groups(self, all_projects=False):
|
||||
"""Get a list of all server groups.
|
||||
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
"NovaServerGroups.create_and_get_server_group": [
|
||||
{
|
||||
"args": {
|
||||
"kwargs": {
|
||||
"policies": [
|
||||
"affinity"
|
||||
]
|
||||
}
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 4,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
NovaServerGroups.create_and_get_server_group:
|
||||
-
|
||||
args:
|
||||
kwargs:
|
||||
policies: ["affinity"]
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -60,3 +60,61 @@ class NovaServerGroupsTestCase(test.ScenarioTestCase):
|
||||
kwargs=create_args)
|
||||
scenario._create_server_group.assert_called_with(**create_args)
|
||||
scenario._list_server_groups.assert_called_with(all_projects)
|
||||
|
||||
@ddt.data(
|
||||
{},
|
||||
{"create_args": {"policies": ["fake_policy"]}}
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_create_and_get_server_group_positive(self, create_args=None):
|
||||
scenario = server_groups.CreateAndGetServerGroup(self.context)
|
||||
gen_name = mock.MagicMock()
|
||||
scenario.generate_random_name = gen_name
|
||||
fake_server_group = mock.MagicMock()
|
||||
fake_server_group_info = mock.MagicMock()
|
||||
fake_server_group.id = 123
|
||||
fake_server_group_info.id = 123
|
||||
scenario._create_server_group = mock.MagicMock()
|
||||
scenario._get_server_group = mock.MagicMock()
|
||||
create_args = create_args or {}
|
||||
# Positive case
|
||||
scenario._create_server_group.return_value = fake_server_group
|
||||
scenario._get_server_group.return_value = fake_server_group_info
|
||||
scenario.run(create_args)
|
||||
scenario._create_server_group.assert_called_once_with(**create_args)
|
||||
scenario._get_server_group.assert_called_once_with(
|
||||
fake_server_group.id)
|
||||
|
||||
@ddt.data(
|
||||
{},
|
||||
{"create_args": {"policies": ["fake_policy"]}}
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_create_and_get_server_group_negative(self, create_args=None):
|
||||
scenario = server_groups.CreateAndGetServerGroup(self.context)
|
||||
gen_name = mock.MagicMock()
|
||||
scenario.generate_random_name = gen_name
|
||||
fake_server_group = mock.MagicMock()
|
||||
fake_server_group_info = mock.MagicMock()
|
||||
fake_server_group.id = 123
|
||||
fake_server_group_info.id = 123
|
||||
scenario._create_server_group = mock.MagicMock()
|
||||
scenario._get_server_group = mock.MagicMock()
|
||||
create_args = create_args or {}
|
||||
|
||||
# Negative case1: server group isn't created
|
||||
scenario._create_server_group.return_value = None
|
||||
self.assertRaises(rally_exceptions.RallyAssertionError,
|
||||
scenario.run,
|
||||
create_args)
|
||||
scenario._create_server_group.assert_called_with(**create_args)
|
||||
|
||||
# Negative case2: server group to get information not the created one
|
||||
fake_server_group_info.id = 456
|
||||
scenario._create_server_group.return_value = fake_server_group
|
||||
self.assertRaises(rally_exceptions.RallyAssertionError,
|
||||
scenario.run,
|
||||
create_args)
|
||||
scenario._create_server_group.assert_called_with(**create_args)
|
||||
scenario._get_server_group.assert_called_with(
|
||||
fake_server_group.id)
|
||||
|
@ -806,6 +806,18 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.create_keypair")
|
||||
|
||||
def test__get_server_group(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
fakeid = 12345
|
||||
result = nova_scenario._get_server_group(fakeid)
|
||||
self.assertEqual(
|
||||
self.clients("nova").server_groups.get.return_value,
|
||||
result)
|
||||
self.clients("nova").server_groups.get.assert_called_once_with(
|
||||
fakeid)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.get_server_group")
|
||||
|
||||
def test__create_server_group(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
result = nova_scenario._create_server_group(fakeargs="fakeargs")
|
||||
|
Loading…
Reference in New Issue
Block a user