def test_sync_single_file_to_file(self):
        content_file_name_src = "test_1kb_file_sync_src.txt"
        content_file_path_src = util.create_test_file(content_file_name_src,
                                                      1024)
        content_file_name_dst = "test_1kb_file_sync_dst.txt"
        content_file_path_dst = util.create_test_file(content_file_name_src,
                                                      1024)

        # create source and destination files of size 1KB.
        # make sure to create the destination first so that it has an older lmt
        remote_src_file_path = util.get_resource_sas_from_share(
            content_file_name_src)
        remote_dst_file_path = util.get_resource_sas_from_share(
            content_file_name_dst)
        result = util.Command("cp").add_arguments(content_file_path_dst).add_arguments(remote_dst_file_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)
        result = util.Command("cp").add_arguments(content_file_path_src).add_arguments(remote_src_file_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # perform the single file sync using azcopy.
        result = util.Command("sync").add_arguments(remote_src_file_path).add_arguments(remote_dst_file_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # verifying the sync worked, both remote source and destination should be identical to the local source
        result = util.Command("testFile").add_arguments(
            content_file_path_src).add_arguments(
                remote_src_file_path).execute_azcopy_verify()
        self.assertTrue(result)
        result = util.Command("testFile").add_arguments(
            content_file_path_src).add_arguments(
                remote_dst_file_path).execute_azcopy_verify()
        self.assertTrue(result)
Exemple #2
0
    def test_sync_single_blob_with_local(self):
        # create file of size 1KB.
        filename = "test_1kb_blob_sync.txt"
        file_path = util.create_test_file(filename, 1024)
        blob_path = util.get_resource_sas(filename)

        # Upload 1KB file using azcopy.
        src = file_path
        dest = blob_path
        result = util.Command("cp").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob.
        # the resource local path should be the first argument for the azcopy validator.
        # the resource sas should be the second argument for azcopy validator.
        resource_url = util.get_resource_sas(filename)
        result = util.Command("testBlob").add_arguments(file_path).add_arguments(resource_url).execute_azcopy_verify()
        self.assertTrue(result)

        # Sync 1KB file to local using azcopy.
        src = blob_path
        dest = file_path
        result = util.Command("sync").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Sync 1KB file to blob using azcopy.
        # reset local file lmt first
        util.create_test_file(filename, 1024)
        src = file_path
        dest = blob_path
        result = util.Command("sync").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)
    def test_set_block_blob_tier(self):
        # create a file file_hot_block_blob_tier
        filename = "test_hot_block_blob_tier.txt"
        file_path = util.create_test_file(filename, 10 * 1024)

        # uploading the file file_hot_block_blob_tier using azcopy and setting the block-blob-tier to Hot
        destination_sas = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas). \
            add_flags("log-level", "info").add_flags("block-blob-tier", "Hot").execute_azcopy_copy_command()
        self.assertTrue(result)
        # execute azcopy validate order.
        # added the expected blob-tier "Hot"
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(destination_sas).add_flags(
                "blob-tier", "Hot").execute_azcopy_verify()
        self.assertTrue(result)

        # create file to upload with block blob tier set to "Cool".
        filename = "test_cool_block_blob_tier.txt"
        file_path = util.create_test_file(filename, 10 * 1024)

        # uploading the file file_cool_block_blob_tier using azcopy and setting the block-blob-tier to Cool.
        destination_sas = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas). \
            add_flags("log-level", "info").add_flags("block-blob-tier", "Cool").execute_azcopy_copy_command()
        self.assertTrue(result)

        # execute azcopy validate order.
        # added the expected blob-tier "Cool"
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(destination_sas).add_flags(
                "blob-tier", "Cool").execute_azcopy_verify()
        self.assertTrue(result)

        # create file to upload with block blob tier set to "Archive".
        filename = "test_archive_block_blob_tier.txt"
        file_path = util.create_test_file(filename, 10 * 1024)

        # uploading the file file_archive_block_blob_tier using azcopy and setting the block-blob-tier to Archive.
        destination_sas = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas). \
            add_flags("log-level", "info").add_flags("block-blob-tier", "archive").execute_azcopy_copy_command()
        self.assertTrue(result)

        # execute azcopy validate order.
        # added the expected blob-tier "Archive"
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(destination_sas).add_flags(
                "blob-tier", "Archive").execute_azcopy_verify()
        self.assertTrue(result)
