Add read-only functional tests
Add more read-only functional tests. It allows us to use only manilaclient's own functional tests and CLI tests from Manila Tempest plugin are not required anymore. Partially implements bp functional-tests Change-Id: I6ff3fb79740b958581c2536bac353935d53c9bae
This commit is contained in:
parent
6773889fd6
commit
b2e554d2d4
63
manilaclient/tests/functional/test_common.py
Normal file
63
manilaclient/tests/functional/test_common.py
Normal file
@ -0,0 +1,63 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
import ddt
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestCommonReadOnly(base.BaseTestCase):
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_manila_version(self, role):
|
||||
self.clients[role].manila('', flags='--version')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_help(self, role):
|
||||
help_text = self.clients[role].manila('help')
|
||||
lines = help_text.split('\n')
|
||||
self.assertFirstLineStartsWith(lines, 'usage: manila')
|
||||
|
||||
commands = []
|
||||
cmds_start = lines.index('Positional arguments:')
|
||||
cmds_end = lines.index('Optional arguments:')
|
||||
command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')
|
||||
for line in lines[cmds_start:cmds_end]:
|
||||
match = command_pattern.match(line)
|
||||
if match:
|
||||
commands.append(match.group(1))
|
||||
commands = set(commands)
|
||||
wanted_commands = set((
|
||||
'absolute-limits', 'list', 'help', 'quota-show', 'access-list',
|
||||
'snapshot-list', 'access-allow', 'access-deny',
|
||||
'share-network-list', 'security-service-list'))
|
||||
self.assertFalse(wanted_commands - commands)
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_credentials(self, role):
|
||||
self.clients[role].manila('credentials')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_list_extensions(self, role):
|
||||
roles = self.parser.listing(
|
||||
self.clients[role].manila('list-extensions'))
|
||||
self.assertTableStruct(roles, ['Name', 'Summary', 'Alias', 'Updated'])
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_endpoints(self, role):
|
||||
self.clients[role].manila('endpoints')
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2014 Mirantis Inc.
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -13,15 +13,18 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
class ManilaClientTestList(base.BaseTestCase):
|
||||
@ddt.ddt
|
||||
class ManilaClientTestLimitsReadOnly(base.BaseTestCase):
|
||||
|
||||
# TODO(vponomaryov): add more tests
|
||||
@ddt.data('admin', 'user')
|
||||
def test_rate_limits(self, role):
|
||||
self.clients[role].manila('rate-limits')
|
||||
|
||||
def test_manila_list_by_admin(self):
|
||||
self.clients['admin'].manila('list')
|
||||
|
||||
def test_manila_list_by_user(self):
|
||||
self.clients['user'].manila('list')
|
||||
@ddt.data('admin', 'user')
|
||||
def test_absolute_limits(self, role):
|
||||
self.clients[role].manila('absolute-limits')
|
46
manilaclient/tests/functional/test_quotas.py
Normal file
46
manilaclient/tests/functional/test_quotas.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
from tempest_lib import exceptions
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestQuotasReadOnly(base.BaseTestCase):
|
||||
|
||||
def test_quota_class_show_by_admin(self):
|
||||
roles = self.parser.listing(
|
||||
self.clients['admin'].manila('quota-class-show', params='abc'))
|
||||
self.assertTableStruct(roles, ['Property', 'Value'])
|
||||
|
||||
def test_quota_class_show_by_user(self):
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.clients['user'].manila,
|
||||
'quota-class-show',
|
||||
params='abc')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_quota_defaults(self, role):
|
||||
roles = self.parser.listing(
|
||||
self.clients[role].manila('quota-defaults'))
|
||||
self.assertTableStruct(roles, ['Property', 'Value'])
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_quota_show(self, role):
|
||||
roles = self.parser.listing(self.clients[role].manila('quota-show'))
|
||||
self.assertTableStruct(roles, ['Property', 'Value'])
|
43
manilaclient/tests/functional/test_services.py
Normal file
43
manilaclient/tests/functional/test_services.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestServicesReadOnly(base.BaseTestCase):
|
||||
|
||||
def test_services_list(self):
|
||||
self.clients['admin'].manila('service-list')
|
||||
|
||||
def test_list_with_debug_flag(self):
|
||||
self.clients['admin'].manila('service-list', flags='--debug')
|
||||
|
||||
def test_shares_list_filter_by_host(self):
|
||||
self.clients['admin'].manila('service-list', params='--host host')
|
||||
|
||||
def test_shares_list_filter_by_binary(self):
|
||||
self.clients['admin'].manila('service-list', params='--binary binary')
|
||||
|
||||
def test_shares_list_filter_by_zone(self):
|
||||
self.clients['admin'].manila('service-list', params='--zone zone')
|
||||
|
||||
def test_shares_list_filter_by_status(self):
|
||||
self.clients['admin'].manila('service-list', params='--status status')
|
||||
|
||||
def test_shares_list_filter_by_state(self):
|
||||
self.clients['admin'].manila('service-list', params='--state state')
|
47
manilaclient/tests/functional/test_share_servers.py
Normal file
47
manilaclient/tests/functional/test_share_servers.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
from tempest_lib import exceptions
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestShareServersReadOnly(base.BaseTestCase):
|
||||
|
||||
def test_share_server_list(self):
|
||||
self.clients['admin'].manila('share-server-list')
|
||||
|
||||
def test_share_server_list_with_host_param(self):
|
||||
self.clients['admin'].manila('share-server-list', params='--host host')
|
||||
|
||||
def test_share_server_list_with_status_param(self):
|
||||
self.clients['admin'].manila(
|
||||
'share-server-list', params='--status status')
|
||||
|
||||
def test_share_server_list_with_share_network_param(self):
|
||||
self.clients['admin'].manila(
|
||||
'share-server-list', params='--share-network share-network')
|
||||
|
||||
def test_share_server_list_with_project_id_param(self):
|
||||
self.clients['admin'].manila(
|
||||
'share-server-list', params='--project-id project-id')
|
||||
|
||||
def test_share_server_list_by_user(self):
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.clients['user'].manila,
|
||||
'share-server-list')
|
90
manilaclient/tests/functional/test_shares.py
Normal file
90
manilaclient/tests/functional/test_shares.py
Normal file
@ -0,0 +1,90 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
from tempest_lib import exceptions
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestSharesReadOnly(base.BaseTestCase):
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list(self, role):
|
||||
self.clients[role].manila('list')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_list_with_debug_flag(self, role):
|
||||
self.clients[role].manila('list', flags='--debug')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_all_tenants(self, role):
|
||||
self.clients[role].manila('list', params='--all-tenants')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_filter_by_name(self, role):
|
||||
self.clients[role].manila('list', params='--name name')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_filter_by_status(self, role):
|
||||
self.clients[role].manila('list', params='--status status')
|
||||
|
||||
def test_shares_list_filter_by_share_server_as_admin(self):
|
||||
self.clients['admin'].manila('list', params='--share-server fake')
|
||||
|
||||
def test_shares_list_filter_by_share_server_as_user(self):
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.clients['user'].manila,
|
||||
'this-does-not-exist')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_filter_by_project_id(self, role):
|
||||
self.clients[role].manila('list', params='--project-id fake')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_filter_by_host(self, role):
|
||||
self.clients[role].manila('list', params='--host fake')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_shares_list_with_limit_and_offset(self, role):
|
||||
self.clients[role].manila('list', params='--limit 1 --offset 1')
|
||||
|
||||
@ddt.data(
|
||||
{'role': 'admin', 'direction': 'asc'},
|
||||
{'role': 'admin', 'direction': 'desc'},
|
||||
{'role': 'user', 'direction': 'asc'},
|
||||
{'role': 'user', 'direction': 'desc'})
|
||||
@ddt.unpack
|
||||
def test_shares_list_with_sorting(self, role, direction):
|
||||
self.clients[role].manila(
|
||||
'list', params='--sort-key host --sort-dir ' + direction)
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_snapshot_list(self, role):
|
||||
self.clients[role].manila('snapshot-list')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_snapshot_list_all_tenants(self, role):
|
||||
self.clients[role].manila('snapshot-list', params='--all-tenants')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_snapshot_list_filter_by_name(self, role):
|
||||
self.clients[role].manila('snapshot-list', params='--name name')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_snapshot_list_filter_by_status(self, role):
|
||||
self.clients[role].manila('snapshot-list', params='--status status')
|
30
manilaclient/tests/functional/test_volume_types.py
Normal file
30
manilaclient/tests/functional/test_volume_types.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
|
||||
from manilaclient.tests.functional import base
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaClientTestVolumeTypesReadOnly(base.BaseTestCase):
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_volume_type_list(self, role):
|
||||
self.clients[role].manila('type-list')
|
||||
|
||||
@ddt.data('admin', 'user')
|
||||
def test_extra_specs_list(self, role):
|
||||
self.clients[role].manila('extra-specs-list')
|
@ -6,6 +6,7 @@
|
||||
hacking>=0.9.2,<0.10
|
||||
|
||||
coverage>=3.6
|
||||
ddt>=0.4.0
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user