Skip to content

Commit

Permalink
[Storage] [DataMovement] Moved all blob related tests out of DataMove…
Browse files Browse the repository at this point in the history
…ment.Tests to DataMovement.Blobs.Test (#46475)

* Initial commit

* Moved more test files

* More tests moved over

* Compile Include over just adding the files to DM.Blobs.Tests
  • Loading branch information
nickliu-msft authored Oct 10, 2024
1 parent 37d33af commit 15bd590
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 1,370 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_56a707e8fb"
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_e796f456ff"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

extern alias BaseBlobs;
extern alias DMBlobs;
using System;
using System.Collections.Generic;
Expand All @@ -11,13 +12,11 @@
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.Blobs.Tests;
using Azure.Storage.DataMovement.Tests;
using Azure.Storage.Sas;
using Azure.Storage.Test;
using BaseBlobs::Azure.Storage.Blobs;
using BaseBlobs::Azure.Storage.Blobs.Models;
using BaseBlobs::Azure.Storage.Blobs.Specialized;
using BaseBlobs::Azure.Storage.Sas;
using DMBlobs::Azure.Storage.DataMovement.Blobs;
using Moq;
using NUnit.Framework;
Expand Down Expand Up @@ -53,7 +52,7 @@ public void Ctor_PublicUri()
public async Task ReadStreamAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
var length = Constants.KB;
await blobClient.CreateAsync();
Expand All @@ -77,7 +76,7 @@ public async Task ReadStreamAsync()
public async Task ReadStreamAsync_Position()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

int readPosition = 512;
Expand Down Expand Up @@ -106,7 +105,7 @@ public async Task ReadStreamAsync_Position()
public async Task ReadStreamAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);

Expand All @@ -123,7 +122,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task ReadStreamAsync_Partial()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);

Expand All @@ -148,7 +147,7 @@ public async Task ReadStreamAsync_Partial()
public async Task WriteFromStreamAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

