def test_list_share_groups_with_detail_min(self, version):
        utils.check_skip_if_microversion_not_supported(version)
        params = None
        if utils.is_microversion_ge(version, '2.36'):
            params = {'name~': 'tempest', 'description~': 'tempest'}
        # List share groups
        share_groups = self.shares_v2_client.list_share_groups(
            detailed=True, params=params, version=version)['share_groups']

        # Verify keys
        for sg in share_groups:
            keys = set(sg.keys())
            self.assertTrue(
                constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS.issubset(keys),
                'Not all required keys returned for share group %s.  '
                'Expected at least: %s, found %s' % (
                    sg['id'],
                    constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS,
                    ','.join(keys),
                ))

        # Share group ids are in list exactly once
        for group_id in (self.share_group["id"], self.share_group2["id"]):
            gen = [
                share_group["id"] for share_group in share_groups
                if share_group["id"] == group_id
            ]
            msg = ("Expected id %s exactly once in share group list" %
                   group_id)
            self.assertEqual(1, len(gen), msg)
Esempio n. 2
0
    def test_share_type_create_list(self, version):
        utils.check_skip_if_microversion_not_supported(version)

        name = data_utils.rand_name("tempest-manila")
        description = None
        if utils.is_microversion_ge(version, "2.41"):
            description = "Description for share type"
        extra_specs = self.add_extra_specs_to_dict()

        # Create share type
        st_create = self.create_share_type(name,
                                           extra_specs=extra_specs,
                                           version=version,
                                           description=description)
        self._verify_is_public_key_name(st_create, version)
        st_id = st_create["id"]

        # list share types
        st_list = self.shares_v2_client.list_share_types(version=version)
        sts = st_list["share_types"]
        self.assertGreaterEqual(len(sts), 1)
        self.assertTrue(any(st_id in st["id"] for st in sts))
        for st in sts:
            self._verify_is_public_key_name(st, version)

        # Check that backwards compatibility didn't break
        vts = st_list["volume_types"]
        self.assertEqual(len(sts), len(vts))
        for i in range(len(sts)):
            self.assertDictMatch(sts[i], vts[i])
    def test_list_security_services_with_detail(self, version):
        utils.check_skip_if_microversion_not_supported(version)
        with_ou = True if utils.is_microversion_ge(version, '2.44') else False
        if utils.is_microversion_ge(version, '2.0'):
            listed = self.shares_v2_client.list_security_services(
                detailed=True, version=version)['security_services']
        else:
            listed = self.shares_client.list_security_services(
                detailed=True)['security_services']

        self.assertTrue(any(self.ss_ldap['id'] == ss['id'] for ss in listed))
        self.assertTrue(
            any(self.ss_kerberos['id'] == ss['id'] for ss in listed))

        # verify keys
        keys = [
            "name",
            "id",
            "status",
            "description",
            "domain",
            "server",
            "dns_ip",
            "user",
            "password",
            "type",
            "created_at",
            "updated_at",
            "project_id",
        ]
        [self.assertIn(key, s_s.keys()) for s_s in listed for key in keys]

        for ss in listed:
            self.assertEqual(with_ou, 'ou' in ss.keys())
