Skip to content
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

[Storage] [DataMovement] [Shares] Preserve Permission Key #44696

Merged
merged 15 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_0523c237f1"
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_db329f90cd"
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,18 @@ protected override StorageResourceCheckpointData GetDestinationCheckpointData()
metadata:_options?.Metadata,
tags: default);
}

// no-op for get permissions
protected override Task<string> GetPermissionsAsync(
StorageResourceItemProperties properties = default,
CancellationToken cancellationToken = default)
=> Task.FromResult((string)default);

// no-op for set permissions
protected override Task SetPermissionsAsync(
StorageResourceItem sourceResource,
StorageResourceItemProperties sourceProperties,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private StorageResourceItem GetBlobAsStorageResource(
/// </summary>
/// <returns>List of the child resources in the storage container.</returns>
protected override async IAsyncEnumerable<StorageResource> GetStorageResourcesAsync(
StorageResourceContainer destinationContainer = default,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
// Suffix the backwards slash when searching if there's a prefix specified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,18 @@ protected override StorageResourceCheckpointData GetDestinationCheckpointData()
metadata: _options?.Metadata,
tags: default);
}

// no-op for get permissions
protected override Task<string> GetPermissionsAsync(
StorageResourceItemProperties properties = default,
CancellationToken cancellationToken = default)
=> Task.FromResult((string)default);

// no-op for set permissions
protected override Task SetPermissionsAsync(
StorageResourceItem sourceResource,
StorageResourceItemProperties sourceProperties,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,18 @@ protected override StorageResourceCheckpointData GetDestinationCheckpointData()
metadata: _options?.Metadata,
tags: default);
}

// no-op for get permissions
protected override Task<string> GetPermissionsAsync(
StorageResourceItemProperties properties = default,
CancellationToken cancellationToken = default)
=> Task.FromResult((string)default);