Exemple #4
0
    def test_copy_single_file_to_file(self):
        content_file_name_src = "test_1kb_file_copy_src.txt"
        content_file_path_src = util.create_test_file(content_file_name_src,
                                                      1024)
        content_file_name_dst = "test_1kb_file_copy_dst.txt"

        # create source file of size 1KB.
        remote_src_file_path = util.get_resource_sas_from_share(
            content_file_name_src)
        remote_dst_file_path = util.get_resource_sas_from_share(
            content_file_name_dst)
        result = util.Command("cp").add_arguments(content_file_path_src).add_arguments(remote_src_file_path). \
            add_flags("log-level", "debug").execute_azcopy_copy_command()
        self.assertTrue(result)

        # perform the single file copy using azcopy.
        result = util.Command("copy").add_arguments(remote_src_file_path).add_arguments(remote_dst_file_path). \
            add_flags("log-level", "debug").execute_azcopy_copy_command()
        self.assertTrue(result)

        # verifying the copy worked, both remote source and destination should be identical to the local source
        result = util.Command("testFile").add_arguments(
            content_file_path_src).add_arguments(
                remote_src_file_path).execute_azcopy_verify()
        self.assertTrue(result)
        result = util.Command("testFile").add_arguments(
            content_file_path_src).add_arguments(
                remote_dst_file_path).execute_azcopy_verify()
        self.assertTrue(result)
    def test_piping_upload_and_download_large_file(self):
        # large means azcopy has to rotate buffers when uploading.

        # create file of size 8MB
        filename = "test_8mb_blob_piping_upload.txt"
        source_file_path = util.create_test_file(filename, 8 * 1024 * 1024)

        # compute source md5 to compare later
        source_file_md5 = compute_md5(source_file_path)

        # uploadfile using azcopy
        # TODO reviewers please note, this used to use a 4MB file, with a 1 KiB block size, but now we don't support block sizes
        #    smaller than 1 MB. I've compensated slightly by changing it to an 8 MB file
        destination_url = util.get_resource_sas(filename)
        azcopy_cmd = util.Command("copy").add_arguments(destination_url).add_flags("block-size-mb", '1').add_flags("from-to", "PipeBlob").string()
        self.assertTrue(execute_command_with_pipe(azcopy_cmd, source_file_to_pipe=source_file_path))

        # downloading the uploaded file
        azcopy_cmd = util.Command("copy").add_arguments(destination_url).add_flags("block-size-mb", '1').add_flags("from-to", "BlobPipe").string()
        destination_file_path = util.test_directory_path + "/test_8mb_blob_piping_download.txt"
        self.assertTrue(execute_command_with_pipe(azcopy_cmd, destination_file_to_pipe=destination_file_path))

        # compute destination md5 to compare
        destination_file_md5 = compute_md5(destination_file_path)

        # verifying the downloaded blob
        self.assertEqual(source_file_md5, destination_file_md5)
    def util_test_blobfs_download_1Kb_file(self, explictFromTo=False):
        # create file of size 1KB
        filename = "test_blob_d_1kb_file.txt"
        file_path = util.create_test_file(filename, 1024)
        # upload the file using Azcopy
        cmd = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_account_url). \
            add_flags("log-level", "Info")
        util.process_oauth_command(cmd, "LocalBlobFS" if explictFromTo else "")
        result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the file uploaded file
        fileUrl = util.test_bfs_account_url + filename
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(fileUrl).execute_azcopy_verify()
        self.assertTrue(result)

        # delete the file locally
        try:
            os.remove(file_path)
        except:
            self.fail('error deleting the file ' + file_path)

        # download the file using Azcopy
        cmd = util.Command("copy").add_arguments(fileUrl).add_arguments(util.test_directory_path). \
            add_flags("log-level", "Info")
        util.process_oauth_command(cmd, "BlobFSLocal" if explictFromTo else "")
        result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # validate the downloaded file
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(fileUrl).execute_azcopy_verify()
        self.assertTrue(result)
Exemple #7
0
    def test_piping_upload_and_download_large_file(self):
        # large means azcopy has to rotate buffers when uploading.

        # create file of size 4MB
        filename = "test_4mb_blob_piping_upload.txt"
        source_file_path = util.create_test_file(filename, 4 * 1024 * 1024)

        # compute source md5 to compare later
        source_file_md5 = compute_md5(source_file_path)

        # upload 1KB file using azcopy
        destination_url = util.get_resource_sas(filename)
        azcopy_cmd = util.Command("copy").add_arguments(
            destination_url).add_flags("block-size", '1024').string()
        self.assertTrue(
            execute_command_with_pipe(azcopy_cmd,
                                      source_file_to_pipe=source_file_path))

        # downloading the uploaded file
        destination_file_path = util.test_directory_path + "/test_1kb_blob_piping_download.txt"
        self.assertTrue(
            execute_command_with_pipe(
                azcopy_cmd, destination_file_to_pipe=destination_file_path))

        # compute destination md5 to compare
        destination_file_md5 = compute_md5(destination_file_path)

        # verifying the downloaded blob
        self.assertEqual(source_file_md5, destination_file_md5)
