Skip to content

Commit

Permalink
[Storage][DataMovement] Fix Blob directory copy tests (Azure#48400)
Browse files Browse the repository at this point in the history
  • Loading branch information
jalauzon-msft authored Feb 24, 2025
1 parent 133784d commit 1a0cc96
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Blobs",
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_214325a4f9"
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_ad91d92591"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override Task CreateObjectInDestinationAsync(
string objectName = null,
Stream contents = null,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override Task CreateObjectInSourceAsync(
BlobContainerClient container,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override Task CreateObjectInSourceAsync(
Stream contents = null,
TransferPropertiesTestType propertiesTestType = TransferPropertiesTestType.Default,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient containerClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override Task CreateObjectInDestinationAsync(
string objectName = null,
Stream contents = null,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override Task CreateObjectInSourceAsync(
BlobContainerClient container,
Expand All @@ -40,7 +40,7 @@ protected override Task CreateObjectInSourceAsync(
Stream contents = null,
TransferPropertiesTestType propertiesType = default,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient containerClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override Task CreateObjectInSourceAsync(
Stream contents = null,
TransferPropertiesTestType propertiesTestType = TransferPropertiesTestType.Default,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient containerClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override Task CreateObjectInDestinationAsync(
string objectName = null,
Stream contents = null,
CancellationToken cancellationToken = default)
=> CreateBlockBlobAsync(container, objectName, contents, cancellationToken);
=> CreateBlockBlobAsync(container, objectLength, objectName, contents, cancellationToken);

protected override Task CreateObjectInSourceAsync(
BlobContainerClient container,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class StartTransferBlobDirectoryCopyTestBase<TSourceObjectClient
where TDestinationObjectClient : BlobBaseClient
{
private readonly AccessTier _defaultAccessTier = AccessTier.Cold;
private const string _defaultContentType = "text/plain";
private const string _defaultContentType = "image/jpeg";
private const string _defaultContentLanguage = "en-US";
private const string _defaultContentDisposition = "inline";
private const string _defaultCacheControl = "no-cache";
Expand Down Expand Up @@ -81,21 +81,22 @@ protected override Task CreateDirectoryInSourceAsync(

internal async Task CreateBlockBlobAsync(
BlobContainerClient container,
string blobName,
Stream contents,
long? objectLength = null,
string objectName = null,
Stream contents = null,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
blobName ??= GetNewObjectName();
objectName ??= GetNewObjectName();

BlockBlobClient blobClient = container.GetBlockBlobClient(blobName);
BlockBlobClient blobClient = container.GetBlockBlobClient(objectName);
if (contents != default)
{
await blobClient.UploadAsync(contents, cancellationToken: cancellationToken);
}
else
{
var data = new byte[0];
byte[] data = GetRandomBuffer(objectLength ?? 0);
using (var stream = new MemoryStream(data))
{
await blobClient.UploadAsync(
Expand Down Expand Up @@ -163,7 +164,7 @@ internal async Task CreateAppendBlobAsync(
}
else
{
var data = new byte[0];
byte[] data = GetRandomBuffer(objectLength ?? 0);
using (var stream = new MemoryStream(data))
{
await UploadAppendBlocksAsync(
Expand Down Expand Up @@ -222,7 +223,7 @@ internal async Task CreatePageBlobAsync(
}
else
{
var data = new byte[0];
byte[] data = GetRandomBuffer(objectLength ?? 0);
using (var stream = new MemoryStream(data))
{
await UploadPagesAsync(
Expand Down

0 comments on commit 1a0cc96

Please sign in to comment.