Fix the exact filter can be filter by inexact value
Fix the ``exact`` filters (name, description) in ``shares``,
``snapshots``, ``share-networks`` list can be filter by ``inexact``
value.
Change-Id: I51e6b754f37a09c09a60e9a7fb51d3c9721f2d1f
Closes-bug: #1704971
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index e12990e..cf179bf 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -338,7 +338,15 @@
@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):
+ def test_list_shares_with_detail_filter_by_existed_description(self):
+ # list shares by description, at least one share is expected
+ params = {"description": self.share_desc}
+ shares = self.shares_v2_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_inexact_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)
@@ -563,6 +571,22 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @base.skip_if_microversion_not_supported("2.35")
+ def test_list_snapshots_with_detail_filter_by_description(self):
+ filters = {'description': self.snap_desc}
+
+ # list snapshots
+ snaps = self.shares_client.list_snapshots_with_detail(
+ params=filters)
+
+ # verify response
+ self.assertGreater(len(snaps), 0)
+ for snap in snaps:
+ self.assertEqual(filters['description'], snap['description'])
+
+ @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+ @testtools.skipUnless(CONF.share.run_snapshot_tests,
+ "Snapshot tests are disabled.")
def test_list_snapshots_with_detail_and_asc_sorting(self):
filters = {'sort_key': 'share_id', 'sort_dir': 'asc'}
diff --git a/manila_tempest_tests/tests/api/test_shares_actions_negative.py b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
index 1f3da5f..6d1fa6c 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
@@ -15,6 +15,7 @@
import ddt
from tempest import config
+from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
import testtools
from testtools import testcase as tc
@@ -30,7 +31,18 @@
def resource_setup(cls):
super(SharesActionsNegativeTest, cls).resource_setup()
cls.admin_client = cls.admin_shares_v2_client
- cls.share = cls.create_share()
+ cls.share_name = data_utils.rand_name("tempest-share-name")
+ cls.share_desc = data_utils.rand_name("tempest-share-description")
+ cls.share = cls.create_share(
+ name=cls.share_name,
+ description=cls.share_desc)
+ if CONF.share.run_snapshot_tests:
+ # create snapshot
+ cls.snap_name = data_utils.rand_name("tempest-snapshot-name")
+ cls.snap_desc = data_utils.rand_name(
+ "tempest-snapshot-description")
+ cls.snap = cls.create_snapshot_wait_for_active(
+ cls.share["id"], cls.snap_name, cls.snap_desc)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
@testtools.skipUnless(
@@ -167,7 +179,7 @@
self.assertEqual(0, len(shares))
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
- @base.skip_if_microversion_not_supported("2.35")
+ @base.skip_if_microversion_not_supported("2.36")
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
@@ -182,7 +194,7 @@
self.assertGreater(len(shares), 0)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
- @base.skip_if_microversion_not_supported("2.35")
+ @base.skip_if_microversion_not_supported("2.36")
def test_list_shares_with_like_filter_not_exist(self):
filters = {
'name~': 'fake_not_exist',
@@ -191,3 +203,43 @@
shares = self.shares_v2_client.list_shares(params=filters)
self.assertEqual(0, len(shares))
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ def test_list_shares_with_name_not_exist(self):
+ filters = {
+ 'name': "tempest-share",
+ }
+ shares = self.shares_v2_client.list_shares(params=filters)
+
+ self.assertEqual(0, len(shares))
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ @base.skip_if_microversion_not_supported("2.36")
+ def test_list_shares_with_description_not_exist(self):
+ filters = {
+ 'description': "tempest-share",
+ }
+ shares = self.shares_v2_client.list_shares(params=filters)
+
+ self.assertEqual(0, len(shares))
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ @base.skip_if_microversion_not_supported("2.36")
+ def test_list_snapshots_with_description_not_exist(self):
+ filters = {
+ 'description': "tempest-snapshot",
+ }
+ shares = self.shares_v2_client.list_snapshots_with_detail(
+ params=filters)
+
+ self.assertEqual(0, len(shares))
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ def test_list_snapshots_with_name_not_exist(self):
+ filters = {
+ 'name': "tempest-snapshot",
+ }
+ shares = self.shares_v2_client.list_snapshots_with_detail(
+ params=filters)
+
+ self.assertEqual(0, len(shares))