Exemple #8
0
    def test_sync_single_blob_to_blob(self):
        content_file_name = "test_1kb_blob_sync.txt"
        content_file_path = util.create_test_file(content_file_name, 1024)

        # create source and destination blobs of size 1KB.
        # make sure to create the destination first so that it has an older lmt
        src_blob_path = util.get_resource_sas("test_1kb_blob_sync_src.txt")
        dst_blob_path = util.get_resource_sas("test_1kb_blob_sync_dst.txt")
        result = util.Command("cp").add_arguments(content_file_path).add_arguments(dst_blob_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)
        result = util.Command("cp").add_arguments(content_file_path).add_arguments(src_blob_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # verifying the uploaded blobs.
        # the resource local path should be the first argument for the azcopy validator.
        # the resource sas should be the second argument for azcopy validator.
        result = util.Command("testBlob").add_arguments(content_file_path).add_arguments(src_blob_path).execute_azcopy_verify()
        self.assertTrue(result)
        result = util.Command("testBlob").add_arguments(content_file_path).add_arguments(dst_blob_path).execute_azcopy_verify()
        self.assertTrue(result)

        # perform the single blob sync using azcopy.
        result = util.Command("sync").add_arguments(src_blob_path).add_arguments(dst_blob_path). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)
    def util_test_1kb_blob_upload(self, use_oauth_session=False):
        # Creating a single File Of size 1 KB
        filename = "test1KB.txt"
        file_path = util.create_test_file(filename, 1024)

        # executing the azcopy command to upload the 1KB file.
        src = file_path
        if not use_oauth_session:
            dest = util.get_resource_sas(filename)
            dest_validate = dest
        else:
            dest = util.get_resource_from_oauth_container(filename)
            dest_validate = util.get_resource_from_oauth_container_validate(
                filename)

        result = util.Command("copy").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob.
        # the resource local path should be the first argument for the azcopy validator.
        # the resource sas should be the second argument for azcopy validator.
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(dest_validate).execute_azcopy_verify()
        self.assertTrue(result)
    def util_test_1GB_blob_upload(self, use_oauth_session=False):
        # create 1Gb file
        filename = "test_1G_blob.txt"
        file_path = util.create_test_file(filename, 1 * 1024 * 1024 * 1024)

        # execute azcopy upload.
        if not use_oauth_session:
            dest = util.get_resource_sas(filename)
            dest_validate = dest
        else:
            dest = util.get_resource_from_oauth_container(filename)
            dest_validate = util.get_resource_from_oauth_container_validate(
                filename)

        result = util.Command("copy").add_arguments(file_path).add_arguments(dest).add_flags("log-level", "info"). \
            add_flags("block-size", "104857600").add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob.
        # adding local file path as first argument.
        # adding file sas as local argument.
        # calling the testBlob validator to verify whether blob has been successfully uploaded or not.
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(dest_validate).execute_azcopy_verify()
        self.assertTrue(result)
    def util_test_download_1kb_blob_with_oauth(self):
        # create file of size 1KB.
        filename = "test_1kb_blob_upload.txt"
        file_path = util.create_test_file(filename, 1024)

        # Upload 1KB file using azcopy.
        src = file_path
        dest = util.test_oauth_container_url
        cmd = util.Command("copy").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").add_flags("recursive", "true")
        util.process_oauth_command(cmd, "")
        result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob.
        # the resource local path should be the first argument for the azcopy validator.
        # the resource sas should be the second argument for azcopy validator.
        dest_validate = util.get_resource_from_oauth_container_validate(filename)
        result = util.Command("testBlob").add_arguments(file_path).add_arguments(dest_validate).execute_azcopy_verify()
        self.assertTrue(result)

        # downloading the uploaded file
        src = util.get_resource_from_oauth_container(filename)
        src_validate = util.get_resource_from_oauth_container_validate(filename)
        dest = util.test_directory_path + "/test_1kb_blob_download.txt"
        cmd = util.Command("copy").add_arguments(src).add_arguments(dest).add_flags("log-level", "info")
        util.process_oauth_command(cmd, "")
        result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the downloaded blob
        result = util.Command("testBlob").add_arguments(dest).add_arguments(src_validate).execute_azcopy_verify()
        self.assertTrue(result)
    def test_blobfs_sas_download_64MB_file(self):
        # Create file of size 1KB
        filename = "test_blobfs_sas_d_64MB_file.txt"
        file_path = util.create_test_file(filename, 64 * 1024 * 1024)
        # Upload the file using azCopy
        result = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_sas_account_url). \
            add_flags("log-level", "Info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the uploaded file
        file_url = util.get_resource_sas_from_bfs(filename)
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(file_url).execute_azcopy_verify()
        self.assertTrue(result)

        # Delete the local file
        try:
            os.remove(file_path)
        except:
            self.fail('error deleting the file ' + file_path)

        # Download the file using AzCopy
        result = util.Command("copy").add_arguments(file_url).add_arguments(util.test_directory_path). \
            add_flags("log-level", "Info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the downloaded file
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(file_url).execute_azcopy_verify()
        self.assertTrue(result)
    def test_blob_download_63mb_in_4mb(self):
        # create file of 63mb
        file_name = "test_63mb_in4mb_upload.txt"
        file_path = util.create_test_file(file_name, 63 * 1024 * 1024)

        # uploading file through azcopy with flag block-size set to 4194304 i.e 4mb
        destination_sas = util.get_resource_sas(file_name)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas).\
                    add_flags("log-level","info").add_flags("block-size", "4194304").execute_azcopy_copy_command()
        self.assertTrue(result)

        # verify the uploaded file.
        result = util.Command("testBlob").add_arguments(file_path).add_arguments(destination_sas).execute_azcopy_verify()
        self.assertTrue(result)

        # downloading the created parallely in blocks of 4mb file through azcopy.
        download_file = util.test_directory_path + "/test_63mb_in4mb_download.txt"
        result = util.Command("copy").add_arguments(destination_sas).add_arguments(download_file)\
                    .add_flags("log-level","info").add_flags("block-size", "4194304").execute_azcopy_copy_command()
        self.assertTrue(result)

        # verify the downloaded file
        result = util.Command("testBlob").add_arguments(download_file).add_arguments(
            destination_sas).execute_azcopy_verify()
        self.assertTrue(result)
    def test_blob_download_preserve_last_modified_time(self):
        # create a file of 2KB
        filename = "test_upload_preserve_last_mtime.txt"
        file_path = util.create_test_file(filename, 2048)

        # upload file through azcopy.
        destination_sas = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas). \
            add_flags("log-level", "info").add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob
        result = util.Command("testBlob").add_arguments(file_path).add_arguments(destination_sas).execute_azcopy_verify()
        self.assertTrue(result)

        time.sleep(5)

        # download file through azcopy with flag preserve-last-modified-time set to true
        download_file_name = util.test_directory_path + "/test_download_preserve_last_mtime.txt"
        result = util.Command("copy").add_arguments(destination_sas).add_arguments(download_file_name)\
                    .add_flags("log-level","info").add_flags("preserve-last-modified-time", "true").\
                    execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the downloaded blob and its modified with the modified time of blob.
        result = util.Command("testBlob").add_arguments(download_file_name).add_arguments(destination_sas).add_flags(
            "preserve-last-modified-time", "true").execute_azcopy_verify()
        self.assertTrue(result)