Esempio n. 4
0
    def skip_checks(cls):
        super(ShareGroupTypesAdminNegativeTest, cls).skip_checks()
        if not CONF.share.run_share_group_tests:
            raise cls.skipException('Share Group tests disabled.')

        utils.check_skip_if_microversion_not_supported(
            constants.MIN_SHARE_GROUP_MICROVERSION)
    def test_update_share_group(self, version):
        utils.check_skip_if_microversion_not_supported(version)

        # Get share_group
        share_group = self.shares_v2_client.get_share_group(
            self.share_group['id'], version=version)['share_group']
        self.assertEqual(self.share_group_name, share_group["name"])
        self.assertEqual(self.share_group_desc, share_group["description"])

        # Update share_group
        new_name = data_utils.rand_name("tempest-new-name")
        new_desc = data_utils.rand_name("tempest-new-description")
        updated = self.shares_v2_client.update_share_group(
            share_group["id"],
            name=new_name,
            description=new_desc,
            version=version,
        )['share_group']
        self.assertEqual(new_name, updated["name"])
        self.assertEqual(new_desc, updated["description"])

        # Get share_group
        share_group = self.shares_v2_client.get_share_group(
            self.share_group['id'],
            version=version,
        )['share_group']
        self.assertEqual(new_name, share_group["name"])
        self.assertEqual(new_desc, share_group["description"])

        # Rollback the update since this is a ddt and the class resources are
        # going to be reused
        self._rollback_share_group_update(version)
    def test_list_snapshots_with_detail(self, version):
        params = None
        if version and utils.is_microversion_ge(version, '2.36'):
            params = {'name~': 'tempest', 'description~': 'tempest'}
        # list share snapshots
        if version is None:
            snaps = self.shares_client.list_snapshots_with_detail(
            )['snapshots']
        else:
            utils.check_skip_if_microversion_not_supported(version)
            snaps = self.shares_v2_client.list_snapshots_with_detail(
                version=version, params=params)['snapshots']

        # verify keys
        expected_keys = [
            "status", "links", "share_id", "name", "share_proto", "created_at",
            "description", "id", "share_size", "size"
        ]
        if version and utils.is_microversion_ge(version, '2.17'):
            expected_keys.extend(["user_id", "project_id"])

        # strict key check
        [self.assertEqual(set(expected_keys), set(s.keys())) for s in snaps]

        # our share id in list and have no duplicates
        gen = [sid["id"] for sid in snaps if sid["id"] in self.snap["id"]]
        msg = "expected id lists %s times in share list" % (len(gen))
        self.assertEqual(1, len(gen), msg)
    def skip_checks(cls):
        super(ReplicationActionsTest, cls).skip_checks()
        if not CONF.share.run_replication_tests:
            raise cls.skipException('Replication tests are disabled.')

        utils.check_skip_if_microversion_not_supported(
            _MIN_SUPPORTED_MICROVERSION)
    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)
        waiters.wait_for_resource_status(self.admin_client,
                                         replica['id'],
                                         constants.REPLICATION_STATE_IN_SYNC,
                                         resource_name='share_replica',
                                         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,
            version=version)
        waiters.wait_for_resource_status(
            self.admin_client,
            replica['id'],
            constants.REPLICATION_STATE_OUT_OF_SYNC,
            resource_name='share_replica',
            status_attr='replica_state')

        # Attempt resync
        self.admin_client.resync_share_replica(replica['id'], version=version)
        waiters.wait_for_resource_status(self.admin_client,
                                         replica['id'],
                                         constants.REPLICATION_STATE_IN_SYNC,
                                         resource_name='share_replica',
                                         status_attr='replica_state')
Esempio n. 9
0
    def test_create_share_group_with_single_share_type_min(self, version):
        utils.check_skip_if_microversion_not_supported(version)
        share_group = self.create_share_group(
            share_group_type_id=self.sg_type_id,
            cleanup_in_class=False,
            share_type_ids=[self.share_type_id],
            version=version)

        keys = set(share_group.keys())
        self.assertTrue(
            constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS.issubset(keys),
            'At least one expected element missing from share group '
            'response. Expected %(expected)s, got %(actual)s.' % {
                "expected": constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS,
                "actual": keys
            })

        actual_sg_type = share_group['share_group_type_id']
        expected_sg_type = self.sg_type_id
        self.assertEqual(
            expected_sg_type, actual_sg_type,
            'Incorrect share group type applied to share group '
            '%s. Expected %s, got %s' %
            (share_group['id'], expected_sg_type, actual_sg_type))

        actual_share_types = share_group['share_types']
        expected_share_types = [self.share_type_id]
        self.assertEqual(
            sorted(expected_share_types), sorted(actual_share_types),
            'Incorrect share types applied to share group %s. '
            'Expected %s, got %s' %
            (share_group['id'], expected_share_types, actual_share_types))
Esempio n. 10
0
    def test_manage_different_versions(self, version):
        """Run snapshot manage test for multiple versions.

        This test is configured with ddt to run for the configured maximum
        version as well as versions 2.12 (when the API was introduced) and
        2.16.
        """
        utils.skip_if_manage_not_supported_for_version(version)

        # Skip in case specified version is not supported
        utils.check_skip_if_microversion_not_supported(version)

        snap_name = data_utils.rand_name("tempest-snapshot-name")
        snap_desc = data_utils.rand_name("tempest-snapshot-description")
        # Create snapshot
        snapshot = self.create_snapshot_wait_for_active(
            self.share['id'], snap_name, snap_desc)
        snapshot = self.shares_v2_client.get_snapshot(
            snapshot['id'])['snapshot']
        # Unmanage snapshot
        self.shares_v2_client.unmanage_snapshot(snapshot['id'],
                                                version=version)
        self.shares_client.wait_for_resource_deletion(
            snapshot_id=snapshot['id'])

        # Manage snapshot
        self._test_manage(snapshot=snapshot, version=version)
