Esempio n. 1
0
    def test_get_snapshot(self, version):

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

        # 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. 2
0
    def test_list_snapshots_with_detail(self, version):

        # list share snapshots
        if version is None:
            snaps = self.shares_client.list_snapshots_with_detail()
        else:
            utils.skip_if_microversion_not_supported(version)
            snaps = self.shares_v2_client.list_snapshots_with_detail(
                version=version)

        # 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)
Esempio n. 3
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.
        """
        # Skip in case specified version is not supported
        utils.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'])
        # 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)