0970eb6e3a
- Add Database migration to introduce the column on the share instances model. - Set the field to True if creating read-only secondary replicas, unset while promoting them. - Set the field to True if drivers don't support writable access to migrating shares, or if using host assisted migration. Unset if migration fails, or is canceled. - Expose the field via share-instances and share-replicas APIs to administrators. Supporting read only-access rules is part of the minimum driver requirements in manila. APIImpact DocImpact Implements: bp fix-and-improve-access-rules Co-Authored-By: Rodrigo Barbieri <rodrigo.barbieri@fit-tecnologia.org.br> Change-Id: Ie8425f36f02cbcede0aaa9f3fe1f5f3cf23df8b8
107 lines
4.3 KiB
Python
107 lines
4.3 KiB
Python
# Copyright 2015 Andrew Kerr
|
|
# 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 config
|
|
from testtools import testcase as tc
|
|
|
|
from manila_tempest_tests.tests.api import base
|
|
from manila_tempest_tests import utils
|
|
|
|
CONF = config.CONF
|
|
|
|
|
|
class ShareInstancesTest(base.BaseSharesAdminTest):
|
|
|
|
@classmethod
|
|
def resource_setup(cls):
|
|
super(ShareInstancesTest, cls).resource_setup()
|
|
cls.share = cls.create_share()
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_get_instances_of_share_v2_3(self):
|
|
"""Test that we get only the 1 share instance back for the share."""
|
|
share_instances = self.shares_v2_client.get_instances_of_share(
|
|
self.share['id'], version='2.3'
|
|
)
|
|
|
|
self.assertEqual(1, len(share_instances),
|
|
'Too many share instances found; expected 1, '
|
|
'found %s' % len(share_instances))
|
|
|
|
si = share_instances[0]
|
|
self.assertEqual(self.share['id'], si['share_id'],
|
|
'Share instance %s has incorrect share id value; '
|
|
'expected %s, got %s.' % (si['id'],
|
|
self.share['id'],
|
|
si['share_id']))
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_list_share_instances_v2_3(self):
|
|
"""Test that we get at least the share instance back for the share."""
|
|
share_instances = self.shares_v2_client.get_instances_of_share(
|
|
self.share['id'], version='2.3'
|
|
)
|
|
|
|
share_ids = [si['share_id'] for si in share_instances]
|
|
|
|
msg = 'Share instance for share %s was not found.' % self.share['id']
|
|
self.assertIn(self.share['id'], share_ids, msg)
|
|
|
|
def _get_share_instance(self, version):
|
|
"""Test that we get the proper keys back for the instance."""
|
|
share_instances = self.shares_v2_client.get_instances_of_share(
|
|
self.share['id'], version=version,
|
|
)
|
|
|
|
si = self.shares_v2_client.get_share_instance(
|
|
share_instances[0]['id'], version=version)
|
|
|
|
expected_keys = [
|
|
'host', 'share_id', 'id', 'share_network_id', 'status',
|
|
'availability_zone', 'share_server_id', 'created_at',
|
|
]
|
|
if utils.is_microversion_lt(version, '2.9'):
|
|
expected_keys.extend(["export_location", "export_locations"])
|
|
if utils.is_microversion_ge(version, '2.10'):
|
|
expected_keys.append("access_rules_status")
|
|
if utils.is_microversion_ge(version, '2.11'):
|
|
expected_keys.append("replica_state")
|
|
if utils.is_microversion_ge(version, '2.22'):
|
|
expected_keys.append("share_type_id")
|
|
if utils.is_microversion_ge(version, '2.30'):
|
|
expected_keys.append("cast_rules_to_readonly")
|
|
expected_keys = sorted(expected_keys)
|
|
actual_keys = sorted(si.keys())
|
|
self.assertEqual(expected_keys, actual_keys,
|
|
'Share instance %s returned incorrect keys; '
|
|
'expected %s, got %s.' % (
|
|
si['id'], expected_keys, actual_keys))
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_get_share_instance_v2_3(self):
|
|
self._get_share_instance('2.3')
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_get_share_instance_v2_9(self):
|
|
self._get_share_instance('2.9')
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_get_share_instance_v2_10(self):
|
|
self._get_share_instance('2.10')
|
|
|
|
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
|
|
def test_get_share_instance_v2_30(self):
|
|
self._get_share_instance('2.30')
|