Exemple #15
0
    def test_piping_upload_and_download_small_file(self):
        # small means azcopy doesn't have to rotate buffers when uploading.
        # it is assumed that the default block size is much larger than 1KB.

        # create file of size 1KB
        filename = "test_1kb_blob_piping_upload.txt"
        source_file_path = util.create_test_file(filename, 1024)

        # compute source md5 to compare later
        source_file_md5 = compute_md5(source_file_path)

        # upload 1KB file using azcopy
        destination_url = util.get_resource_sas(filename)
        azcopy_cmd = util.Command("copy").add_arguments(
            destination_url).add_flags("from-to", "PipeBlob").add_flags(
                "log-level", "DEBUG").string()
        self.assertTrue(
            execute_command_with_pipe(azcopy_cmd,
                                      source_file_to_pipe=source_file_path))

        # downloading the uploaded file
        azcopy_cmd = util.Command("copy").add_arguments(
            destination_url).add_flags("from-to", "BlobPipe").add_flags(
                "log-level", "DEBUG").string()
        destination_file_path = util.test_directory_path + "/test_1kb_blob_piping_download.txt"
        self.assertTrue(
            execute_command_with_pipe(
                azcopy_cmd, destination_file_to_pipe=destination_file_path))

        # compute destination md5 to compare
        destination_file_md5 = compute_md5(destination_file_path)

        # verifying the downloaded blob
        self.assertEqual(source_file_md5, destination_file_md5)