var length = Constants.KB;
Expand All @@ -174,7 +173,7 @@ await storageResource.CopyFromStreamAsync(
public async Task WriteFromStreamAsync_Position()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

long readPosition = Constants.KB;
Expand Down Expand Up @@ -215,7 +214,7 @@ await storageResource.CopyFromStreamAsync(
public async Task WriteFromStreamAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);

Expand Down Expand Up @@ -533,7 +532,7 @@ await destinationResource.CopyFromStreamInternalAsync(
public async Task CopyFromUriAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

Expand Down Expand Up @@ -567,7 +566,7 @@ public async Task CopyFromUriAsync_OAuth()
{
// Arrange
BlobServiceClient serviceClient = GetServiceClient_OAuth();
await using DisposingContainer test = await GetTestContainerAsync(
await using DisposingBlobContainer test = await GetTestContainerAsync(
service: serviceClient,
publicAccessType: PublicAccessType.None);

Expand Down Expand Up @@ -611,7 +610,7 @@ public async Task CopyFromUriAsync_HttpAuthorization()
{
// Arrange
BlobServiceClient serviceClient = GetServiceClient_OAuth();
await using DisposingContainer test = await GetTestContainerAsync(
await using DisposingBlobContainer test = await GetTestContainerAsync(
service: serviceClient,
publicAccessType: PublicAccessType.None);

Expand Down Expand Up @@ -948,7 +947,7 @@ await destinationResource.CopyFromUriInternalAsync(
public async Task CopyFromUriAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

Expand All @@ -969,7 +968,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task CopyBlockFromUriAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
await sourceClient.CreateIfNotExistsAsync();
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
Expand Down Expand Up @@ -1011,7 +1010,7 @@ public async Task CopyBlockFromUriAsync_OAuth()
{
// Arrange
BlobServiceClient serviceClient = GetServiceClient_OAuth();
await using DisposingContainer test = await GetTestContainerAsync(
await using DisposingBlobContainer test = await GetTestContainerAsync(
service: serviceClient,
publicAccessType: PublicAccessType.None);
AppendBlobClient sourceClient = test.Container.GetAppendBlobClient(GetNewBlobName());
Expand Down Expand Up @@ -1058,7 +1057,7 @@ await destinationResource.CopyBlockFromUriAsync(
public async Task CopyBlockFromUriAsync_OAuth_Token()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.None);
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.None);
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
await sourceClient.CreateIfNotExistsAsync();
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
Expand Down Expand Up @@ -1108,7 +1107,7 @@ public async Task CopyBlockFromUriAsync_HttpAuthorization()
{
// Arrange
BlobServiceClient serviceClient = GetServiceClient_OAuth();
await using DisposingContainer test = await GetTestContainerAsync(
await using DisposingBlobContainer test = await GetTestContainerAsync(
service: serviceClient,
publicAccessType: PublicAccessType.None);
AppendBlobClient sourceClient = test.Container.GetAppendBlobClient(GetNewBlobName());
Expand Down Expand Up @@ -1455,7 +1454,7 @@ await destinationResource.CopyBlockFromUriInternalAsync(
public async Task CopyBlockFromUriAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

Expand All @@ -1476,7 +1475,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task GetPropertiesAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

var length = Constants.KB;
Expand All @@ -1502,7 +1501,7 @@ public async Task GetPropertiesAsync()
public async Task GetPropertiesAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
Expand Down Expand Up @@ -1618,7 +1617,7 @@ public async Task GetPropertiesAsync_Cached()
public async Task CompleteTransferAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);

Expand All @@ -1644,7 +1643,7 @@ await storageResource.CopyFromStreamAsync(
public async Task CompleteTransferAsync_Error()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
Expand All @@ -1662,7 +1661,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task GetCopyAuthorizationHeaderAsync()
{
// Arrange
await using DisposingContainer testContainer = await GetTestContainerAsync();
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());

var length = Constants.KB;
Expand All @@ -1688,7 +1687,7 @@ public async Task GetCopyAuthorizationHeaderAsync_OAuth()
// Arrange
var containerName = GetNewContainerName();
BlobServiceClient service = GetServiceClient_OAuth();
await using DisposingContainer testContainer = await GetTestContainerAsync(
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(
service,
containerName,
publicAccessType: PublicAccessType.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<Compile Include="$(AzureStorageDataMovementTestSharedSources)StartTransferDownloadTestBase.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementTestSharedSources)StartTransferDirectoryCopyTestBase.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementTestSharedSources)TransferValidator.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementTestSharedSources)DataMovementTestBase.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementTestSharedSources)TransferDirection.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementTestSharedSources)TransferValidator.Local.cs" LinkBase="Shared\DataMovement" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\**">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

extern alias BaseBlobs;
extern alias DMBlobs;
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Azure.Identity;
using Azure.Storage.Blobs;
using BaseBlobs::Azure.Storage.Blobs;
using DMBlobs::Azure.Storage.Blobs;
using DMBlobs::Azure.Storage.DataMovement.Blobs;
using NUnit.Framework;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

extern alias BaseBlobs;
extern alias DMBlobs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.Blobs.Tests;
using Azure.Storage.DataMovement.Tests;
using BaseBlobs::Azure.Storage.Blobs;
using BaseBlobs::Azure.Storage.Blobs.Specialized;
using DMBlobs::Azure.Storage.DataMovement.Blobs;
using Moq;
using NUnit.Framework;
Expand Down Expand Up @@ -82,7 +79,7 @@ public void Ctor_PublicUri()
public async Task GetStorageResourcesAsync()
{
// Arrange
await using DisposingContainer test = await GetTestContainerAsync();
await using DisposingBlobContainer test = await GetTestContainerAsync();
await SetUpContainerForListing(test.Container);

string folderName = "foo";
Expand Down Expand Up @@ -247,7 +244,7 @@ public async Task GetStorageResourcesAsync_SubDirectories()
[RecordedTest]
public async Task GetStorageResourceReferenceAsync_Default()
{
await using DisposingContainer test = await GetTestContainerAsync();
await using DisposingBlobContainer test = await GetTestContainerAsync();
await SetUpContainerForListing(test.Container);

string prefix = "foo";
Expand All @@ -268,7 +265,7 @@ public async Task GetStorageResourceReferenceAsync_Default()
[TestCase(DataMovementBlobConstants.ResourceId.AppendBlob)]
public async Task GetStorageResourceReferenceAsync_BlobType(string blobResourceId)
{
await using DisposingContainer test = await GetTestContainerAsync();
await using DisposingBlobContainer test = await GetTestContainerAsync();
await SetUpContainerForListing(test.Container);

string prefix = "foo";
Expand Down
Loading

0 comments on commit 15bd590

Please sign in to comment.