Browse Source

[Tempest] Stop using deprecated Tempest opts

Currently, Manila CI Tempest jobs use deprecated options of Tempest.
Recently, latest version of Tempest dropped them [1].
Manila CI jobs work ok, because they check out specific version of
Tempest. But it will work until first Devstack update for some one
more Tempest feature and then we will be forced to use latest Tempest
again. Switch to supported approach of setting up users in Tempest,
to avoid such sudden blockers.

[1] I8c24cd17f643083dde71ab2bd2a38417c54aeccb

Change-Id: I5b3ebab52ea1401f6f7a116d1260268eb10ebe0c
Closes-Bug: #1586129
changes/95/322895/20
Valeriy Ponomaryov 5 years ago
parent
commit
82a571c486
  1. 29
      contrib/ci/post_test_hook.sh
  2. 8
      contrib/ci/pre_test_hook.sh
  3. 45
      manila_tempest_tests/clients_share.py
  4. 69
      manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py
  5. 13
      manila_tempest_tests/tests/api/admin/test_export_locations.py
  6. 13
      manila_tempest_tests/tests/api/admin/test_export_locations_negative.py
  7. 7
      manila_tempest_tests/tests/api/admin/test_quotas.py
  8. 9
      manila_tempest_tests/tests/api/admin/test_quotas_negative.py
  9. 52
      manila_tempest_tests/tests/api/admin/test_replication.py
  10. 78
      manila_tempest_tests/tests/api/admin/test_replication_actions.py
  11. 25
      manila_tempest_tests/tests/api/admin/test_services_negative.py
  12. 38
      manila_tempest_tests/tests/api/admin/test_share_servers_negative.py
  13. 192
      manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py
  14. 60
      manila_tempest_tests/tests/api/admin/test_share_types_negative.py
  15. 123
      manila_tempest_tests/tests/api/base.py
  16. 9
      manila_tempest_tests/tests/api/test_replication.py
  17. 5
      manila_tempest_tests/tests/api/test_replication_negative.py
  18. 5
      manila_tempest_tests/tests/api/test_replication_snapshots.py
  19. 4
      manila_tempest_tests/tests/api/test_security_services.py
  20. 12
      manila_tempest_tests/tests/api/test_share_types_negative.py
  21. 18
      manila_tempest_tests/tests/api/test_shares_actions_negative.py
  22. 26
      manila_tempest_tests/tests/scenario/manager_share.py

29
contrib/ci/post_test_hook.sh

@ -23,7 +23,7 @@ sudo chmod -R o+rx $BASE/new/devstack/files
# Import devstack functions 'iniset', 'iniget' and 'trueorfalse'
source $BASE/new/devstack/functions
export TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf
export TEMPEST_CONFIG=${TEMPEST_CONFIG:-$BASE/new/tempest/etc/tempest.conf}
# === Handle script arguments ===
@ -120,13 +120,14 @@ if [[ "$MULTITENANCY_ENABLED" == "False" ]]; then
# threads to avoid errors for Cinder volume creations that appear
# because of lack of free space.
MANILA_TEMPEST_CONCURRENCY=${MANILA_TEMPEST_CONCURRENCY:-8}
iniset $TEMPEST_CONFIG auth create_isolated_networks False
fi
# let us control if we die or not
set +o errexit
cd $BASE/new/tempest
export MANILA_TEMPEST_CONCURRENCY=${MANILA_TEMPEST_CONCURRENCY:-20}
export MANILA_TEMPEST_CONCURRENCY=${MANILA_TEMPEST_CONCURRENCY:-6}
export MANILA_TESTS=${MANILA_TESTS:-'manila_tempest_tests.tests.api'}
if [[ "$TEST_TYPE" == "scenario" ]]; then
@ -143,6 +144,7 @@ elif [[ "$DRIVER" == "generic" ]]; then
# per job using 'generic' share driver.
iniset $TEMPEST_CONFIG share enable_protocols nfs
fi
MANILA_TESTS="(^manila_tempest_tests.tests.api)(?=.*\[.*\bbackend\b.*\])"
fi
if [[ "$DRIVER" == "lvm" ]]; then
@ -193,30 +195,13 @@ iniset $TEMPEST_CONFIG share run_manage_unmanage_tests $RUN_MANILA_MANAGE_TESTS
# Enable manage/unmanage snapshot tests
iniset $TEMPEST_CONFIG share run_manage_unmanage_snapshot_tests $RUN_MANILA_MANAGE_SNAPSHOT_TESTS
iniset $TEMPEST_CONFIG validation ip_version_for_ssh 4
iniset $TEMPEST_CONFIG validation network_for_ssh ${PRIVATE_NETWORK_NAME:-"private"}
# check if tempest plugin was installed correctly
echo 'import pkg_resources; print list(pkg_resources.iter_entry_points("tempest.test_plugins"))' | python
# Workaround for Tempest architectural changes
# See bugs:
# 1) https://bugs.launchpad.net/manila/+bug/1531049
# 2) https://bugs.launchpad.net/tempest/+bug/1524717
TEMPEST_CONFIG=${TEMPEST_CONFIG:-$TEMPEST_DIR/etc/tempest.conf}
ADMIN_TENANT_NAME=${ADMIN_TENANT_NAME:-"admin"}
ADMIN_DOMAIN_NAME=${ADMIN_DOMAIN_NAME:-"Default"}
ADMIN_PASSWORD=${ADMIN_PASSWORD:-"secretadmin"}
iniset $TEMPEST_CONFIG auth admin_username ${ADMIN_USERNAME:-"admin"}
iniset $TEMPEST_CONFIG auth admin_password $ADMIN_PASSWORD
iniset $TEMPEST_CONFIG auth admin_tenant_name $ADMIN_TENANT_NAME
iniset $TEMPEST_CONFIG auth admin_domain_name $ADMIN_DOMAIN_NAME
iniset $TEMPEST_CONFIG identity username ${TEMPEST_USERNAME:-"demo"}
iniset $TEMPEST_CONFIG identity password $ADMIN_PASSWORD
iniset $TEMPEST_CONFIG identity tenant_name ${TEMPEST_TENANT_NAME:-"demo"}
iniset $TEMPEST_CONFIG identity alt_username ${ALT_USERNAME:-"alt_demo"}
iniset $TEMPEST_CONFIG identity alt_password $ADMIN_PASSWORD
iniset $TEMPEST_CONFIG identity alt_tenant_name ${ALT_TENANT_NAME:-"alt_demo"}
iniset $TEMPEST_CONFIG validation ip_version_for_ssh 4
iniset $TEMPEST_CONFIG validation network_for_ssh ${PRIVATE_NETWORK_NAME:-"private"}
export OS_PROJECT_DOMAIN_NAME=$ADMIN_DOMAIN_NAME
export OS_USER_DOMAIN_NAME=$ADMIN_DOMAIN_NAME

