Add tests replica create with 'share-network' option.
This patch update positive and negative tests using the share replica create API. For version >= 2.72. Partial-Bug: #1925486 Depends-On: I9049dcd418fbb16d663ab8ed27b90c765fafc5d3 Change-Id: I76175e33f506e35112ab9e86724caa3aea8f546d
This commit is contained in:
parent
54e31e8f5b
commit
2521fbf86a
manila_tempest_tests
common
services/share/v2/json
tests/api
@ -42,6 +42,7 @@ REPLICATION_STATE_IN_SYNC = 'in_sync'
|
||||
REPLICATION_STATE_OUT_OF_SYNC = 'out_of_sync'
|
||||
MIN_SHARE_REPLICATION_VERSION = '2.11'
|
||||
SHARE_REPLICA_GRADUATION_VERSION = '2.56'
|
||||
SHARE_REPLICA_SHARE_NET_PARAM_VERSION = '2.72'
|
||||
|
||||
# Access Rules
|
||||
RULE_STATE_ACTIVE = 'active'
|
||||
|
@ -1563,8 +1563,8 @@ class SharesV2Client(shares_client.SharesClient):
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_share_replica(self, share_id, availability_zone=None,
|
||||
version=LATEST_MICROVERSION,
|
||||
scheduler_hints=None):
|
||||
scheduler_hints=None, share_network_id=None,
|
||||
version=LATEST_MICROVERSION):
|
||||
"""Add a share replica of an existing share."""
|
||||
uri = "share-replicas"
|
||||
post_body = {
|
||||
@ -1574,6 +1574,9 @@ class SharesV2Client(shares_client.SharesClient):
|
||||
|
||||
if scheduler_hints:
|
||||
post_body["scheduler_hints"] = scheduler_hints
|
||||
if share_network_id:
|
||||
post_body['share_network_id'] = share_network_id
|
||||
|
||||
headers, extra_headers = utils.get_extra_headers(
|
||||
version, constants.SHARE_REPLICA_GRADUATION_VERSION)
|
||||
body = json.dumps({'share_replica': post_body})
|
||||
|
@ -105,9 +105,13 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
|
||||
|
||||
# NOTE(Yogi1): Cleanup needs to be disabled for replica that is
|
||||
# being promoted since it will become the 'primary'/'active' replica.
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
replica = self.create_share_replica(
|
||||
share["id"], self.replica_zone, cleanup=False,
|
||||
client=self.admin_client, version=version)
|
||||
share["id"], self.replica_zone, share_network_id=share_net_id,
|
||||
cleanup=False, client=self.admin_client, version=version)
|
||||
# Wait for replica state to update after creation
|
||||
waiters.wait_for_resource_status(
|
||||
self.admin_client, replica['id'],
|
||||
@ -156,11 +160,15 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
|
||||
def test_force_delete_share_replica(self, version):
|
||||
"""Test force deleting a replica that is in 'error_deleting' status."""
|
||||
utils.check_skip_if_microversion_not_supported(version)
|
||||
replica = self.create_share_replica(self.share['id'],
|
||||
self.replica_zone,
|
||||
cleanup_in_class=False,
|
||||
client=self.admin_client,
|
||||
version=version)
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
replica = self.create_share_replica(
|
||||
self.share['id'], self.replica_zone,
|
||||
share_network_id=share_net_id,
|
||||
cleanup_in_class=False,
|
||||
client=self.admin_client, version=version)
|
||||
self.admin_client.reset_share_replica_status(
|
||||
replica['id'], constants.STATUS_ERROR_DELETING, version=version)
|
||||
waiters.wait_for_resource_status(
|
||||
@ -179,11 +187,15 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
|
||||
def test_reset_share_replica_status(self, version):
|
||||
"""Test resetting a replica's 'status' attribute."""
|
||||
utils.check_skip_if_microversion_not_supported(version)
|
||||
replica = self.create_share_replica(self.share['id'],
|
||||
self.replica_zone,
|
||||
cleanup_in_class=False,
|
||||
client=self.admin_client,
|
||||
version=version)
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
replica = self.create_share_replica(
|
||||
self.share['id'], self.replica_zone,
|
||||
share_network_id=share_net_id,
|
||||
cleanup_in_class=False, client=self.admin_client,
|
||||
version=version)
|
||||
self.admin_client.reset_share_replica_status(replica['id'],
|
||||
constants.STATUS_ERROR,
|
||||
version=version)
|
||||
@ -200,11 +212,15 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
|
||||
def test_reset_share_replica_state(self, version):
|
||||
"""Test resetting a replica's 'replica_state' attribute."""
|
||||
utils.check_skip_if_microversion_not_supported(version)
|
||||
replica = self.create_share_replica(self.share['id'],
|
||||
self.replica_zone,
|
||||
cleanup_in_class=False,
|
||||
client=self.admin_client,
|
||||
version=version)
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
replica = self.create_share_replica(
|
||||
self.share['id'], self.replica_zone,
|
||||
share_network_id=share_net_id,
|
||||
cleanup_in_class=False, client=self.admin_client,
|
||||
version=version)
|
||||
self.admin_client.reset_share_replica_state(replica['id'],
|
||||
constants.STATUS_ERROR,
|
||||
version=version)
|
||||
@ -222,11 +238,12 @@ class ReplicationAdminTest(base.BaseSharesMixedTest):
|
||||
def test_resync_share_replica(self, version):
|
||||
"""Test resyncing a replica."""
|
||||
utils.check_skip_if_microversion_not_supported(version)
|
||||
replica = self.create_share_replica(self.share['id'],
|
||||
self.replica_zone,
|
||||
cleanup_in_class=False,
|
||||
client=self.admin_client,
|
||||
version=version)
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
replica = self.create_share_replica(
|
||||
self.share['id'], share_network_id=share_net_id, version=version)
|
||||
waiters.wait_for_resource_status(
|
||||
self.admin_client, replica['id'],
|
||||
constants.REPLICATION_STATE_IN_SYNC, resource_name='share_replica',
|
||||
|
@ -676,14 +676,17 @@ class BaseSharesTest(test.BaseTestCase):
|
||||
|
||||
@classmethod
|
||||
def create_share_replica(cls, share_id, availability_zone=None,
|
||||
scheduler_hints=None,
|
||||
share_network_id=None,
|
||||
client=None, cleanup_in_class=False,
|
||||
cleanup=True,
|
||||
version=CONF.share.max_api_microversion,
|
||||
scheduler_hints=None):
|
||||
version=CONF.share.max_api_microversion):
|
||||
client = client or cls.shares_v2_client
|
||||
replica = client.create_share_replica(
|
||||
share_id, availability_zone=availability_zone,
|
||||
version=version, scheduler_hints=scheduler_hints)['share_replica']
|
||||
scheduler_hints=scheduler_hints,
|
||||
share_network_id=share_network_id,
|
||||
version=version)['share_replica']
|
||||
resource = {
|
||||
"type": "share_replica",
|
||||
"id": replica["id"],
|
||||
|
@ -13,6 +13,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
|
||||
from tempest.lib import decorators
|
||||
@ -26,12 +27,14 @@ from manila_tempest_tests.tests.api import base
|
||||
from manila_tempest_tests import utils
|
||||
|
||||
CONF = config.CONF
|
||||
LATEST_MICROVERSION = CONF.share.max_api_microversion
|
||||
_MIN_SUPPORTED_MICROVERSION = '2.11'
|
||||
SUMMARY_KEYS = ['share_id', 'id', 'replica_state', 'status']
|
||||
DETAIL_KEYS = SUMMARY_KEYS + ['availability_zone', 'updated_at',
|
||||
'share_network_id', 'created_at']
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ReplicationTest(base.BaseSharesMixedTest):
|
||||
|
||||
@classmethod
|
||||
@ -96,11 +99,15 @@ class ReplicationTest(base.BaseSharesMixedTest):
|
||||
share["id"])['share_instances']
|
||||
return share_instances[0]["id"]
|
||||
|
||||
def _verify_create_replica(self):
|
||||
def _verify_create_replica(self, version=LATEST_MICROVERSION):
|
||||
# Create the replica
|
||||
share_replica = self.create_share_replica(self.shares[0]["id"],
|
||||
self.replica_zone,
|
||||
cleanup_in_class=False)
|
||||
share_net_id = None
|
||||
if utils.is_microversion_ge(version, (
|
||||
constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION)):
|
||||
share_net_id = self.sn_id
|
||||
share_replica = self.create_share_replica(
|
||||
self.shares[0]["id"], self.replica_zone,
|
||||
share_network_id=share_net_id, cleanup_in_class=False)
|
||||
share_replicas = self.shares_v2_client.list_share_replicas(
|
||||
share_id=self.shares[0]["id"])['share_replicas']
|
||||
# Ensure replica is created successfully.
|
||||
@ -155,6 +162,18 @@ class ReplicationTest(base.BaseSharesMixedTest):
|
||||
raise self.skipException(
|
||||
msg % ','.join(constants.REPLICATION_PROMOTION_CHOICES))
|
||||
|
||||
@decorators.idempotent_id('c59e3198-062b-4284-8a3b-189a62213573')
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
|
||||
@testtools.skipUnless(
|
||||
CONF.share.multitenancy_enabled, "Only for multitenancy.")
|
||||
@ddt.data(
|
||||
*utils.deduplicate([constants.SHARE_REPLICA_SHARE_NET_PARAM_VERSION,
|
||||
LATEST_MICROVERSION]))
|
||||
def test_create_share_replica_with_provided_network(self, version):
|
||||
utils.check_skip_if_microversion_not_supported(version)
|
||||
share_replica = self._verify_create_replica(version)
|
||||
self.assertIsNotNone(share_replica)
|
||||
|
||||
@decorators.idempotent_id('8858617f-292d-4e5c-9e15-794b7f1b2e3c')
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
|
||||
def test_add_delete_share_replica(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user