// no-op for set permissions
protected override Task SetPermissionsAsync(
StorageResourceItem sourceResource,
StorageResourceItemProperties sourceProperties,
CancellationToken cancellationToken = default)
=> Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ protected override async Task VerifyPropertiesCopyAsync(
BlobProperties destinationProperties = await destinationClient.GetPropertiesAsync();

Assert.That(_defaultMetadata, Is.EqualTo(destinationProperties.Metadata));
Assert.AreEqual(_defaultAccessTier.ToString(), destinationProperties.AccessTier);
Assert.AreEqual(_defaultContentDisposition, destinationProperties.ContentDisposition);
Assert.AreEqual(_defaultContentLanguage, destinationProperties.ContentLanguage);
Assert.AreEqual(_defaultCacheControl, destinationProperties.CacheControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ protected override async Task VerifyPropertiesCopyAsync(
BlobProperties destinationProperties = await destinationClient.GetPropertiesAsync();

Assert.That(_defaultMetadata, Is.EqualTo(destinationProperties.Metadata));
Assert.AreEqual(_defaultAccessTier.ToString(), destinationProperties.AccessTier);
Assert.AreEqual(_defaultContentDisposition, destinationProperties.ContentDisposition);
Assert.AreEqual(_defaultContentLanguage, destinationProperties.ContentLanguage);
Assert.AreEqual(_defaultCacheControl, destinationProperties.CacheControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ await checkpointer.AddNewJobAsync(
GetMockBlockBlobResource("blob2").Object,
GetMockBlockBlobResource("blob3").Object,
};
sourceMock.Setup(r => r.GetStorageResourcesAsync(It.IsAny<CancellationToken>()))
sourceMock.Setup(r => r.GetStorageResourcesAsync(
It.IsAny<StorageResourceContainer>(),
It.IsAny<CancellationToken>()))
.Returns(GetStorageResourceItemsAsyncEnumerable(blobItems));
ServiceToServiceTransferJob transferJob = new ServiceToServiceTransferJob(
new DataTransfer(
Expand Down Expand Up @@ -165,7 +167,9 @@ await checkpointer.AddNewJobAsync(
GetMockAppendBlobResource("appendblob2").Object,
GetMockBlockBlobResource("blockblob3").Object,
};
sourceMock.Setup(r => r.GetStorageResourcesAsync(It.IsAny<CancellationToken>()))
sourceMock.Setup(r => r.GetStorageResourcesAsync(
It.IsAny<StorageResourceContainer>(),
It.IsAny<CancellationToken>()))
.Returns(GetStorageResourceItemsAsyncEnumerable(blobItems));
ServiceToServiceTransferJob transferJob = new ServiceToServiceTransferJob(
new DataTransfer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ protected override async Task VerifyPropertiesCopyAsync(
BlobProperties destinationProperties = await destinationClient.GetPropertiesAsync();

Assert.That(_defaultMetadata, Is.EqualTo(destinationProperties.Metadata));
Assert.AreEqual(_defaultAccessTier.ToString(), destinationProperties.AccessTier);
Assert.AreEqual(_defaultContentDisposition, destinationProperties.ContentDisposition);
Assert.AreEqual(_defaultContentLanguage, destinationProperties.ContentLanguage);
Assert.AreEqual(_defaultCacheControl, destinationProperties.CacheControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ protected override async Task VerifyPropertiesCopyAsync(
BlobProperties destinationProperties = await destinationClient.GetPropertiesAsync();

Assert.That(_defaultMetadata, Is.EqualTo(destinationProperties.Metadata));
Assert.AreEqual(_defaultAccessTier.ToString(), destinationProperties.AccessTier);
Assert.AreEqual(_defaultContentDisposition, destinationProperties.ContentDisposition);
Assert.AreEqual(_defaultContentLanguage, destinationProperties.ContentLanguage);
Assert.AreEqual(_defaultCacheControl, destinationProperties.CacheControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ protected override async Task VerifyPropertiesCopyAsync(
BlobProperties destinationProperties = await destinationClient.GetPropertiesAsync();

Assert.That(_defaultMetadata, Is.EqualTo(destinationProperties.Metadata));
Assert.AreEqual(_defaultAccessTier.ToString(), destinationProperties.AccessTier);
Assert.AreEqual(_defaultContentDisposition, destinationProperties.ContentDisposition);
Assert.AreEqual(_defaultContentLanguage, destinationProperties.ContentLanguage);
Assert.AreEqual(_defaultCacheControl, destinationProperties.CacheControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ private async Task UploadAppendBlocksAsync(
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerAsync(ShareServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestShareAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(ShareClient containerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
ShareClient containerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
{
// Authorize with SAS when performing operations
if (containerClient.CanGenerateSasUri)
Expand Down Expand Up @@ -171,7 +174,13 @@ protected override async Task VerifyEmptyDestinationContainerAsync(ShareClient d
Assert.IsEmpty(items);
}

protected override async Task VerifyResultsAsync(BlobContainerClient sourceContainer, string sourcePrefix, ShareClient destinationContainer, string destinationPrefix, CancellationToken cancellationToken = default)
protected override async Task VerifyResultsAsync(
BlobContainerClient sourceContainer,
string sourcePrefix,
ShareClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ await blobClient.UploadAsync(
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerAsync(ShareServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestShareAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(ShareClient containerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
ShareClient containerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
{
// Authorize with SAS when performing operations
if (containerClient.CanGenerateSasUri)
Expand Down Expand Up @@ -151,7 +154,13 @@ protected override async Task VerifyEmptyDestinationContainerAsync(ShareClient d
Assert.IsEmpty(items);
}

protected override async Task VerifyResultsAsync(BlobContainerClient sourceContainer, string sourcePrefix, ShareClient destinationContainer, string destinationPrefix, CancellationToken cancellationToken = default)
protected override async Task VerifyResultsAsync(
BlobContainerClient sourceContainer,
string sourcePrefix,
ShareClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ private async Task UploadPagesAsync(
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerAsync(ShareServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestShareAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(ShareClient containerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
ShareClient containerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
{
// Authorize with SAS when performing operations
if (containerClient.CanGenerateSasUri)
Expand Down Expand Up @@ -171,7 +174,13 @@ protected override async Task VerifyEmptyDestinationContainerAsync(ShareClient d
Assert.IsEmpty(items);
}

protected override async Task VerifyResultsAsync(BlobContainerClient sourceContainer, string sourcePrefix, ShareClient destinationContainer, string destinationPrefix, CancellationToken cancellationToken = default)
protected override async Task VerifyResultsAsync(
BlobContainerClient sourceContainer,
string sourcePrefix,
ShareClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ protected override async Task CreateObjectInSourceAsync(
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(BlobContainerClient sourceContainerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient sourceContainerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
=> new BlobStorageResourceContainer(sourceContainerClient, new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = directoryPath, BlobType = new(BlobType.Append) });

protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName)
Expand Down Expand Up @@ -184,6 +187,7 @@ protected override async Task VerifyResultsAsync(
string sourcePrefix,
BlobContainerClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ protected override async Task CreateObjectInSourceAsync(
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(BlobContainerClient sourceContainerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient sourceContainerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
=> new BlobStorageResourceContainer(sourceContainerClient, new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = directoryPath, BlobType = new(BlobType.Block) });

protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName)
Expand Down Expand Up @@ -165,6 +168,7 @@ protected override async Task VerifyResultsAsync(
string sourcePrefix,
BlobContainerClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ protected override async Task CreateObjectInSourceAsync(
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);

protected override StorageResourceContainer GetDestinationStorageResourceContainer(BlobContainerClient sourceContainerClient, string directoryPath)
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
BlobContainerClient sourceContainerClient,
string directoryPath,
TransferPropertiesTestType propertiesTestType = default)
=> new BlobStorageResourceContainer(sourceContainerClient, new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = directoryPath, BlobType = new(BlobType.Page) });

protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName)
Expand Down Expand Up @@ -185,6 +188,7 @@ protected override async Task VerifyResultsAsync(
string sourcePrefix,
BlobContainerClient destinationContainer,
string destinationPrefix,
TransferPropertiesTestType propertiesTestType = default,
CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public ShareFileStorageResourceOptions() { }
public Azure.Storage.DataMovement.DataTransferProperty<System.DateTimeOffset?> FileCreatedOn { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty<System.DateTimeOffset?> FileLastWrittenOn { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty<System.Collections.Generic.IDictionary<string, string>> FileMetadata { get { throw null; } set { } }
public string FilePermissionKey { get { throw null; } set { } }
public string FilePermissions { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty FilePermissions { get { throw null; } set { } }
public Azure.Storage.Files.Shares.Models.ShareFileRequestConditions SourceConditions { get { throw null; } set { } }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public ShareFileStorageResourceOptions() { }
public Azure.Storage.DataMovement.DataTransferProperty<System.DateTimeOffset?> FileCreatedOn { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty<System.DateTimeOffset?> FileLastWrittenOn { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty<System.Collections.Generic.IDictionary<string, string>> FileMetadata { get { throw null; } set { } }
public string FilePermissionKey { get { throw null; } set { } }
public string FilePermissions { get { throw null; } set { } }
public Azure.Storage.DataMovement.DataTransferProperty FilePermissions { get { throw null; } set { } }
public Azure.Storage.Files.Shares.Models.ShareFileRequestConditions SourceConditions { get { throw null; } set { } }
}
}
Expand Down
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.Files.Shares",
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_34fa84b61a"
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_e232faf009"
}
Loading