8
contrib/ci/pre_test_hook.sh

@ -21,6 +21,7 @@
source $BASE/new/devstack/functions
localrc_path=$BASE/new/devstack/localrc
local_conf_path=$BASE/new/devstack/local.conf
echo "DEVSTACK_GATE_TEMPEST_ALLOW_TENANT_ISOLATION=1" >> $localrc_path
echo "API_RATE_LIMIT=False" >> $localrc_path
echo "TEMPEST_SERVICES+=,manila" >> $localrc_path
@ -68,6 +69,9 @@ MANILA_SERVICE_IMAGE_ENABLED=False
if [[ "$DRIVER" == "generic" ]]; then
MANILA_SERVICE_IMAGE_ENABLED=True
echo "SHARE_DRIVER=manila.share.drivers.generic.GenericShareDriver" >> $localrc_path
echo -e "[[post-config|${NOVA_CONF:-/etc/nova/nova.conf}]]\n[DEFAULT]\nquota_instances=30\n" >> $local_conf_path
echo -e "[[post-config|${NEUTRON_CONF:-/etc/neutron/neutron.conf}]]\n[DEFAULT]\nmax_fixed_ips_per_port=100\n" >> $local_conf_path
echo -e "[[post-config|${NEUTRON_CONF:-/etc/neutron/neutron.conf}]]\n[QUOTAS]\nquota_subnet=-1\n" >> $local_conf_path
elif [[ "$DRIVER" == "windows" ]]; then
MANILA_SERVICE_IMAGE_ENABLED=True
echo "SHARE_DRIVER=manila.share.drivers.windows.windows_smb_driver.WindowsSMBDriver" >> $localrc_path
@ -96,6 +100,10 @@ echo 'ENABLE_ISOLATED_METADATA=True' >> $localrc_path
cd $BASE/new/neutron-fwaas
git revert --no-edit a59df892d3f90f97c967a46b6c18e595d60a9b85
echo "TEMPEST_USE_TEST_ACCOUNTS=True" >> $localrc_path
echo "TEMPEST_ALLOW_TENANT_ISOLATION=False" >> $localrc_path
echo "TEMPEST_CONCURRENCY=8" >> $localrc_path
# Go to Tempest dir and checkout stable commit to avoid possible
# incompatibilities for plugin stored in Manila repo.
cd $BASE/new/tempest

45
manila_tempest_tests/clients_share.py

@ -1,45 +0,0 @@
# Copyright 2014 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.
from tempest import clients
from tempest.common import credentials_factory as common_creds
from manila_tempest_tests.services.share.json import shares_client
from manila_tempest_tests.services.share.v2.json import shares_client \
as shares_v2_client
class Manager(clients.Manager):
def __init__(
self,
credentials=common_creds.get_configured_credentials('user'),
service=None):
super(Manager, self).__init__(credentials, service)
self.shares_client = shares_client.SharesClient(self.auth_provider)
self.shares_v2_client = shares_v2_client.SharesV2Client(
self.auth_provider)
class AltManager(Manager):
def __init__(self, service=None):
super(AltManager, self).__init__(
common_creds.get_configured_credentials('alt_user'), service)
class AdminManager(Manager):
def __init__(self, service=None):
super(AdminManager, self).__init__(
common_creds.get_configured_credentials('identity_admin'),
service)

69
manila_tempest_tests/tests/api/admin/test_admin_actions_negative.py

