-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Datamovement tests ShareUploadDirectory #39718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jaschrep-msft
merged 21 commits into
Azure:main
from
jaschrep-msft:datamovement-tests-shareuploaddirectory
Nov 10, 2023
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ce08d76
initial testbase implementation
jaschrep-msft a6b1993
hook up shares to testbase, some failures
jaschrep-msft 5cfa710
fixes
jaschrep-msft 343e7f1
fix a test
jaschrep-msft 10e7eef
get root vs nonroot tests working together
jaschrep-msft 997fdb7
Merge branch 'main' into datamovement-tests-shareuploaddirectory
jaschrep-msft 015db91
fix build
jaschrep-msft 1d966d3
cleanup
jaschrep-msft 42270e2
testproxy
jaschrep-msft ced4943
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
jaschrep-msft 7ca375b
rerecord
jaschrep-msft d22d24e
rerecord
jaschrep-msft 8893aec
rerecord (exceeding file path limits)
jaschrep-msft 9b88dc9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
jaschrep-msft ba6b724
change path generation, hopefully fix linux tests
jaschrep-msft 94f18ce
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
jaschrep-msft 0e47894
recorded test attr
jaschrep-msft cc666aa
disable bad test
jaschrep-msft 9a84848
use system path separator
jaschrep-msft b335e68
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-net int…
jaschrep-msft 64f149f
bugfix
jaschrep-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...e/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferUploadTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Azure.Storage.DataMovement.Tests; | ||
| using Azure.Storage.Files.Shares; | ||
| using Azure.Storage.Files.Shares.Tests; | ||
| using Azure.Storage.Test.Shared; | ||
|
|
||
| namespace Azure.Storage.DataMovement.Files.Shares.Tests | ||
| { | ||
| [ShareClientTestFixture(true)] | ||
| [ShareClientTestFixture(false)] | ||
| internal class ShareDirectoryStartTransferUploadTests : StartTransferUploadDirectoryTestBase< | ||
| ShareServiceClient, | ||
| ShareDirectoryClient, | ||
| ShareFileClient, | ||
| ShareClientOptions, | ||
| StorageTestEnvironment> | ||
| { | ||
| /// <summary> | ||
| /// A <see cref="DisposingShare"/> but exposes a directory client within that share. | ||
| /// Still cleans up the whole share. Helpful for parameterizing tests to use a root | ||
| /// directory vs a subdir. | ||
| /// </summary> | ||
| private class DisposingShareDirectory : IDisposingContainer<ShareDirectoryClient> | ||
| { | ||
| private readonly DisposingShare _disposingShare; | ||
| public ShareDirectoryClient Container { get; } | ||
|
|
||
| public DisposingShareDirectory(DisposingShare disposingShare, ShareDirectoryClient dirClient) | ||
| { | ||
| _disposingShare = disposingShare; | ||
| Container = dirClient; | ||
| } | ||
|
|
||
| public async ValueTask DisposeAsync() | ||
| { | ||
| if (_disposingShare != default) | ||
| { | ||
| await _disposingShare.DisposeAsync(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public bool UseNonRootDirectory { get; } | ||
|
|
||
| public ShareDirectoryStartTransferUploadTests(bool async, ShareClientOptions.ServiceVersion serviceVersion, bool useNonRootDirectory) | ||
| : base(async, null /* RecordedTestMode.Record /* to re-record */) | ||
| { | ||
| ClientBuilder = ClientBuilderExtensions.GetNewShareClientBuilder(Tenants, serviceVersion); | ||
| UseNonRootDirectory = useNonRootDirectory; | ||
| } | ||
|
|
||
| protected override async Task<IDisposingContainer<ShareDirectoryClient>> GetDisposingContainerAsync(ShareServiceClient service = null, string containerName = null) | ||
| { | ||
| DisposingShare disposingShare = await ClientBuilder.GetTestShareAsync(service, containerName); | ||
| ShareDirectoryClient directoryClient = disposingShare.Container.GetRootDirectoryClient(); | ||
| if (UseNonRootDirectory) | ||
| { | ||
| foreach (var _ in Enumerable.Range(0, 2)) | ||
| { | ||
| directoryClient = directoryClient.GetSubdirectoryClient(GetNewObjectName()); | ||
| await directoryClient.CreateAsync(); | ||
| } | ||
| } | ||
| return new DisposingShareDirectory(disposingShare, directoryClient); | ||
| } | ||
|
|
||
| protected override StorageResourceContainer GetStorageResourceContainer(ShareDirectoryClient containerClient) | ||
| { | ||
| return new ShareDirectoryStorageResourceContainer(containerClient, null); | ||
| } | ||
|
|
||
| protected override TransferValidator.ListFilesAsync GetStorageResourceLister(ShareDirectoryClient containerClient) | ||
| { | ||
| return TransferValidator.GetShareFileLister(containerClient); | ||
| } | ||
|
|
||
| protected override async Task InitializeDestinationDataAsync(ShareDirectoryClient containerClient, List<(string FilePath, long Size)> fileSizes, CancellationToken cancellationToken) | ||
| { | ||
| foreach ((string filePath, long size) in fileSizes) | ||
| { | ||
| ShareDirectoryClient directory = containerClient; | ||
|
|
||
| string[] pathSegments = filePath.Split('/'); | ||
| foreach (string pathSegment in pathSegments.Take(pathSegments.Length - 1)) | ||
| { | ||
| directory = directory.GetSubdirectoryClient(pathSegment); | ||
| await directory.CreateIfNotExistsAsync(cancellationToken: cancellationToken); | ||
| } | ||
| ShareFileClient file = directory.GetFileClient(pathSegments.Last()); | ||
| await file.CreateAsync(size, cancellationToken: cancellationToken); | ||
| await file.UploadAsync(await CreateLimitedMemoryStream(size), cancellationToken: cancellationToken); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.