Esempio n. 11
0
    def test_default_share_group_type_applied(self, version):
        utils.check_skip_if_microversion_not_supported(version)
        try:
            default_type = self.shares_v2_client.get_default_share_group_type(
                version=version)['share_group_type']
        except exceptions.NotFound:
            msg = "There is no default share group type"
            raise self.skipException(msg)
        default_share_types = default_type['share_types']

        share_group = self.create_share_group(
            cleanup_in_class=False,
            share_type_ids=default_share_types,
            version=version)

        keys = set(share_group.keys())
        self.assertTrue(
            constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS.issubset(keys),
            'At least one expected element missing from share group '
            'response. Expected %(expected)s, got %(actual)s.' % {
                "expected": constants.SHARE_GROUP_DETAIL_REQUIRED_KEYS,
                "actual": keys
            })

        actual_sg_type = share_group['share_group_type_id']
        expected_sg_type = default_type['id']
        self.assertEqual(
            expected_sg_type, actual_sg_type,
            'Incorrect share group type applied to share group %s. '
            'Expected %s, got %s' %
            (share_group['id'], expected_sg_type, actual_sg_type))
Esempio n. 12
0
    def skip_checks(cls):
        super(SnapshotExportLocationsTest, cls).skip_checks()
        if not CONF.share.run_snapshot_tests:
            raise cls.skipException('Snapshot tests are disabled.')
        if not CONF.share.run_mount_snapshot_tests:
            raise cls.skipException('Mountable snapshots tests are disabled.')

        utils.check_skip_if_microversion_not_supported("2.32")
Esempio n. 13
0
    def skip_checks(cls):
        super(ManageShareServersNegativeTest, cls).skip_checks()
        if not CONF.share.multitenancy_enabled:
            raise cls.skipException('Multitenancy tests are disabled.')
        if not CONF.share.run_manage_unmanage_tests:
            raise cls.skipException('Manage/unmanage tests are disabled.')

        utils.check_skip_if_microversion_not_supported('2.49')
 def skip_checks(cls):
     super(ReplicaQuotasNegativeTest, cls).skip_checks()
     if not CONF.auth.use_dynamic_credentials:
         raise cls.skipException('Dynamic credentials are required')
     if not CONF.share.run_quota_tests:
         msg = "Quota tests are disabled."
         raise cls.skipException(msg)
     utils.check_skip_if_microversion_not_supported(
         SHARE_REPLICA_QUOTAS_MICROVERSION)
Esempio n. 15
0
 def skip_checks(cls):
     super(SharesSchedulerHintsAdminTest, cls).skip_checks()
     if not CONF.share.multi_backend:
         raise cls.skipException("Manila multi-backend tests are disabled.")
     elif len(CONF.share.backend_names) < 2:
         raise cls.skipException("For running multi-backend tests, two or "
                                 "more backend names must be configured.")
     elif any(not name for name in CONF.share.backend_names):
         raise cls.skipException("Share backend names can not be empty.")
     utils.check_skip_if_microversion_not_supported('2.67')
Esempio n. 16
0
    def skip_checks(cls):
        super(ReplicationActionsAdminTest, cls).skip_checks()
        if not CONF.share.run_replication_tests:
            raise cls.skipException('Replication tests are disabled.')
        if CONF.share.multitenancy_enabled:
            raise cls.skipException(
                'Only for driver_handles_share_servers = False driver mode.')

        utils.check_skip_if_microversion_not_supported(
            _MIN_SUPPORTED_MICROVERSION)
