From c0483dbdaf787244baa4347d930e4801b4d5c0ac Mon Sep 17 00:00:00 2001 From: xiaonlimsft Date: Sat, 10 Oct 2020 17:13:36 +0800 Subject: [PATCH] Resolve CRI failure (#11756) --- .../review/storage-file-datalake.api.md | 2 +- .../src/utils/DataLakeAclChangeFailedError.ts | 4 +- .../test/node/pathclient.spec.ts | 82 ++++++++++++++++++- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md index 08c51e6ccbc1..e4808adde926 100644 --- a/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md +++ b/sdk/storage/storage-file-datalake/review/storage-file-datalake.api.md @@ -156,7 +156,7 @@ export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: Reque export class DataLakeAclChangeFailedError extends Error { constructor(error: RestError | Error, continuationToken?: string); continuationToken?: string; - internalError: RestError | Error; + innerError: RestError | Error; } // @public diff --git a/sdk/storage/storage-file-datalake/src/utils/DataLakeAclChangeFailedError.ts b/sdk/storage/storage-file-datalake/src/utils/DataLakeAclChangeFailedError.ts index b0312e562cf2..3b65a013666f 100644 --- a/sdk/storage/storage-file-datalake/src/utils/DataLakeAclChangeFailedError.ts +++ b/sdk/storage/storage-file-datalake/src/utils/DataLakeAclChangeFailedError.ts @@ -24,12 +24,12 @@ export class DataLakeAclChangeFailedError extends Error { * @type {(RestError | Error)} * @memberof DataLakeAclChangeFailedError */ - public internalError: RestError | Error; + public innerError: RestError | Error; constructor(error: RestError | Error, continuationToken?: string) { super(error.message); this.name = "DataLakeAclChangeFailedError"; - this.internalError = error; + this.innerError = error; this.continuationToken = continuationToken; Object.setPrototypeOf(this, DataLakeAclChangeFailedError.prototype); } diff --git a/sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts b/sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts index 94160870ec40..31bf425b4a49 100644 --- a/sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts +++ b/sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts @@ -10,7 +10,7 @@ import { DataLakeFileSystemClient, DataLakeServiceClient, PathAccessControlItem, - PathPermissions + PathPermissions, } from "../../src"; import { toAcl, toRemoveAcl } from "../../src/transforms"; import { bodyToString, getDataLakeServiceClient, recorderEnvSetup } from "../utils"; @@ -591,8 +591,9 @@ describe("DataLakePathClient setAccessControlRecursive Node.js only", () => { } ); } catch (err) { - assert.equal(err.name, "AbortError"); - assert.equal(err.message, "The operation was aborted.", "Unexpected error caught: " + err); + assert.equal(err.name, "DataLakeAclChangeFailedError"); + assert.equal(err.innerError.name, "AbortError"); + assert.equal(err.innerError.message, "The operation was aborted.", "Unexpected error caught: " + err); } const result = await directoryClient.setAccessControlRecursive( @@ -709,5 +710,78 @@ describe("DataLakePathClient setAccessControlRecursive Node.js only", () => { assert.deepStrictEqual(undefined, removeResult.continuationToken); }); - it("setAccessControlRecursive should work with progress failures - TODO", async () => {}); + it("setAccessControlRecursive should work with progress failures", async () => { + // Manually execution needed + // TODO: Cannot set up environment to reproduce progress failure due to service change + // Blob Data Contributor unexpectedly doesn't have permission for setRecursiveAcl API + // Check with feature team + + // /directory + // /directory/subdirectory1 + // /directory/subdirectory1/fileName1 + // /directory/subdirectory1/fileName2 + // /directory/subdirectory2/fileName3 + // /directory/subdirectory2/fileName4 + // Service client with SharedKey authentication creates following directories and files + // /directory/subdirectory1/fileName5 + // /directory/subdirectory2/fileName6 + + /* + + const token = ""; + const fileSystemClientOAuth = new DataLakeFileSystemClient(fileSystemClient.url, new SimpleTokenCredential(token)); + + const directoryName = recorder.getUniqueName("directory"); + const subDirectoryName1 = recorder.getUniqueName("subdirectory1"); + const fileName1 = recorder.getUniqueName("fileName1"); + const fileName2 = recorder.getUniqueName("fileName2"); + const subDirectoryName2 = recorder.getUniqueName("subdirectory2"); + const fileName3 = recorder.getUniqueName("fileName3"); + const fileName4 = recorder.getUniqueName("fileName4"); + const fileName5 = recorder.getUniqueName("fileName5"); + const fileName6 = recorder.getUniqueName("fileName6"); + + const directoryClient = fileSystemClient.getDirectoryClient(directoryName); + const directoryClientOAuth = fileSystemClientOAuth.getDirectoryClient(directoryName); + const subDirectoryClient1 = directoryClient.getSubdirectoryClient(subDirectoryName1); + const subDirectoryClientOAuth1 = directoryClientOAuth.getSubdirectoryClient(subDirectoryName1); + const fileClientOAuth1 = subDirectoryClientOAuth1.getFileClient(fileName1); + const fileClientOAuth2 = subDirectoryClientOAuth1.getFileClient(fileName2); + const fileClient5 = subDirectoryClient1.getFileClient(fileName5); + const subDirectoryClient2 = directoryClient.getSubdirectoryClient(subDirectoryName2); + const subDirectoryClientOAuth2 = directoryClientOAuth.getSubdirectoryClient(subDirectoryName2); + const fileClientOAuth3 = subDirectoryClientOAuth2.getFileClient(fileName3); + const fileClientOAuth4 = subDirectoryClientOAuth2.getFileClient(fileName4); + const fileClient6 = subDirectoryClient2.getFileClient(fileName6); + + await directoryClientOAuth.create(); + await subDirectoryClientOAuth1.create(); + await subDirectoryClientOAuth2.create(); + + await fileClientOAuth1.create(); + await fileClientOAuth2.create(); + await fileClientOAuth3.create(); + await fileClientOAuth4.create(); + await fileClient5.create(); + await fileClient6.create(); + + // let continuation; + // let midProgress: AccessControlChanges; + + await directoryClientOAuth.setAccessControlRecursive( + toAcl( + "user::rwx,user:ec3595d6-2c17-4696-8caa-7e139758d24a:rw-,group::rw-,mask::rwx,other::---" + ), + { + batchSize: 2, + // onProgress: (progress) => { + // midProgress = progress; + // continuation = progress.continuationToken; + // }, + continueOnFailure: true + } + ); + + */ + }); });