def bucketSanity():

    ## Create five buckets
    dssSanityLib.whisper("Creating five test buckets and putting objects in them...")
    bucketpref = dssSanityLib.getsNewBucketName()
    dssSanityLib.createMaxBuckets(12, bucketpref)

    ## Bucket name conflict during creation
    #dssSanityLib.whisper("Trying to create a bucket with name conflict...")
    #userObj = dssSanityLib.getConnection(1) ## Different user
    #buck_str = bucketpref + '1'
    #try:
        #b = userObj.create_bucket(buck_str)
        #print "Error: Unexpectedly created bucket " + buck_str
        #return -1
    #except:
    #    print "Expected failure: " + str(sys.exc_info())

    ## Delete all buckets
    try:
        userObj = dssSanityLib.getConnection()
        dssSanityLib.whisper("Deleting the test buckets...")
        dssSanityLib.cleanupUser(userObj, bucketpref)
    except:
        print "Unexpected failure: " + str(sys.exc_info())
        return -1
    return 0
Exemple #2
0
def bucketSanity():

    ## Create five buckets
    dssSanityLib.whisper(
        "Creating five test buckets and putting objects in them...")
    bucketpref = dssSanityLib.getsNewBucketName()
    dssSanityLib.createMaxBuckets(12, bucketpref)

    ## Bucket name conflict during creation
    #dssSanityLib.whisper("Trying to create a bucket with name conflict...")
    #userObj = dssSanityLib.getConnection(1) ## Different user
    #buck_str = bucketpref + '1'
    #try:
    #b = userObj.create_bucket(buck_str)
    #print "Error: Unexpectedly created bucket " + buck_str
    #return -1
    #except:
    #    print "Expected failure: " + str(sys.exc_info())

    ## Delete all buckets
    try:
        userObj = dssSanityLib.getConnection()
        dssSanityLib.whisper("Deleting the test buckets...")
        dssSanityLib.cleanupUser(userObj, bucketpref)
    except:
        print "Unexpected failure: " + str(sys.exc_info())
        return -1
    return 0
Exemple #3
0
def createBucket(num, targ):
    pref = dssSanityLib.getsNewBucketName(targ)
    if (dssSanityLib.CLI_USER):
        userObj = dssSanityLib.getConnection(int(dssSanityLib.CLI_USER))
    else:
        userObj = dssSanityLib.getConnection()

    for i in range(1, int(num) + 1):
        buckname = pref + str(i)
        dssSanityLib.whisper("Creating bucket " + buckname)
        userObj.create_bucket(buckname)
    return
Exemple #4
0
def createBucket(num, targ):
    pref = dssSanityLib.getsNewBucketName(targ)
    if (dssSanityLib.CLI_USER):
        userObj = dssSanityLib.getConnection(int(dssSanityLib.CLI_USER))
    else:
        userObj = dssSanityLib.getConnection()

    for i in range(1, int(num) + 1):
        buckname = pref + str(i)
        dssSanityLib.whisper("Creating bucket " + buckname)
        userObj.create_bucket(buckname)
    return
def multipartObjectUpload():
    result = 0
    dssSanityLib.whisper("Making bucket and listing...")
    userObj = dssSanityLib.getConnection()
    bucketpref = dssSanityLib.getsNewBucketName()
    b = userObj.create_bucket(bucketpref)
    #dssSanityLib.listBucket(userObj, "User")

    source_path = dssSanityLib.MULTIPART_LARGE_FILE
    source_size = os.stat(source_path).st_size
    chunk_size = 5242880 ## 5 mb
    #chunk_size = 1048576  ## 1 mb
    chunk_count = int(math.ceil(source_size / float(chunk_size)))

    b1 = userObj.get_bucket(bucketpref)
    dssSanityLib.whisper("Got bucket: " + str(b1))
    try:
        mp = b1.initiate_multipart_upload(os.path.basename(source_path))
        for i in range(chunk_count):
            dssSanityLib.whisper("Uploading chunk: " + str(i))
            offset = chunk_size * i
            bytes = min(chunk_size, source_size - offset)
            with FileChunkIO(source_path, 'r', offset=offset, bytes=bytes) as fp:
                mp.upload_part_from_file(fp, part_num=i + 1)
        mp.complete_upload()
    except:
        print "Unexpected error during multipart upload: ", sys.exc_info()
        result = -1

    dssSanityLib.cleanupUser(userObj, bucketpref)
    return result
Exemple #6
0
def multipartObjectUpload():
    result = 0
    dssSanityLib.whisper("Making bucket and listing...")
    userObj = dssSanityLib.getConnection()
    bucketpref = dssSanityLib.getsNewBucketName()
    b = userObj.create_bucket(bucketpref)
    #b.set_acl('public-read-write')
    ##dssSanityLib.listBucket(userObj, "User")

    source_path = dssSanityLib.MULTIPART_LARGE_FILE
    source_size = os.stat(source_path).st_size
    chunk_size = 5242880  ## 5 mb
    #chunk_size = 1048576  ## 1 mb
    chunk_count = int(math.ceil(source_size / float(chunk_size)))

    b1 = userObj.get_bucket(bucketpref)
    dssSanityLib.whisper("Got bucket: " + str(b1))
    try:
        mp = b1.initiate_multipart_upload(os.path.basename(source_path))
        for i in range(chunk_count):
            dssSanityLib.whisper("Uploading chunk: " + str(i))
            offset = chunk_size * i
            bytes = min(chunk_size, source_size - offset)
            with FileChunkIO(source_path, 'r', offset=offset,
                             bytes=bytes) as fp:
                mp.upload_part_from_file(fp, part_num=i + 1)

        time.sleep(2)
        for i in b1.list_multipart_uploads():
            print "list_multipart_uploads: " + str(i)

        for i in b1.get_all_multipart_uploads():
            print "get_all_multipart_uploads: " + str(i)

        print("\n\nCompleting uploads")
        mp.complete_upload()
        #print("\n\nCancelling uploads")
        #mp.cancel_upload()

    except:
        print "Unexpected error during multipart upload: ", sys.exc_info()
        result = -1

    dssSanityLib.cleanupUser(userObj, bucketpref)
    return result