Exemple #16
0
    def test_upload_download_1kb_file_fullname(self):
        # create file of size 1KB.
        filename = "test_upload_download_1kb_file_fullname.txt"
        file_path = util.create_test_file(filename, 1024)

        # Upload 1KB file using azcopy.
        src = file_path
        dest = util.test_share_url
        result = util.Command("copy").add_arguments(src).add_arguments(dest). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded file.
        # the resource local path should be the first argument for the azcopy validator.
        # the resource sas should be the second argument for azcopy validator.
        resource_url = util.get_resource_sas_from_share(filename)
        result = util.Command("testFile").add_arguments(file_path).add_arguments(resource_url).execute_azcopy_verify()
        self.assertTrue(result)

        time.sleep(5)

        # downloading the uploaded file
        src = util.get_resource_sas_from_share(filename)
        dest = util.test_directory_path + "/test_1kb_file_download.txt"
        result = util.Command("copy").add_arguments(src).add_arguments(dest).add_flags("log-level",
                                                                                       "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the downloaded file
        result = util.Command("testFile").add_arguments(dest).add_arguments(src).execute_azcopy_verify()
        self.assertTrue(result)
def test_blobfs_upload_1Kb_file(
    explictFromTo=False,
    forceOAuthLogin=False,
    tenantID="",
    aadEndpoint=""):
    # create file of size 1KB
    filename = "test_blob_1kb_file.txt"
    file_path = util.create_test_file(filename, 1024)
    # upload the file using Azcopy
    cmd = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_account_url). \
        add_flags("log-level", "Info")
    util.process_oauth_command(
        cmd,
        "LocalBlobFS" if explictFromTo else "",
        forceOAuthLogin,
        tenantID,
        aadEndpoint)
    if forceOAuthLogin:
        result = cmd.execute_azcopy_command_interactive()
    else:
        result = cmd.execute_azcopy_copy_command()
    if not result:
        print("test_blobfs_upload_1Kb_file failed uploading the 1kb file ", filename, " to the filesystem")
        sys.exit(1)
    # Validate the file uploaded file
    fileUrl = util.test_bfs_account_url + filename
    result = util.Command("testBlobFS").add_arguments(file_path).add_arguments(fileUrl).execute_azcopy_verify()
    if not result:
        print("test_blobfs_upload_1Kb_file failed while validating the 1kb file upload")
        sys.exit(1)
    print("test_blobfs_upload_1Kb_file successfully passed")
    def test_block_size(self):

        block_size = 4 * 1024 * 1024
        # create file of size 63 Mb
        filename = "test63Mb_blob.txt"
        file_path = util.create_test_file(filename, 63 * 1024 * 1024)

        # execute azcopy upload of 63 Mb file.
        destination_sas = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas).add_flags("log-level", "info"). \
            add_flags("block-size", str(block_size)).add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob
        # calling the testBlob validator to verify whether blob has been successfully uploaded or not
        if (63 * 1024 * 1024) % block_size == 0:
            number_of_blocks = int(63 * 1024 * 1024 / block_size)
        else:
            number_of_blocks = int(63 * 1024 * 1024 / block_size) + 1
        result = util.Command("testBlob").add_arguments(
            file_path).add_arguments(destination_sas).add_flags(
                "verify-block-size", "true").add_flags(
                    "number-blocks-or-pages",
                    str(number_of_blocks)).execute_azcopy_verify()
        self.assertTrue(result)