Esempio n. 17
0
 def skip_checks(cls):
     super(MigrationShareServerBase, cls).skip_checks()
     if cls.protocol not in CONF.share.enable_protocols:
         raise cls.skipException('%s tests are disabled.' % cls.protocol)
     if not CONF.share.multitenancy_enabled:
         raise cls.skipException('Multitenancy tests are disabled.')
     if not CONF.share.run_share_server_migration_tests:
         raise cls.skipException(
             'Share server migration tests are disabled.')
     utils.check_skip_if_microversion_not_supported('2.57')
 def test_try_delete_required_spec_snapshot_support_version(self, version):
     utils.check_skip_if_microversion_not_supported(version)
     st = self.create_share_type(extra_specs=self.extra_specs)
     # Try delete extra spec 'snapshot_support'
     self.assertRaises(
         lib_exc.Forbidden,
         self.admin_shares_v2_client.delete_share_type_extra_spec,
         st["id"],
         "snapshot_support",
         version=version)
 def skip_checks(cls):
     super(ShareSnapshotUserRulesForCIFSTest, cls).skip_checks()
     if not CONF.share.run_mount_snapshot_tests:
         raise cls.skipException('Mountable snapshots tests are disabled.')
     if not (cls.protocol in CONF.share.enable_protocols and cls.protocol
             in CONF.share.enable_user_rules_for_protocols):
         msg = ("User rule tests for %s protocol are "
                "disabled." % cls.protocol)
         raise cls.skipException(msg)
     utils.check_skip_if_microversion_not_supported('2.32')
    def test_create_share_group_from_populated_share_group_snapshot(
            self, version):
        utils.check_skip_if_microversion_not_supported(version)

        sg_snapshot = self.shares_v2_client.get_share_group_snapshot(
            self.sg_snapshot['id'],
            version=version,
        )['share_group_snapshot']
        snapshot_members = sg_snapshot['members']

        new_share_group = self.create_share_group(
            cleanup_in_class=False,
            source_share_group_snapshot_id=self.sg_snapshot['id'],
            version=version,
            share_group_type_id=self.share_group_type_id,
        )

        new_share_group = self.shares_v2_client.get_share_group(
            new_share_group['id'],
            version=version,
        )['share_group']

        # Verify that share_network information matches source share group
        self.assertEqual(self.share_group['share_network_id'],
                         new_share_group['share_network_id'])

        new_shares = self.shares_v2_client.list_shares(
            params={'share_group_id': new_share_group['id']},
            detailed=True,
            version=version,
        )['shares']

        # Verify each new share is available
        for share in new_shares:
            self.assertEqual(
                'available', share['status'],
                'Share %s is not in available status.' % share['id'])

        # Verify each sgsnapshot member is represented in the new sg
        # appropriately
        share_source_member_ids = [
            share['source_share_group_snapshot_member_id']
            for share in new_shares
        ]
        for member in snapshot_members:
            self.assertIn(
                member['id'], share_source_member_ids,
                'Share group snapshot member %s not represented by '
                'share group %s.' % (member['id'], new_share_group['id']))
            for share in new_shares:
                if (share['source_share_group_snapshot_member_id'] == (
                        member['id'])):
                    self.assertEqual(member['size'], share['size'])
                    self.assertEqual(self.share_group['share_network_id'],
                                     share['share_network_id'])
Esempio n. 21
0
 def skip_checks(cls):
     super(SharesSchedulerHintsNegativeTest, cls).skip_checks()
     if not CONF.share.multi_backend:
         raise cls.skipException("Manila multi-backend is disabled.")
     elif len(CONF.share.backend_names) < 2:
         raise cls.skipException("For running multi-backend tests required"
                                 " two names in config. Skipping.")
     elif any(not name for name in CONF.share.backend_names):
         raise cls.skipException("Share backend names can not be empty. "
                                 "Skipping.")
     utils.check_skip_if_microversion_not_supported('2.65')
Esempio n. 22
0
 def skip_checks(cls):
     super(SharesFromSnapshotAcrossPools, cls).skip_checks()
     if not CONF.share.capability_create_share_from_snapshot_support:
         raise cls.skipException(
             'Create share from snapshot tests are disabled.')
     if (not CONF.share.
             run_create_share_from_snapshot_in_another_pool_or_az_tests):
         raise cls.skipException(
             'Create share from snapshot in another pool or az tests are '
             'disabled.')
     utils.check_skip_if_microversion_not_supported("2.54")
Esempio n. 23
0
    def skip_checks(cls):
        super(ManageNFSSnapshotTest, cls).skip_checks()
        if not CONF.share.run_manage_unmanage_snapshot_tests:
            raise cls.skipException(
                'Manage/unmanage snapshot tests are disabled.')
        if cls.protocol not in CONF.share.enable_protocols:
            message = "%s tests are disabled" % cls.protocol
            raise cls.skipException(message)

        utils.check_skip_if_microversion_not_supported('2.12')
        utils.skip_if_manage_not_supported_for_version()
    def test_get_snapshot(self, version):

        # get snapshot
        if version is None:
            snapshot = self.shares_client.get_snapshot(
                self.snap["id"])['snapshot']
        else:
            utils.check_skip_if_microversion_not_supported(version)
            snapshot = self.shares_v2_client.get_snapshot(
                self.snap["id"], version=version)['snapshot']

        # verify keys
        expected_keys = [
            "status", "links", "share_id", "name", "share_proto", "created_at",
            "description", "id", "share_size", "size"
        ]
        if version and utils.is_microversion_ge(version, '2.17'):
            expected_keys.extend(["user_id", "project_id"])
        actual_keys = snapshot.keys()

        # strict key check
        self.assertEqual(set(expected_keys), set(actual_keys))

        # verify data
        msg = "Expected name: '%s', actual name: '%s'" % (self.snap_name,
                                                          snapshot["name"])
        self.assertEqual(self.snap_name, snapshot["name"], msg)

        msg = ("Expected description: '%s' actual description: '%s'" %
               (self.snap_desc, snapshot["description"]))
        self.assertEqual(self.snap_desc, snapshot["description"], msg)

        msg = ("Expected share_id: '%s', actual share_id: '%s'" %
               (self.shares[0]["id"], snapshot["share_id"]))
        self.assertEqual(self.shares[0]["id"], snapshot["share_id"], msg)

        # Verify that the user_id and project_id are same as the one for
        # the base share
        if version and utils.is_microversion_ge(version, '2.17'):
            msg = ("Expected %(key)s in snapshot: '%(expected)s', "
                   "actual %(key)s in snapshot: '%(actual)s'")
            self.assertEqual(
                self.shares[0]['user_id'], snapshot['user_id'], msg % {
                    'expected': self.shares[0]['user_id'],
                    'actual': snapshot['user_id'],
                    'key': 'user_id'
                })
            self.assertEqual(
                self.shares[0]['project_id'], snapshot['project_id'], msg % {
                    'expected': self.shares[0]['project_id'],
                    'actual': snapshot['project_id'],
                    'key': 'project_id'
                })
