diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py index e12990e3..cf179bf3 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 @@ class SharesActionsTest(base.BaseSharesTest): @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) @@ -560,6 +568,22 @@ class SharesActionsTest(base.BaseSharesTest): self.assertEqual(filters['status'], snap['status']) self.assertEqual(filters['name'], snap['name']) + @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.") 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 1f3da5fe..6d1fa6c8 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 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest): 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 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest): 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 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest): 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 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest): 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))