Merge "Add like filter"
This commit is contained in:
commit
a7526f7104
|
@ -30,7 +30,7 @@ ShareGroup = [
|
|||
help="The minimum api microversion is configured to be the "
|
||||
"value of the minimum microversion supported by Manila."),
|
||||
cfg.StrOpt("max_api_microversion",
|
||||
default="2.35",
|
||||
default="2.36",
|
||||
help="The maximum api microversion is configured to be the "
|
||||
"value of the latest microversion supported by Manila."),
|
||||
cfg.StrOpt("region",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
import testtools
|
||||
|
@ -21,6 +22,7 @@ from testtools import testcase as tc
|
|||
|
||||
from manila_tempest_tests.common import constants
|
||||
from manila_tempest_tests.tests.api import base
|
||||
from manila_tempest_tests import utils
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
@ -28,6 +30,7 @@ CONF = config.CONF
|
|||
@testtools.skipUnless(
|
||||
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
|
||||
@base.skip_if_microversion_lt(constants.MIN_SHARE_GROUP_MICROVERSION)
|
||||
@ddt.ddt
|
||||
class ShareGroupActionsTest(base.BaseSharesTest):
|
||||
"""Covers share group functionality."""
|
||||
|
||||
|
@ -157,11 +160,14 @@ class ShareGroupActionsTest(base.BaseSharesTest):
|
|||
self.assertEqual(1, len(gen), msg)
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
def test_list_share_groups_with_detail_min(self):
|
||||
|
||||
@ddt.data(constants.MIN_SHARE_GROUP_MICROVERSION, '2.36')
|
||||
def test_list_share_groups_with_detail_min(self, version):
|
||||
params = None
|
||||
if utils.is_microversion_ge(version, '2.36'):
|
||||
params = {'name~': 'tempest', 'description~': 'tempest'}
|
||||
# List share groups
|
||||
share_groups = self.shares_v2_client.list_share_groups(
|
||||
detailed=True, version=constants.MIN_SHARE_GROUP_MICROVERSION)
|
||||
detailed=True, params=params, version=version)
|
||||
|
||||
# Verify keys
|
||||
for sg in share_groups:
|
||||
|
|
|
@ -70,6 +70,22 @@ class ShareNetworkListMixin(object):
|
|||
self.assertTrue(any(ss['id'] == self.ss_ldap['id']
|
||||
for ss in ss_list))
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
|
||||
@base.skip_if_microversion_lt("2.36")
|
||||
def test_list_share_networks_like_filter(self):
|
||||
valid_filter_opts = {
|
||||
'name': 'sn_with_ldap_ss',
|
||||
'description': 'fake',
|
||||
}
|
||||
|
||||
listed = self.shares_v2_client.list_share_networks_with_detail(
|
||||
{'name~': 'ldap_ss', 'description~': 'fa'})
|
||||
self.assertTrue(any(self.sn_with_ldap_ss['id'] == sn['id']
|
||||
for sn in listed))
|
||||
for sn in listed:
|
||||
self.assertTrue(all(value in sn[key] for key, value in
|
||||
valid_filter_opts.items()))
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
|
||||
def test_list_share_networks_all_filter_opts(self):
|
||||
valid_filter_opts = {
|
||||
|
|
|
@ -128,3 +128,16 @@ class ShareNetworksNegativeTest(base.BaseSharesTest):
|
|||
self.assertRaises(
|
||||
lib_exc.Conflict,
|
||||
self.shares_client.delete_share_network, new_sn['id'])
|
||||
|
||||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
|
||||
@base.skip_if_microversion_not_supported("2.35")
|
||||
def test_list_shares_with_like_filter_not_exist(self):
|
||||
filters = {
|
||||
'name~': 'fake_not_exist',
|
||||
'description~': 'fake_not_exist',
|
||||
}
|
||||
share_networks = (
|
||||
self.shares_v2_client.list_share_networks_with_detail(
|
||||
params=filters))
|
||||
|
||||
self.assertEqual(0, len(share_networks))
|
||||
|
|
|
@ -336,6 +336,15 @@ class SharesActionsTest(base.BaseSharesTest):
|
|||
shares = self.shares_client.list_shares_with_detail(params)
|
||||
self.assertEqual(self.share_name, shares[0]["name"])
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
@base.skip_if_microversion_lt("2.36")
|
||||
def test_list_shares_with_detail_filter_by_nonexistent_name(self):
|
||||
# list shares by name, at least one share is expected
|
||||
params = {"name~": 'tempest-share'}
|
||||
shares = self.shares_v2_client.list_shares_with_detail(params)
|
||||
for share in shares:
|
||||
self.assertIn('tempest-share', share["name"])
|
||||
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
def test_list_shares_with_detail_filter_by_fake_name(self):
|
||||
# list shares by fake name, no shares are expected
|
||||
|
@ -481,16 +490,18 @@ class SharesActionsTest(base.BaseSharesTest):
|
|||
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
||||
@testtools.skipUnless(CONF.share.run_snapshot_tests,
|
||||
"Snapshot tests are disabled.")
|
||||
@ddt.data(None, '2.16', LATEST_MICROVERSION)
|
||||
@ddt.data(None, '2.16', '2.36', LATEST_MICROVERSION)
|
||||
def test_list_snapshots_with_detail(self, version):
|
||||
|
||||
params = None
|
||||
if version and utils.is_microversion_ge(version, '2.36'):
|
||||
params = {'name~': 'tempest', 'description~': 'tempest'}
|
||||
# list share snapshots
|
||||
if version is None:
|
||||
snaps = self.shares_client.list_snapshots_with_detail()
|
||||
else:
|
||||
utils.skip_if_microversion_not_supported(version)
|
||||
snaps = self.shares_v2_client.list_snapshots_with_detail(
|
||||
version=version)
|
||||
version=version, params=params)
|
||||
|
||||
# verify keys
|
||||
expected_keys = ["status", "links", "share_id", "name",
|
||||
|
|
|
@ -165,3 +165,29 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
|
|||
params=filters)
|
||||
|
||||
self.assertEqual(0, len(shares))
|
||||
|
||||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
|
||||
@base.skip_if_microversion_not_supported("2.35")
|
||||
def test_list_shares_with_like_filter_and_invalid_version(self):
|
||||
# In API versions < v2.36, querying the share API by inexact
|
||||
# filter (name or description) should have no effect. Those
|
||||
# filters were supported from v2.36
|
||||
filters = {
|
||||
'name~': 'fake',
|
||||
'description~': 'fake',
|
||||
}
|
||||
shares = self.shares_v2_client.list_shares(
|
||||
params=filters, version="2.35")
|
||||
|
||||
self.assertGreater(len(shares), 0)
|
||||
|
||||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
|
||||
@base.skip_if_microversion_not_supported("2.35")
|
||||
def test_list_shares_with_like_filter_not_exist(self):
|
||||
filters = {
|
||||
'name~': 'fake_not_exist',
|
||||
'description~': 'fake_not_exist',
|
||||
}
|
||||
shares = self.shares_v2_client.list_shares(params=filters)
|
||||
|
||||
self.assertEqual(0, len(shares))
|
||||
|
|
Loading…
Reference in New Issue