Esempio n. 25
0
 def skip_checks(cls):
     super(ShareServerMultipleSubnetTest, cls).skip_checks()
     if not CONF.share.multitenancy_enabled:
         raise cls.skipException('Multitenancy tests are disabled.')
     if not CONF.share.run_share_server_multiple_subnet_tests and not (
             CONF.share.run_network_allocation_update_tests):
         raise cls.skipException(
             'Share server multiple subnets and network allocation '
             'update tests are disabled.')
     if CONF.share.share_network_id != "":
         raise cls.skipException(
             'These tests are not suitable for pre-existing '
             'share_network.')
     utils.check_skip_if_microversion_not_supported("2.70")
    def test_replicated_share_export_locations(self, version):
        """Test behavior changes in the share export locations API at 2.47"""
        utils.check_skip_if_microversion_not_supported(version)
        share, replica, primary_replica_exports, replica_exports = (
            self._create_share_and_replica_get_exports()
        )

        # Share export locations list API
        share_exports = self.shares_v2_client.list_share_export_locations(
            share['id'], version=version)['export_locations']

        self._validate_export_location_api_behavior(replica, replica_exports,
                                                    primary_replica_exports,
                                                    share_exports, version)
Esempio n. 27
0
    def skip_checks(cls):
        super(RevertToSnapshotNegativeTest, cls).skip_checks()
        if not CONF.share.run_revert_to_snapshot_tests:
            msg = "Revert to snapshot tests are disabled."
            raise cls.skipException(msg)
        if not CONF.share.capability_snapshot_support:
            msg = "Snapshot support is disabled."
            raise cls.skipException(msg)
        if not CONF.share.run_snapshot_tests:
            msg = "Snapshot tests are disabled."
            raise cls.skipException(msg)

        utils.check_skip_if_microversion_not_supported(
            constants.REVERT_TO_SNAPSHOT_MICROVERSION)
    def skip_checks(cls):
        super(AccessRulesMetadataTest, cls).skip_checks()
        if not (any(p in CONF.share.enable_ip_rules_for_protocols
                    for p in cls.protocols)
                or any(p in CONF.share.enable_user_rules_for_protocols
                       for p in cls.protocols)
                or any(p in CONF.share.enable_cert_rules_for_protocols
                       for p in cls.protocols)
                or any(p in CONF.share.enable_cephx_rules_for_protocols
                       for p in cls.protocols)):
            cls.message = "Rule tests are disabled"
            raise cls.skipException(cls.message)

        utils.check_skip_if_microversion_not_supported(
            constants.MIN_SHARE_ACCESS_METADATA_MICROVERSION)
 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)
     self.admin_client.reset_share_replica_status(replica['id'],
                                                  constants.STATUS_ERROR,
                                                  version=version)
     waiters.wait_for_resource_status(self.admin_client,
                                      replica['id'],
                                      constants.STATUS_ERROR,
                                      resource_name='share_replica')
 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)
     self.admin_client.reset_share_replica_status(
         replica['id'], constants.STATUS_ERROR_DELETING, version=version)
     waiters.wait_for_resource_status(self.admin_client,
                                      replica['id'],
                                      constants.STATUS_ERROR_DELETING,
                                      resource_name='share_replica')
     self.admin_client.force_delete_share_replica(replica['id'],
                                                  version=version)
     self.admin_client.wait_for_resource_deletion(replica_id=replica['id'])