[Manila] Add scenario for creation and listing of Manila share networks

List of changes:
- Added support of 'list'  operation for share networks.
- Added benchmark for creating and listing share networks.

Change-Id: Ib62f3291d685a4392e26fdf55e2edac09bb3f73c
This commit is contained in:
Valeriy Ponomaryov 2015-06-11 20:41:45 +03:00
parent 8bb636cf69
commit 94eb770cac
7 changed files with 174 additions and 0 deletions

View File

@ -51,3 +51,25 @@
sla:
failure_rate:
max: 0
ManilaShares.create_share_network_and_list:
-
args:
name: "rally"
detailed: True
search_opts:
name: "rally"
runner:
type: "constant"
times: 10
concurrency: 10
context:
quotas:
manila:
share_networks: -1
users:
tenants: 2
users_per_tenant: 1
sla:
failure_rate:
max: 0

View File

@ -86,3 +86,38 @@ class ManilaShares(utils.ManilaScenario):
description=description,
)
self._delete_share_network(share_network)
@validation.required_services(consts.Service.MANILA)
@validation.required_openstack(users=True)
@base.scenario(context={"cleanup": ["manila"]})
def create_share_network_and_list(self,
neutron_net_id=None,
neutron_subnet_id=None,
nova_net_id=None,
name=None,
description=None,
detailed=True,
search_opts=None):
"""Creates share network and then lists it.
:param neutron_net_id: ID of Neutron network
:param neutron_subnet_id: ID of Neutron subnet
:param nova_net_id: ID of Nova network
:param name: share network name
:param description: share network description
:param detailed: defines either to return detailed list of
objects or not.
:param search_opts: container of search opts such as
"name", "nova_net_id", "neutron_net_id", etc.
"""
self._create_share_network(
neutron_net_id=neutron_net_id,
neutron_subnet_id=neutron_subnet_id,
nova_net_id=nova_net_id,
name=name,
description=description,
)
self._list_share_networks(
detailed=detailed,
search_opts=search_opts,
)

View File

@ -146,3 +146,17 @@ class ManilaScenario(base.Scenario):
update_resource=bench_utils.get_from_manager(),
timeout=CONF.benchmark.manila_share_delete_timeout,
check_interval=CONF.benchmark.manila_share_delete_poll_interval)
@base.atomic_action_timer("manila.list_share_networks")
def _list_share_networks(self, detailed=True, search_opts=None):
"""List share networks.
:param detailed: defines either to return detailed list of
objects or not.
:param search_opts: container of search opts such as
"project_id" and "name".
:returns: list of instances of :class:`ShareNetwork`
"""
share_networks = self.clients("manila").share_networks.list(
detailed=detailed, search_opts=search_opts)
return share_networks

View File

@ -0,0 +1,29 @@
{
"ManilaShares.create_share_network_and_list": [
{
"args": {
"name": "rally",
"detailed": true,
"search_opts": {
"name": "rally"
}
},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 10
},
"context": {
"quotas": {
"manila": {
"share_networks": -1
}
},
"users": {
"tenants": 2,
"users_per_tenant": 1
}
}
}
]
}

View File

@ -0,0 +1,19 @@
---
ManilaShares.create_share_network_and_list:
-
args:
name: "rally"
detailed: True
search_opts:
name: "rally"
runner:
type: "constant"
times: 10
concurrency: 10
context:
quotas:
manila:
share_networks: -1
users:
tenants: 2
users_per_tenant: 1

View File

@ -95,3 +95,40 @@ class ManilaSharesTestCase(test.TestCase):
scenario._create_share_network.assert_called_once_with(
**expected_params)
scenario._delete_share_network.assert_called_once_with(fake_sn)
@ddt.data(
{},
{"name": "foo_name"},
{"description": "foo_description"},
{"neutron_net_id": "foo_neutron_net_id"},
{"neutron_subnet_id": "foo_neutron_subnet_id"},
{"nova_net_id": "foo_nova_net_id"},
{"name": "foo_name",
"description": "foo_description",
"neutron_net_id": "foo_neutron_net_id",
"neutron_subnet_id": "foo_neutron_subnet_id",
"nova_net_id": "foo_nova_net_id"},
)
def test_create_share_network_and_list(self, params):
scenario = shares.ManilaShares()
scenario._create_share_network = mock.MagicMock()
scenario._list_share_networks = mock.MagicMock()
expected_create_params = {
"name": params.get("name"),
"description": params.get("description"),
"neutron_net_id": params.get("neutron_net_id"),
"neutron_subnet_id": params.get("neutron_subnet_id"),
"nova_net_id": params.get("nova_net_id"),
}
expected_list_params = {
"detailed": params.get("detailed", True),
"search_opts": params.get("search_opts"),
}
expected_create_params.update(params)
scenario.create_share_network_and_list(**params)
scenario._create_share_network.assert_called_once_with(
**expected_create_params)
scenario._list_share_networks.assert_called_once_with(
**expected_list_params)

View File

@ -113,3 +113,21 @@ class ManilaScenarioTestCase(test.ClientsTestCase):
mock_get_from_manager.assert_called_once_with()
mock_wait_for_delete.assert_called_once_with(
fake_sn, update_resource=mock.ANY, timeout=180, check_interval=2)
@ddt.data(
{"detailed": True, "search_opts": {"name": "foo_sn"}},
{"detailed": False, "search_opts": None},
{},
{"search_opts": {"project_id": "fake_project"}},
)
def test__list_share_networks(self, params):
fake_share_networks = ["foo", "bar"]
self.clients("manila").share_networks.list.return_value = (
fake_share_networks)
result = self.scenario._list_share_networks(**params)
self.assertEqual(fake_share_networks, result)
self.clients("manila").share_networks.list.assert_called_once_with(
detailed=params.get("detailed", True),
search_opts=params.get("search_opts", None))