Ejemplo n.º 1
0
    def test_create_delete_recreate_scope(self):
        bucket_dict = BucketUtils.get_random_scopes(self.bucket_util.buckets,
                                                    "all", 1)
        # Delete scopes
        for bucket_name, scope_dict in bucket_dict.items():
            bucket = BucketUtils.get_bucket_obj(self.bucket_util.buckets,
                                                bucket_name)
            for scope_name, _ in scope_dict["scopes"].items():
                BucketUtils.drop_scope(self.cluster.master, bucket, scope_name)

        # Recreate scopes
        for bucket_name, scope_dict in bucket_dict.items():
            bucket = BucketUtils.get_bucket_obj(self.bucket_util.buckets,
                                                bucket_name)
            for scope_name, _ in scope_dict["scopes"].items():
                BucketUtils.create_scope(self.cluster.master, bucket,
                                         scope_name)
        # Validate doc count as per bucket collections
        self.bucket_util.validate_docs_per_collections_all_buckets()
        self.validate_test_failure()
Ejemplo n.º 2
0
    def test_create_delete_recreate_scope(self):
        scope_drop_fails = False
        bucket_dict = BucketUtils.get_random_scopes(self.bucket_util.buckets,
                                                    "all", 1)
        # Delete scopes
        for bucket_name, scope_dict in bucket_dict.items():
            bucket = BucketUtils.get_bucket_obj(self.bucket_util.buckets,
                                                bucket_name)
            for scope_name, _ in scope_dict["scopes"].items():
                if scope_name == CbServer.default_scope:
                    scope_drop_fails = True
                try:
                    BucketUtils.drop_scope(self.cluster.master, bucket,
                                           scope_name)
                    if scope_drop_fails:
                        raise Exception("default scope deleted")
                except Exception as drop_exception:
                    if scope_drop_fails \
                            and "delete_scope failed" in str(drop_exception):
                        pass
                    else:
                        raise drop_exception

        # Recreate scopes
        for bucket_name, scope_dict in bucket_dict.items():
            bucket = BucketUtils.get_bucket_obj(self.bucket_util.buckets,
                                                bucket_name)
            for scope_name, _ in scope_dict["scopes"].items():
                # Cannot create a _default scope
                if scope_name == CbServer.default_collection:
                    continue
                BucketUtils.create_scope(self.cluster.master, bucket,
                                         {"name": scope_name})
        # Validate doc count as per bucket collections
        self.bucket_util.validate_docs_per_collections_all_buckets()
        self.validate_test_failure()