def test_download_1kb_blob_oauth(forceOAuthLogin=False,
                                 tenantID="",
                                 aadEndpoint=""):
    # create file of size 1KB.
    filename = "test_1kb_blob_upload.txt"
    file_path = util.create_test_file(filename, 1024)

    # Upload 1KB file using azcopy.
    src = file_path
    dest = util.test_oauth_container_url
    cmd = util.Command("copy").add_arguments(src).add_arguments(dest). \
        add_flags("log-level", "info").add_flags("recursive", "true")
    util.process_oauth_command(cmd, "", forceOAuthLogin, tenantID, aadEndpoint)
    if forceOAuthLogin:
        result = cmd.execute_azcopy_command_interactive()
    else:
        result = cmd.execute_azcopy_copy_command()
    if not result:
        print("failed uploading 1KB file to the container")
        return

    # Verifying the uploaded blob.
    # the resource local path should be the first argument for the azcopy validator.
    # the resource sas should be the second argument for azcopy validator.
    dest_validate = util.get_resource_from_oauth_container_validate(filename)
    result = util.Command("testBlob").add_arguments(file_path).add_arguments(
        dest_validate).execute_azcopy_verify()
    if not result:
        print("test_1kb_file test failed")
        return

    time.sleep(5)

    # downloading the uploaded file
    src = util.get_resource_from_oauth_container(filename)
    src_validate = util.get_resource_from_oauth_container_validate(filename)
    dest = util.test_directory_path + "/test_1kb_blob_download.txt"
    cmd = util.Command("copy").add_arguments(src).add_arguments(
        dest).add_flags("log-level", "info")
    util.process_oauth_command(cmd, "", forceOAuthLogin, tenantID, aadEndpoint)
    if forceOAuthLogin:
        result = cmd.execute_azcopy_command_interactive()
    else:
        result = cmd.execute_azcopy_copy_command()
    if not result:
        print("test_download_1kb_blob test case failed")
        return

    # Verifying the downloaded blob
    result = util.Command("testBlob").add_arguments(dest).add_arguments(
        src_validate).execute_azcopy_verify()
    if not result:
        print("test_download_1kb_blob test case failed")
        return

    print("test_download_1kb_blob successfully passed")