@ -13,42 +13,42 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config # noqa
from tempest.lib import exceptions as lib_exc # noqa
from tempest import test # noqa
import testtools # noqa
from tempest import config
from tempest.lib import exceptions as lib_exc
from tempest import test
import testtools
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
CONF = config.CONF
class AdminActionsNegativeTest(base.BaseSharesAdminTest):
class AdminActionsNegativeTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(AdminActionsNegativeTest, cls).resource_setup()
cls.sh = cls.create_share()
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
cls.sh = cls.create_share(client=cls.admin_client)
cls.sh_instance = (
cls.shares_v2_client.get_instances_of_share(cls.sh["id"])[0]
cls.admin_client.get_instances_of_share(cls.sh["id"])[0]
)
if CONF.share.run_snapshot_tests:
cls.sn = cls.create_snapshot_wait_for_active(cls.sh["id"])
cls.member_shares_client = clients.Manager().shares_client
cls.member_shares_v2_client = clients.Manager().shares_v2_client
cls.sn = cls.create_snapshot_wait_for_active(
cls.sh["id"], client=cls.admin_client)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_reset_share_state_to_unacceptable_state(self):
self.assertRaises(lib_exc.BadRequest,
self.shares_client.reset_state,
self.admin_client.reset_state,
self.sh["id"], status="fake")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_reset_share_instance_state_to_unacceptable_state(self):
self.assertRaises(
lib_exc.BadRequest,
self.shares_v2_client.reset_state,
self.admin_client.reset_state,
self.sh_instance["id"],
s_type="share_instances",
status="fake"
@ -59,21 +59,21 @@ class AdminActionsNegativeTest(base.BaseSharesAdminTest):
"Snapshot tests are disabled.")
def test_reset_snapshot_state_to_unacceptable_state(self):
self.assertRaises(lib_exc.BadRequest,
self.shares_client.reset_state,
self.admin_client.reset_state,
self.sn["id"], s_type="snapshots", status="fake")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_try_reset_share_state_with_member(self):
# Even if member from another tenant, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.reset_state,
self.member_client.reset_state,
self.sh["id"])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_try_reset_share_instance_state_with_member(self):
# Even if member from another tenant, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_v2_client.reset_state,
self.member_client.reset_state,
self.sh_instance["id"], s_type="share_instances")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@ -82,21 +82,21 @@ class AdminActionsNegativeTest(base.BaseSharesAdminTest):
def test_try_reset_snapshot_state_with_member(self):
# Even if member from another tenant, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.reset_state,
self.member_client.reset_state,
self.sn["id"], s_type="snapshots")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_try_force_delete_share_with_member(self):
# If a non-admin tries to do force_delete, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.force_delete,
self.member_client.force_delete,
self.sh["id"])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_try_force_delete_share_instance_with_member(self):
# If a non-admin tries to do force_delete, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_v2_client.force_delete,
self.member_client.force_delete,
self.sh_instance["id"], s_type="share_instances")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@ -105,14 +105,14 @@ class AdminActionsNegativeTest(base.BaseSharesAdminTest):
def test_try_force_delete_snapshot_with_member(self):
# If a non-admin tries to do force_delete, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.force_delete,
self.member_client.force_delete,
self.sn["id"], s_type="snapshots")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
def test_try_get_share_instance_with_member(self):
# If a non-admin tries to get instance, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_v2_client.get_share_instance,
self.member_client.get_share_instance,
self.sh_instance["id"])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@ -120,42 +120,43 @@ class AdminActionsNegativeTest(base.BaseSharesAdminTest):
# If a non-admin tries to list instances of given share, it should be
# unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_v2_client.get_instances_of_share,
self.member_client.get_instances_of_share,
self.sh['id'])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@base.skip_if_microversion_lt("2.15")
def test_reset_task_state_empty(self):
self.assertRaises(
lib_exc.BadRequest, self.shares_v2_client.reset_task_state,
lib_exc.BadRequest, self.admin_client.reset_task_state,
self.sh['id'], None)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@base.skip_if_microversion_lt("2.15")
def test_reset_task_state_invalid_state(self):
self.assertRaises(
lib_exc.BadRequest, self.shares_v2_client.reset_task_state,
lib_exc.BadRequest, self.admin_client.reset_task_state,
self.sh['id'], 'fake_state')
class AdminActionsAPIOnlyNegativeTest(base.BaseSharesAdminTest):
class AdminActionsAPIOnlyNegativeTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(AdminActionsAPIOnlyNegativeTest, cls).resource_setup()
cls.member_shares_v2_client = clients.Manager().shares_v2_client
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_list_share_instance_with_member(self):
# If a non-admin tries to list instances, it should be unauthorized
self.assertRaises(lib_exc.Forbidden,
self.member_shares_v2_client.list_share_instances)
self.member_client.list_share_instances)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@base.skip_if_microversion_lt("2.15")
def test_reset_task_state_share_not_found(self):
self.assertRaises(
lib_exc.NotFound, self.shares_v2_client.reset_task_state,
lib_exc.NotFound, self.admin_client.reset_task_state,
'fake_share', 'migration_error')
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -163,35 +164,35 @@ class AdminActionsAPIOnlyNegativeTest(base.BaseSharesAdminTest):
"Snapshot tests are disabled.")
def test_force_delete_nonexistent_snapshot(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.force_delete,
self.admin_client.force_delete,
"fake",
s_type="snapshots")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_force_delete_nonexistent_share(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.force_delete, "fake")
self.admin_client.force_delete, "fake")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_force_delete_nonexistent_share_instance(self):
self.assertRaises(lib_exc.NotFound,
self.shares_v2_client.force_delete,
self.admin_client.force_delete,
"fake",
s_type="share_instances")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_reset_nonexistent_share_state(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.reset_state, "fake")
self.admin_client.reset_state, "fake")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_reset_nonexistent_share_instance_state(self):
self.assertRaises(lib_exc.NotFound, self.shares_v2_client.reset_state,
self.assertRaises(lib_exc.NotFound, self.admin_client.reset_state,
"fake", s_type="share_instances")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
def test_reset_nonexistent_snapshot_state(self):
self.assertRaises(lib_exc.NotFound, self.shares_client.reset_state,
self.assertRaises(lib_exc.NotFound, self.admin_client.reset_state,
"fake", s_type="snapshots")

13
manila_tempest_tests/tests/api/admin/test_export_locations.py

@ -20,7 +20,6 @@ import six
from tempest import config
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
from manila_tempest_tests import utils
@ -30,16 +29,16 @@ LATEST_MICROVERSION = CONF.share.max_api_microversion
@base.skip_if_microversion_not_supported("2.9")
@ddt.ddt
class ExportLocationsTest(base.BaseSharesAdminTest):
class ExportLocationsTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ExportLocationsTest, cls).resource_setup()
cls.admin_client = cls.shares_v2_client
cls.member_client = clients.Manager().shares_v2_client
cls.share = cls.create_share()
cls.share = cls.shares_v2_client.get_share(cls.share['id'])
cls.share_instances = cls.shares_v2_client.get_instances_of_share(
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
cls.share = cls.create_share(client=cls.admin_client)
cls.share = cls.admin_client.get_share(cls.share['id'])
cls.share_instances = cls.admin_client.get_instances_of_share(
cls.share['id'])
def _verify_export_location_structure(

13
manila_tempest_tests/tests/api/admin/test_export_locations_negative.py

@ -17,23 +17,22 @@ from tempest import config
from tempest.lib import exceptions as lib_exc
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
CONF = config.CONF
@base.skip_if_microversion_not_supported("2.9")
class ExportLocationsNegativeTest(base.BaseSharesAdminTest):
class ExportLocationsNegativeTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ExportLocationsNegativeTest, cls).resource_setup()
cls.admin_client = cls.shares_v2_client
cls.member_client = clients.Manager().shares_v2_client
cls.share = cls.create_share()
cls.share = cls.shares_v2_client.get_share(cls.share['id'])
cls.share_instances = cls.shares_v2_client.get_instances_of_share(
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
cls.share = cls.create_share(client=cls.admin_client)
cls.share = cls.admin_client.get_share(cls.share['id'])
cls.share_instances = cls.admin_client.get_instances_of_share(
cls.share['id'])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])

7
manila_tempest_tests/tests/api/admin/test_quotas.py

@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config # noqa
from tempest import test # noqa
from tempest import config
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
CONF = config.CONF
@ -29,7 +28,6 @@ class SharesAdminQuotasTest(base.BaseSharesAdminTest):
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
cls.os = clients.AdminManager()
super(SharesAdminQuotasTest, cls).resource_setup()
cls.user_id = cls.shares_v2_client.user_id
cls.tenant_id = cls.shares_v2_client.tenant_id
@ -73,7 +71,6 @@ class SharesAdminQuotasUpdateTest(base.BaseSharesAdminTest):
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
cls.os = clients.AdminManager()
super(SharesAdminQuotasUpdateTest, cls).resource_setup()
def setUp(self):

9
manila_tempest_tests/tests/api/admin/test_quotas_negative.py

@ -13,12 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config # noqa
from tempest.lib import exceptions as lib_exc # noqa
from tempest import test # noqa
import testtools # noqa
from tempest import config
from tempest.lib import exceptions as lib_exc
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
CONF = config.CONF
@ -33,7 +31,6 @@ class SharesAdminQuotasNegativeTest(base.BaseSharesAdminTest):
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
cls.os = clients.AdminManager()
super(SharesAdminQuotasNegativeTest, cls).resource_setup()
cls.user_id = cls.shares_client.user_id
cls.tenant_id = cls.shares_client.tenant_id

52
manila_tempest_tests/tests/api/admin/test_replication.py

@ -18,7 +18,6 @@ from tempest.lib.common.utils import data_utils
from tempest import test
import testtools
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.common import constants
from manila_tempest_tests import share_exceptions
from manila_tempest_tests.tests.api import base
@ -30,14 +29,15 @@ _MIN_SUPPORTED_MICROVERSION = '2.11'
@testtools.skipUnless(CONF.share.run_replication_tests,
'Replication tests are disabled.')
@base.skip_if_microversion_lt(_MIN_SUPPORTED_MICROVERSION)
class ReplicationAdminTest(base.BaseSharesAdminTest):
class ReplicationAdminTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ReplicationAdminTest, cls).resource_setup()
# Create share_type
name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
cls.admin_client = clients.AdminManager().shares_v2_client
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
cls.replication_type = CONF.share.backend_replication_type
if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
@ -57,8 +57,9 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
cls.share_type = share_type["share_type"]
# Create share with above share_type
cls.share = cls.create_share(share_type_id=cls.share_type["id"],
availability_zone=cls.share_zone,)
cls.replica = cls.shares_v2_client.list_share_replicas(
availability_zone=cls.share_zone,
client=cls.admin_client)
cls.replica = cls.admin_client.list_share_replicas(
share_id=cls.share['id'])[0]
@staticmethod
@ -75,14 +76,16 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
msg = "Option backend_replication_type should be one of (%s)!"
raise self.skipException(
msg % ','.join(constants.REPLICATION_PROMOTION_CHOICES))
share = self.create_share(share_type_id=self.share_type['id'])
original_replica = self.shares_v2_client.list_share_replicas(
share = self.create_share(
share_type_id=self.share_type['id'], client=self.admin_client)
original_replica = self.admin_client.list_share_replicas(
share_id=share['id'])[0]
# NOTE(Yogi1): Cleanup needs to be disabled for replica that is
# being promoted since it will become the 'primary'/'active' replica.
replica = self.create_share_replica(share["id"], self.replica_zone,
cleanup=False)
replica = self.create_share_replica(
share["id"], self.replica_zone, cleanup=False,
client=self.admin_client)
# List replicas
replica_list = self.admin_client.list_share_replicas(
@ -96,7 +99,7 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
# Set replica_state to 'out_of_sync'
self.admin_client.reset_share_replica_state(
replica['id'], constants.REPLICATION_STATE_OUT_OF_SYNC)
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.REPLICATION_STATE_OUT_OF_SYNC,
status_attr='replica_state')
@ -107,7 +110,7 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
self.addCleanup(self.delete_share_replica, original_replica['id'])
# Check if there is still only 1 'active' replica after promotion.
replica_list = self.shares_v2_client.list_share_replicas(
replica_list = self.admin_client.list_share_replicas(
share_id=self.share["id"])
new_active_replicas = self._filter_share_replica_list(
replica_list, constants.REPLICATION_STATE_ACTIVE)
@ -118,24 +121,25 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Test force deleting a replica that is in 'error_deleting' status."""
replica = self.create_share_replica(self.share['id'],
self.replica_zone,
cleanup_in_class=False)
cleanup_in_class=False,
client=self.admin_client)
self.admin_client.reset_share_replica_status(
replica['id'], constants.STATUS_ERROR_DELETING)
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.STATUS_ERROR_DELETING)
self.admin_client.force_delete_share_replica(replica['id'])
self.shares_v2_client.wait_for_resource_deletion(
replica_id=replica['id'])
self.admin_client.wait_for_resource_deletion(replica_id=replica['id'])
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
def test_reset_share_replica_status(self):
"""Test resetting a replica's 'status' attribute."""
replica = self.create_share_replica(self.share['id'],
self.replica_zone,
cleanup_in_class=False)
cleanup_in_class=False,
client=self.admin_client)
self.admin_client.reset_share_replica_status(replica['id'],
constants.STATUS_ERROR)
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.STATUS_ERROR)
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
@ -143,10 +147,11 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Test resetting a replica's 'replica_state' attribute."""
replica = self.create_share_replica(self.share['id'],
self.replica_zone,
cleanup_in_class=False)
cleanup_in_class=False,
client=self.admin_client)
self.admin_client.reset_share_replica_state(replica['id'],
constants.STATUS_ERROR)
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.STATUS_ERROR, status_attr='replica_state')
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
@ -154,20 +159,21 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Test resyncing a replica."""
replica = self.create_share_replica(self.share['id'],
self.replica_zone,
cleanup_in_class=False)
self.shares_v2_client.wait_for_share_replica_status(
cleanup_in_class=False,
client=self.admin_client)
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.REPLICATION_STATE_IN_SYNC,
status_attr='replica_state')
# Set replica_state to 'out_of_sync'.
self.admin_client.reset_share_replica_state(
replica['id'], constants.REPLICATION_STATE_OUT_OF_SYNC)
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.REPLICATION_STATE_OUT_OF_SYNC,
status_attr='replica_state')
# Attempt resync
self.admin_client.resync_share_replica(replica['id'])
self.shares_v2_client.wait_for_share_replica_status(
self.admin_client.wait_for_share_replica_status(
replica['id'], constants.REPLICATION_STATE_IN_SYNC,
status_attr='replica_state')

78
manila_tempest_tests/tests/api/admin/test_replication_actions.py

@ -16,7 +16,6 @@ from tempest.lib import exceptions as lib_exc
from tempest import test
import testtools
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.common import constants
from manila_tempest_tests import share_exceptions
from manila_tempest_tests.tests.api import base
@ -31,14 +30,15 @@ _MIN_SUPPORTED_MICROVERSION = '2.11'
CONF.share.multitenancy_enabled,
"Only for driver_handles_share_servers = False driver mode.")
@base.skip_if_microversion_lt(_MIN_SUPPORTED_MICROVERSION)
class ReplicationAdminTest(base.BaseSharesAdminTest):
class ReplicationAdminTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ReplicationAdminTest, cls).resource_setup()
# Create share_type
name = data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX)
cls.admin_client = clients.AdminManager().shares_v2_client
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
cls.replication_type = CONF.share.backend_replication_type
if cls.replication_type not in constants.REPLICATION_TYPE_CHOICES:
@ -60,8 +60,9 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
# Create share with above share_type
cls.share = cls.create_share(size=2,
share_type_id=cls.share_type["id"],
availability_zone=cls.share_zone,)
cls.replica = cls.shares_v2_client.list_share_replicas(
availability_zone=cls.share_zone,
client=cls.admin_client)
cls.replica = cls.admin_client.list_share_replicas(
share_id=cls.share['id'])[0]
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
@ -70,21 +71,21 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
def test_extend_replicated_share(self):
# Test extend share
new_size = self.share["size"] + 1
self.shares_v2_client.extend_share(self.share["id"], new_size)
self.shares_v2_client.wait_for_share_status(self.share["id"],
"available")
share = self.shares_v2_client.get_share(self.share["id"])
self.admin_client.extend_share(self.share["id"], new_size)
self.admin_client.wait_for_share_status(self.share["id"],
"available")
share = self.admin_client.get_share(self.share["id"])
self.assertEqual(new_size, int(share["size"]))
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
@testtools.skipUnless(CONF.share.run_shrink_tests,
'Shrink share tests are disabled.')
def test_shrink_replicated_share(self):
share = self.shares_v2_client.get_share(self.share["id"])
share = self.admin_client.get_share(self.share["id"])
new_size = self.share["size"] - 1
self.shares_v2_client.shrink_share(self.share["id"], new_size)
self.shares_v2_client.wait_for_share_status(share["id"], "available")
shrink_share = self.shares_v2_client.get_share(self.share["id"])
self.admin_client.shrink_share(self.share["id"], new_size)
self.admin_client.wait_for_share_status(share["id"], "available")
shrink_share = self.admin_client.get_share(self.share["id"])
self.assertEqual(new_size, int(shrink_share["size"]))
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
@ -96,30 +97,31 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
share = self.create_share(size=2,
share_type_id=self.share_type["id"],
availability_zone=self.share_zone,
cleanup_in_class=True)
share = self.shares_v2_client.get_share(share["id"])
export_locations = self.shares_v2_client.list_share_export_locations(
cleanup_in_class=True,
client=self.admin_client)
share = self.admin_client.get_share(share["id"])
export_locations = self.admin_client.list_share_export_locations(
share["id"])
export_path = export_locations[0]['path']
self.shares_v2_client.unmanage_share(share['id'])
self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
self.admin_client.unmanage_share(share['id'])
self.admin_client.wait_for_resource_deletion(share_id=share['id'])
# Manage the previously unmanaged share
managed_share = self.shares_v2_client.manage_share(
managed_share = self.admin_client.manage_share(
share['host'], share['share_proto'],
export_path, self.share_type['id'])
self.shares_v2_client.wait_for_share_status(
self.admin_client.wait_for_share_status(
managed_share['id'], 'available')
# Add managed share to cleanup queue
self.method_resources.insert(
0, {'type': 'share', 'id': managed_share['id'],
'client': self.shares_v2_client})
'client': self.admin_client})
# Make sure a replica can be added to newly managed share
self.create_share_replica(managed_share['id'], self.replica_zone,
cleanup=True)
cleanup=True, client=self.admin_client)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@testtools.skipUnless(CONF.share.run_manage_unmanage_tests,
@ -128,10 +130,10 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Try to unmanage a share having replica."""
# Create a share replica before unmanaging the share
self.create_share_replica(self.share["id"], self.replica_zone,
cleanup=True)
cleanup=True, client=self.admin_client)
self.assertRaises(
lib_exc.Conflict,
self.shares_v2_client.unmanage_share,
self.admin_client.unmanage_share,
share_id=self.share['id'])
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
@ -141,9 +143,10 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Unmanage a replication type share that does not have replica."""
share = self.create_share(size=2,
share_type_id=self.share_type["id"],
availability_zone=self.share_zone,)
self.shares_v2_client.unmanage_share(share['id'])
self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
availability_zone=self.share_zone,
client=self.admin_client)
self.admin_client.unmanage_share(share['id'])
self.admin_client.wait_for_resource_deletion(share_id=share['id'])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@testtools.skipUnless(CONF.share.run_manage_unmanage_snapshot_tests,
@ -152,10 +155,10 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Try to manage a snapshot of the replicated."""
# Create a share replica before managing the snapshot
self.create_share_replica(self.share["id"], self.replica_zone,
cleanup=True)
cleanup=True, client=self.admin_client)
self.assertRaises(
lib_exc.Conflict,
self.shares_v2_client.manage_snapshot,
self.admin_client.manage_snapshot,
share_id=self.share['id'],
provider_location="127.0.0.1:/fake_provider_location/"
"manila_share_9dc61f49_fbc8_48d7_9337_2f9593d9")
@ -167,11 +170,12 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Try to unmanage a snapshot of the replicated share with replica."""
# Create a share replica before unmanaging the snapshot
self.create_share_replica(self.share["id"], self.replica_zone,
cleanup=True)
snapshot = self.create_snapshot_wait_for_active(self.share["id"])
cleanup=True, client=self.admin_client)
snapshot = self.create_snapshot_wait_for_active(
self.share["id"], client=self.admin_client)
self.assertRaises(
lib_exc.Conflict,
self.shares_v2_client.unmanage_snapshot,
self.admin_client.unmanage_snapshot,
snapshot_id=snapshot['id'])
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
@ -181,9 +185,11 @@ class ReplicationAdminTest(base.BaseSharesAdminTest):
"""Unmanage a snapshot of the replicated share with no replica."""
share = self.create_share(size=2,
share_type_id=self.share_type["id"],
availability_zone=self.share_zone,)
availability_zone=self.share_zone,
client=self.admin_client)
snapshot = self.create_snapshot_wait_for_active(share["id"])
self.shares_v2_client.unmanage_snapshot(snapshot_id=snapshot['id'])
self.shares_v2_client.wait_for_resource_deletion(
snapshot = self.create_snapshot_wait_for_active(
share["id"], client=self.admin_client)
self.admin_client.unmanage_snapshot(snapshot_id=snapshot['id'])
self.admin_client.wait_for_resource_deletion(
snapshot_id=snapshot['id'])

25
manila_tempest_tests/tests/api/admin/test_services_negative.py

@ -17,30 +17,29 @@ import ddt
from tempest.lib import exceptions as lib_exc
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
@ddt.ddt
class ServicesAdminNegativeTest(base.BaseSharesAdminTest):
class ServicesAdminNegativeTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ServicesAdminNegativeTest, cls).resource_setup()
user_clients = clients.Manager()
cls.user_shares_client = user_clients.shares_client
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_services_with_non_admin_user(self):
self.assertRaises(lib_exc.Forbidden,
self.user_shares_client.list_services)
self.member_client.list_services)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_params(self):
# All services are expected if send the request with invalid parameter
services = self.shares_client.list_services()
services = self.admin_client.list_services()
params = {'fake_param': 'fake_param_value'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(len(services), len(services_fake))
# "update_at" field could be updated before second request,
@ -58,31 +57,31 @@ class ServicesAdminNegativeTest(base.BaseSharesAdminTest):
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_host(self):
params = {'host': 'fake_host'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(0, len(services_fake))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_binary(self):
params = {'binary': 'fake_binary'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(0, len(services_fake))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_zone(self):
params = {'zone': 'fake_zone'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(0, len(services_fake))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_status(self):
params = {'status': 'fake_status'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(0, len(services_fake))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_get_service_by_invalid_state(self):
params = {'state': 'fake_state'}
services_fake = self.shares_client.list_services(params)
services_fake = self.admin_client.list_services(params)
self.assertEqual(0, len(services_fake))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -96,6 +95,6 @@ class ServicesAdminNegativeTest(base.BaseSharesAdminTest):
def test_list_services_with_wrong_versions(self, url, version):
self.assertRaises(
lib_exc.NotFound,
self.shares_v2_client.list_services,
self.admin_client.list_services,
version=version, url=url,
)

38
manila_tempest_tests/tests/api/admin/test_share_servers_negative.py

@ -13,78 +13,78 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.common.utils import data_utils # noqa
from tempest.lib import exceptions as lib_exc # noqa
from tempest import test # noqa
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
class ShareServersNegativeAdminTest(base.BaseSharesAdminTest):
class ShareServersNegativeAdminTest(base.BaseSharesMixedTest):
@classmethod
def resource_setup(cls):
super(ShareServersNegativeAdminTest, cls).resource_setup()
cls.member_shares_client = clients.Manager().shares_client
cls.admin_client = cls.admin_shares_v2_client
cls.member_client = cls.shares_v2_client
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_list_share_servers_with_member(self):
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.list_share_servers)
self.member_client.list_share_servers)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_show_share_server_with_member(self):
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.show_share_server,
self.member_client.show_share_server,
'fake_id')
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_show_share_server_details_with_member(self):
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.show_share_server_details,
self.member_client.show_share_server_details,
'fake_id')
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_show_share_server_with_inexistent_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.show_share_server,
self.admin_client.show_share_server,
'fake_id')
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_show_share_server_details_with_inexistent_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.show_share_server_details,
self.admin_client.show_share_server_details,
'fake_id')
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_share_servers_with_wrong_filter_key(self):
search_opts = {'fake_filter_key': 'ACTIVE'}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_share_servers_with_wrong_filter_value(self):
search_opts = {'host': 123}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_share_servers_with_fake_status(self):
search_opts = {"status": data_utils.rand_name("fake_status")}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_share_servers_with_fake_host(self):
search_opts = {"host": data_utils.rand_name("fake_host")}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_list_share_servers_with_fake_project(self):
search_opts = {"project_id": data_utils.rand_name("fake_project_id")}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -92,17 +92,17 @@ class ShareServersNegativeAdminTest(base.BaseSharesAdminTest):
search_opts = {
"share_network": data_utils.rand_name("fake_share_network"),
}
servers = self.shares_client.list_share_servers(search_opts)
servers = self.admin_client.list_share_servers(search_opts)
self.assertEqual(0, len(servers))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_delete_share_server_with_nonexistent_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.delete_share_server,
self.admin_client.delete_share_server,
"fake_nonexistent_share_server_id")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_delete_share_server_with_member(self):
self.assertRaises(lib_exc.Forbidden,
self.member_shares_client.delete_share_server,
self.member_client.delete_share_server,
"fake_nonexistent_share_server_id")

192
manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py

@ -13,32 +13,27 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.common.utils import data_utils # noqa
from tempest.lib import exceptions as lib_exc # noqa
from tempest import test # noqa
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests.tests.api import base
class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
class ExtraSpecsAdminNegativeTest(base.BaseSharesMixedTest):
def _create_share_type(self):
name = data_utils.rand_name("unique_st_name")
extra_specs = self.add_required_extra_specs_to_dict({"key": "value"})
return self.create_share_type(name, extra_specs=extra_specs)
@classmethod
def resource_setup(cls):
super(ExtraSpecsAdminNegativeTest, cls).resource_setup()
cls.member_shares_client = clients.Manager().shares_client
return self.create_share_type(
name, extra_specs=extra_specs, client=self.admin_shares_v2_client)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_create_extra_specs_with_user(self):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.create_share_type_extra_specs,
self.shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({"key": "new_value"}))
@ -47,7 +42,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.get_share_type_extra_specs,
self.shares_v2_client.get_share_type_extra_specs,
st["share_type"]["id"])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -55,7 +50,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.get_share_type_extra_spec,
self.shares_v2_client.get_share_type_extra_spec,
st["share_type"]["id"], "key")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -63,13 +58,13 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.get_share_type_extra_specs,
self.shares_v2_client.get_share_type_extra_specs,
st["share_type"]["id"])
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_read_extra_specs_on_share_type_with_user(self):
st = self._create_share_type()
share_type = self.member_shares_client.get_share_type(
share_type = self.shares_v2_client.get_share_type(
st['share_type']['id'])
# Verify a non-admin can only read the required extra-specs
expected_keys = ['driver_handles_share_servers', 'snapshot_support']
@ -83,7 +78,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.update_share_type_extra_spec,
self.shares_v2_client.update_share_type_extra_spec,
st["share_type"]["id"], "key", "new_value")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -91,7 +86,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.update_share_type_extra_specs,
self.shares_v2_client.update_share_type_extra_specs,
st["share_type"]["id"], {"key": "new_value"})
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -99,7 +94,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.Forbidden,
self.member_shares_client.delete_share_type_extra_spec,
self.shares_v2_client.delete_share_type_extra_spec,
st["share_type"]["id"], "key")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@ -108,7 +103,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.BadRequest,
self.shares_client.create_share_type_extra_specs,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({too_big_key: "value"}))
@ -118,7 +113,7 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
st = self._create_share_type()
self.assertRaises(
lib_exc.BadRequest,
self.shares_client.create_share_type_extra_specs,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({"key": too_big_value}))
@ -126,12 +121,12 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
def test_try_set_too_long_value_with_update(self):
too_big_value = "v" * 256
st = self._create_share_type()
self.shares_client.create_share_type_extra_specs(
self.admin_shares_v2_client.create_share_type_extra_specs(
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({"key": "value"}))
self.assertRaises(
lib_exc.BadRequest,
self.shares_client.update_share_type_extra_specs,
self.admin_shares_v2_client.update_share_type_extra_specs,
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({"key": too_big_value}))
@ -139,143 +134,164 @@ class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
def test_try_set_too_long_value_with_update_of_one_key(self):
too_big_value = "v" * 256
st = self._create_share_type()
self.shares_client.create_share_type_extra_specs(
self.admin_shares_v2_client.create_share_type_extra_specs(
st["share_type"]["id"],
self.add_required_extra_specs_to_dict({"key": "value"}))
self.assertRaises(lib_exc.BadRequest,
self.shares_client.update_share_type_extra_spec,
st["share_type"]["id"], "key", too_big_value)
self.assertRaises(
lib_exc.BadRequest,
self.admin_shares_v2_client.update_share_type_extra_spec,
st["share_type"]["id"], "key", too_big_value)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_list_es_with_empty_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_specs, "")
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_specs, "")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_list_es_with_invalid_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_specs,
data_utils.rand_name("fake"))
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_specs,
data_utils.rand_name("fake"))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_create_es_with_empty_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.create_share_type_extra_specs,
"", {"key1": "value1", })
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.create_share_type_extra_specs,
"", {"key1": "value1", })
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_create_es_with_invalid_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.create_share_type_extra_specs,
data_utils.rand_name("fake"), {"key1": "value1", })
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.create_share_type_extra_specs,
data_utils.rand_name("fake"), {"key1": "value1", })
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_create_es_with_empty_specs(self):
st = self._create_share_type()
self.assertRaises(lib_exc.BadRequest,
self.shares_client.create_share_type_extra_specs,
st["share_type"]["id"], "")
self.assertRaises(
lib_exc.BadRequest,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"], "")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_create_es_with_invalid_specs(self):
st = self._create_share_type()
self.assertRaises(lib_exc.BadRequest,
self.shares_client.create_share_type_extra_specs,
st["share_type"]["id"], {"": "value_with_empty_key"})
self.assertRaises(
lib_exc.BadRequest,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"], {"": "value_with_empty_key"})
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_get_extra_spec_with_empty_key(self):
st = self._create_share_type()
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_spec,
st["share_type"]["id"], "")
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_spec,
st["share_type"]["id"], "")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_get_extra_spec_with_invalid_key(self):
st = self._create_share_type()
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_spec,
st["share_type"]["id"], data_utils.rand_name("fake"))
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_spec,
st["share_type"]["id"], data_utils.rand_name("fake"))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_get_extra_specs_with_empty_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_specs,
"")
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_specs,
"")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_get_extra_specs_with_invalid_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.get_share_type_extra_specs,
data_utils.rand_name("fake"))
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_type_extra_specs,
data_utils.rand_name("fake"))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_delete_es_key_with_empty_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.delete_share_type_extra_spec,
"", "key", )
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.delete_share_type_extra_spec,
"", "key", )
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_delete_es_key_with_invalid_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.delete_share_type_extra_spec,
data_utils.rand_name("fake"), "key", )
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.delete_share_type_extra_spec,
data_utils.rand_name("fake"), "key", )
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_delete_with_invalid_key(self):
st = self._create_share_type()
self.assertRaises(lib_exc.NotFound,
self.shares_client.delete_share_type_extra_spec,
st["share_type"]["id"], data_utils.rand_name("fake"))
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.delete_share_type_extra_spec,
st["share_type"]["id"], data_utils.rand_name("fake"))
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_update_spec_with_empty_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.update_share_type_extra_spec,
"", "key", "new_value")
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.update_share_type_extra_spec,
"", "key", "new_value")
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_try_update_spec_with_invalid_shr_type_id(self):
self.assertRaises(lib_exc.NotFound,
self.shares_client.update_share_type_extra_spec,
data_utils.rand_name("fake"), "key", "new_value")
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.update_share_type_extra_spec,
data_utils.rand_name("fake"), "key", "new_value")