Exemple #20
0
    def util_test_copy_file_from_x_bucket_to_x_bucket_wildcard(
            self,
            srcBucketURL,
            srcType,
            dstBucketURL,
            dstType,
            recursive=True):
        # create source bucket
        result = util.Command("create").add_arguments(srcBucketURL).add_flags("serviceType", srcType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()
        self.assertTrue(result)

        # create file.
        filename = "copy_wildcard_file.txt"
        file_path = util.create_test_file(filename, 1)
        srcFileURL = util.get_object_sas(srcBucketURL, filename)
        srcFileWildcardURL = srcFileURL.replace(filename, "*")

        # Upload file using azcopy.
        # TODO: Note for S3/Google need special logic
        result = util.Command("copy").add_arguments(file_path).add_arguments(srcFileURL). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Copy file using azcopy from srcURL to destURL
        if recursive:
            result = util.Command("copy").add_arguments(srcFileWildcardURL).add_arguments(dstBucketURL). \
                add_flags("log-level", "info").add_flags("recursive", "true").execute_azcopy_copy_command()
        else:
            result = util.Command("copy").add_arguments(srcFileWildcardURL).add_arguments(dstBucketURL). \
                add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Downloading the copied files for validation
        validate_dir_name = "validate_copy_file_from_%s_bucket_to_%s_bucket_wildcard_recursive_%s" % (
            srcType, dstType, recursive)
        local_validate_dest = util.create_test_dir(validate_dir_name)
        dst_file_url = util.get_object_sas(dstBucketURL, filename)
        result = util.Command("copy").add_arguments(dst_file_url).add_arguments(local_validate_dest). \
            add_flags("log-level", "info").add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the downloaded file
        result = filecmp.cmp(file_path,
                             os.path.join(local_validate_dest, filename),
                             shallow=False)
        self.assertTrue(result)

        # clean up both source and destination bucket
        util.Command("clean").add_arguments(srcBucketURL).add_flags("serviceType", srcType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()

        util.Command("clean").add_arguments(dstBucketURL).add_flags("serviceType", dstType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()
Exemple #21
0
def test_blobfs_download_64MB_file(explictFromTo=False):
    # create test file of size 64MB
    filename = "test_blob_d_64MB_file.txt"
    file_path = util.create_test_file(filename, 64 * 1024 * 1024)
    # Upload the file using Azcopy
    cmd = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_account_url). \
        add_flags("log-level", "Info")
    util.process_oauth_command(cmd, "LocalBlobFS" if explictFromTo else "")
    result = cmd.execute_azcopy_copy_command()
    if not result:
        print("test_blobfs_download_64MB_file failed uploading the 64MB file ",
              filename, " to the filesystem")
        sys.exit(1)
    # Validate the file uploaded
    fileUrl = util.test_bfs_account_url + filename
    result = util.Command("testBlobFS").add_arguments(file_path).add_arguments(
        fileUrl).execute_azcopy_verify()
    if not result:
        print(
            "test_blobfs_download_64MB_file failed while validating the 64MB file upload"
        )
        sys.exit(1)

    # delete the file locally
    try:
        os.remove(file_path)
    except:
        print(
            "test_blobfs_download_64MB_file failed while deleting the file locally"
        )
        sys.exit(1)

    # download the file using azcopy
    cmd = util.Command("copy").add_arguments(fileUrl).add_arguments(util.test_directory_path). \
        add_flags("log-level", "Info")
    util.process_oauth_command(cmd, "BlobFSLocal" if explictFromTo else "")
    result = cmd.execute_azcopy_copy_command()
    if not result:
        print(
            "test_blobfs_download_64MB_file failed downloading the 64MB file ",
            filename)
        sys.exit(1)

    # validate the downloaded file
    result = util.Command("testBlobFS").add_arguments(file_path).add_arguments(
        fileUrl).execute_azcopy_verify()
    if not result:
        print(
            "test_blobfs_download_64MB_file failed while validating the 64MB downloaded file"
        )
        sys.exit(1)
    print("test_blobfs_download_64MB_file successfully passed")
Exemple #22
0
    def util_test_copy_single_file_from_x_to_x(self,
                                               srcBucketURL,
                                               srcType,
                                               dstBucketURL,
                                               dstType,
                                               sizeInKB=1,
                                               oAuth=False):
        # create source bucket
        result = util.Command("create").add_arguments(srcBucketURL).add_flags("serviceType", srcType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()
        self.assertTrue(result)

        # create file of size 1KB.
        filename = "test_" + str(sizeInKB) + "kb_copy.txt"
        file_path = util.create_test_file(filename, sizeInKB)
        srcFileURL = util.get_object_sas(srcBucketURL, filename)
        if oAuth:
            dstFileURL = util.get_object_without_sas(dstBucketURL, filename)
        else:
            dstFileURL = util.get_object_sas(dstBucketURL, filename)

        # Upload file using azcopy.
        # TODO: Note for S3/Google need special logic
        result = util.Command("copy").add_arguments(file_path).add_arguments(srcFileURL). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Copy file using azcopy from srcURL to destURL
        result = util.Command("copy").add_arguments(srcFileURL).add_arguments(dstFileURL). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Downloading the copied file for validation
        validate_dir_name = "validate_copy_single_%dKB_file_from_%s_to_%s" % (
            sizeInKB, srcType, dstType)
        local_validate_dest_dir = util.create_test_dir(validate_dir_name)
        local_validate_dest = local_validate_dest_dir + filename
        result = util.Command("copy").add_arguments(dstFileURL).add_arguments(local_validate_dest). \
            add_flags("log-level", "info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the downloaded blob
        result = filecmp.cmp(file_path, local_validate_dest, shallow=False)
        self.assertTrue(result)

        # clean up both source and destination bucket
        util.Command("clean").add_arguments(srcBucketURL).add_flags("serviceType", srcType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()

        util.Command("clean").add_arguments(dstBucketURL).add_flags("serviceType", dstType). \
            add_flags("resourceType", "Bucket").execute_azcopy_create()
    def test_blobfs_sas_upload_64MB_file(self):
        # Create file of size 1KB
        filename = "test_blobfs_sas_u_64MB_file.txt"
        file_path = util.create_test_file(filename, 64 * 1024 * 1024)
        # Upload the file using azCopy
        result = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_sas_account_url). \
            add_flags("log-level", "Info").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the uploaded file
        file_url = util.get_resource_sas_from_bfs(filename)
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(file_url).execute_azcopy_verify()
        self.assertTrue(result)
    def util_test_file_upload_size_n_fullname(self, sizeInBytes=1):
        # create the test file.
        file_name = "test_file_upload_%dB_fullname.vhd" % (sizeInBytes)
        file_path = util.create_test_file(file_name, sizeInBytes)

        # execute azcopy upload.
        destination = util.get_resource_sas_from_share(file_name)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination).add_flags("log-level", "debug"). \
            add_flags("block-size-mb", "4").execute_azcopy_copy_command()
        self.assertTrue(result)

        # execute validator.
        result = util.Command("testFile").add_arguments(file_path).add_arguments(destination).execute_azcopy_verify()
        self.assertTrue(result)
    def test_file_upload_1mb_fullname(self):
        # create the test file.
        file_name = "test_file_upload_1mb_fullname.vhd"
        file_path = util.create_test_file(file_name, 1024 * 1024)

        # execute azcopy upload.
        destination = util.get_resource_sas_from_share(file_name)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination).add_flags("log-level", "info"). \
            add_flags("block-size", "4194304").execute_azcopy_copy_command()
        self.assertTrue(result)

        # execute validator.
        result = util.Command("testFile").add_arguments(
            file_path).add_arguments(destination).execute_azcopy_verify()
        self.assertTrue(result)
    def test_file_upload_1mb_wildcard(self):
        # create the test file.
        file_name = "test_file_upload_1mb_wildcard.vhd"
        file_path = util.create_test_file(file_name, 1024 * 1024)

        # execute azcopy upload.
        destination = util.get_resource_sas_from_share(file_name)
        wildcard_path = file_path.replace(file_name, "test_file_upload_1mb_wildcard*")
        result = util.Command("copy").add_arguments(wildcard_path).add_arguments(util.test_share_url).add_flags("log-level", "info"). \
            add_flags("block-size-mb", "4").execute_azcopy_copy_command()
        self.assertTrue(result)

        # execute validator.
        result = util.Command("testFile").add_arguments(file_path).add_arguments(destination).execute_azcopy_verify()
        self.assertTrue(result)
    def util_test_blobfs_upload_64MB_file(self, explictFromTo=False):
        # create test file of size 64MB
        filename = "test_blob_64MB_file.txt"
        file_path = util.create_test_file(filename, 64 * 1024 * 1024)
        # Upload the file using Azcopy
        cmd = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_account_url). \
            add_flags("log-level", "Info")
        util.process_oauth_command(cmd, "LocalBlobFS" if explictFromTo else "")
        result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the file uploaded
        fileUrl = util.test_bfs_account_url + filename
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(fileUrl).execute_azcopy_verify()
        self.assertTrue(result)
    def test_63mb_blob_upload(self):
        # creating file of 63mb size.
        filename = "test63Mb_blob.txt"
        file_path = util.create_test_file(filename, 8 * 1024 * 1024)

        # execute azcopy copy upload.
        dest = util.get_resource_sas(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(dest) \
            .add_flags("log-level", "info").add_flags("block-size-mb", "100").add_flags("recursive", "true"). \
            execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded blob
        # calling the testBlob validator to verify whether blob has been successfully uploaded or not
        result = util.Command("testBlob").add_arguments(file_path).add_arguments(dest).execute_azcopy_verify()
        self.assertTrue(result)
    def util_test_blobfs_download_64MB_file(self,
                                            explictFromTo=False,
                                            forceOAuthLogin=False,
                                            tenantID="",
                                            aadEndpoint=""):
        # create test file of size 64MB
        filename = "test_blob_d_64MB_file.txt"
        file_path = util.create_test_file(filename, 64 * 1024 * 1024)
        # Upload the file using Azcopy
        cmd = util.Command("copy").add_arguments(file_path).add_arguments(util.test_bfs_account_url). \
            add_flags("log-level", "Info")
        util.process_oauth_command(cmd, "LocalBlobFS" if explictFromTo else "",
                                   forceOAuthLogin, tenantID, aadEndpoint)
        if forceOAuthLogin:
            result = cmd.execute_azcopy_command_interactive()
        else:
            result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # Validate the file uploaded
        fileUrl = util.test_bfs_account_url + filename
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(fileUrl).execute_azcopy_verify()
        self.assertTrue(result)

        # delete the file locally
        try:
            os.remove(file_path)
        except:
            self.fail('error deleting the file ' + file_path)

        # download the file using azcopy
        cmd = util.Command("copy").add_arguments(fileUrl).add_arguments(util.test_directory_path). \
            add_flags("log-level", "Info")
        util.process_oauth_command(cmd, "BlobFSLocal" if explictFromTo else "",
                                   forceOAuthLogin, tenantID, aadEndpoint)
        if forceOAuthLogin:
            result = cmd.execute_azcopy_command_interactive()
        else:
            result = cmd.execute_azcopy_copy_command()
        self.assertTrue(result)

        # validate the downloaded file
        result = util.Command("testBlobFS").add_arguments(
            file_path).add_arguments(fileUrl).execute_azcopy_verify()
        self.assertTrue(result)
    def test_1GB_file_upload(self):
        # create 1Gb file
        filename = "test_1G_file.txt"
        file_path = util.create_test_file(filename, 1 * 1024 * 1024 * 1024)

        # execute azcopy upload.
        destination_sas = util.get_resource_sas_from_share(filename)
        result = util.Command("copy").add_arguments(file_path).add_arguments(destination_sas).add_flags("log-level", "info"). \
            add_flags("block-size-mb", "100").add_flags("recursive", "true").execute_azcopy_copy_command()
        self.assertTrue(result)

        # Verifying the uploaded file.
        # adding local file path as first argument.
        # adding file sas as local argument.
        # calling the testFile validator to verify whether file has been successfully uploaded or not.
        result = util.Command("testFile").add_arguments(file_path).add_arguments(destination_sas).execute_azcopy_verify()
        self.assertTrue(result)