Skip to content

Commit

Permalink
[Storage] Tests - common naming - shares. (#21182)
Browse files Browse the repository at this point in the history
* purge recordings.

* shares code.

* parallel

* records.

* playback this.

* unflaky this.

* these as well.
  • Loading branch information
kasobol-msft authored May 5, 2021
1 parent 37838de commit 153351f
Show file tree
Hide file tree
Showing 819 changed files with 50,127 additions and 28,373 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class DirectoryAPITests extends APISpec {
static def filePermission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)S:NO_ACCESS_CONTROL"

def setup() {
shareName = testResourceName.randomName(methodName, 60)
directoryPath = testResourceName.randomName(methodName, 60)
shareClient = shareBuilderHelper(interceptorManager, shareName).buildClient()
shareName = namer.getRandomName(60)
directoryPath = namer.getRandomName(60)
shareClient = shareBuilderHelper(shareName).buildClient()
shareClient.create()
primaryDirectoryClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath).buildDirectoryClient()
primaryDirectoryClient = directoryBuilderHelper(shareName, directoryPath).buildDirectoryClient()
testMetadata = Collections.singletonMap("testmetadata", "value")
smbProperties = new FileSmbProperties().setNtfsFileAttributes(EnumSet.<NtfsFileAttributes>of(NtfsFileAttributes.NORMAL))
}
Expand All @@ -55,7 +55,7 @@ class DirectoryAPITests extends APISpec {
when:
ShareSnapshotInfo shareSnapshotInfo = shareClient.createSnapshot()
expectURL = expectURL + "?sharesnapshot=" + shareSnapshotInfo.getSnapshot()
ShareDirectoryClient newDirClient = shareBuilderHelper(interceptorManager, shareName).snapshot(shareSnapshotInfo.getSnapshot())
ShareDirectoryClient newDirClient = shareBuilderHelper(shareName).snapshot(shareSnapshotInfo.getSnapshot())
.buildClient().getDirectoryClient(directoryPath)
def directoryURL = newDirClient.getDirectoryUrl()

Expand Down Expand Up @@ -101,7 +101,7 @@ class DirectoryAPITests extends APISpec {

def "Exists error"() {
setup:
primaryDirectoryClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath)
primaryDirectoryClient = directoryBuilderHelper(shareName, directoryPath)
.sasToken("sig=dummyToken").buildDirectoryClient()

when:
Expand All @@ -119,10 +119,10 @@ class DirectoryAPITests extends APISpec {

def "Create directory error"() {
given:
def testShareName = testResourceName.randomName(methodName, 60)
def testShareName = namer.getRandomName(60)

when:
directoryBuilderHelper(interceptorManager, testShareName, directoryPath).buildDirectoryClient().create()
directoryBuilderHelper(testShareName, directoryPath).buildDirectoryClient().create()

then:
def e = thrown(ShareStorageException)
Expand Down Expand Up @@ -153,8 +153,8 @@ class DirectoryAPITests extends APISpec {
def "Create directory with file permission key"() {
setup:
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
when:
def resp = primaryDirectoryClient.createWithResponse(smbProperties, null, null, null, null)
Expand All @@ -175,8 +175,8 @@ class DirectoryAPITests extends APISpec {
setup:
def filePermissionKey = shareClient.createPermission(filePermission)
def attributes = EnumSet.of(NtfsFileAttributes.HIDDEN, NtfsFileAttributes.DIRECTORY)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
.setNtfsFileAttributes(attributes)
when:
Expand Down Expand Up @@ -270,8 +270,8 @@ class DirectoryAPITests extends APISpec {
def "Set properties file permission key"() {
given:
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
primaryDirectoryClient.create()
def resp = primaryDirectoryClient.setPropertiesWithResponse(smbProperties, null, null, null)
Expand Down Expand Up @@ -380,7 +380,7 @@ class DirectoryAPITests extends APISpec {
given:
primaryDirectoryClient.create()
def nameList = new LinkedList()
def dirPrefix = testResourceName.randomName(methodName, 60)
def dirPrefix = namer.getRandomName(60)
for (int i = 0; i < 2; i++) {
def subDirClient = primaryDirectoryClient.getSubdirectoryClient(dirPrefix + i)
subDirClient.create()
Expand All @@ -395,7 +395,7 @@ class DirectoryAPITests extends APISpec {
}

when:
def fileRefIter = primaryDirectoryClient.listFilesAndDirectories(prefix, maxResults, null, null).iterator()
def fileRefIter = primaryDirectoryClient.listFilesAndDirectories(namer.getResourcePrefix() + extraPrefix, maxResults, null, null).iterator()

then:
for (int i = 0; i < numOfResults; i++) {
Expand All @@ -404,17 +404,17 @@ class DirectoryAPITests extends APISpec {
!fileRefIter.hasNext()

where:
prefix | maxResults | numOfResults
null | null | 3
"directoryapitestslistfilesanddirectoriesargs" | 1 | 3
"noOp" | 3 | 0
extraPrefix | maxResults | numOfResults
"" | null | 3
"" | 1 | 3
"noOp" | 3 | 0
}

def "List max results by page"() {
given:
primaryDirectoryClient.create()
def nameList = new LinkedList()
def dirPrefix = testResourceName.randomName(methodName, 60)
def dirPrefix = namer.getRandomName(60)
for (int i = 0; i < 2; i++) {
def subDirClient = primaryDirectoryClient.getSubdirectoryClient(dirPrefix + i)
subDirClient.create()
Expand All @@ -430,7 +430,7 @@ class DirectoryAPITests extends APISpec {

when:
def fileRefIter = primaryDirectoryClient
.listFilesAndDirectories("directoryapitestslistmaxresultsbypage", null, null, null)
.listFilesAndDirectories(namer.getResourcePrefix(), null, null, null)
.iterableByPage(1).iterator()

then:
Expand Down Expand Up @@ -553,8 +553,8 @@ class DirectoryAPITests extends APISpec {
given:
primaryDirectoryClient.create()
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
expect:
FileTestHelper.assertResponseStatusCode(
Expand Down Expand Up @@ -616,8 +616,8 @@ class DirectoryAPITests extends APISpec {
primaryDirectoryClient.create()
ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
.setContentType("txt")
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())

expect:
FileTestHelper.assertResponseStatusCode(
Expand Down Expand Up @@ -674,7 +674,7 @@ class DirectoryAPITests extends APISpec {
1, 1), ZoneOffset.UTC).toString()

when:
def shareSnapshotClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath).snapshot(snapshot).buildDirectoryClient()
def shareSnapshotClient = directoryBuilderHelper(shareName, directoryPath).snapshot(snapshot).buildDirectoryClient()

then:
snapshot == shareSnapshotClient.getShareSnapshotId()
Expand All @@ -695,7 +695,7 @@ class DirectoryAPITests extends APISpec {
given:
primaryDirectoryClient.create()

def directoryClient = directoryBuilderHelper(interceptorManager, primaryDirectoryClient.getShareName(), primaryDirectoryClient.getDirectoryPath())
def directoryClient = directoryBuilderHelper(primaryDirectoryClient.getShareName(), primaryDirectoryClient.getDirectoryPath())
.addPolicy(getPerCallVersionPolicy()).buildDirectoryClient()

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class DirectoryAsyncAPITests extends APISpec {
static def filePermission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)S:NO_ACCESS_CONTROL"

def setup() {
shareName = testResourceName.randomName(methodName, 60)
directoryPath = testResourceName.randomName(methodName, 60)
shareClient = shareBuilderHelper(interceptorManager, shareName).buildClient()
shareName = namer.getRandomName(60)
directoryPath = namer.getRandomName(60)
shareClient = shareBuilderHelper(shareName).buildClient()
shareClient.create()
primaryDirectoryAsyncClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath).buildDirectoryAsyncClient()
primaryDirectoryAsyncClient = directoryBuilderHelper(shareName, directoryPath).buildDirectoryAsyncClient()
testMetadata = Collections.singletonMap("testmetadata", "value")
smbProperties = new FileSmbProperties().setNtfsFileAttributes(EnumSet.<NtfsFileAttributes>of(NtfsFileAttributes.NORMAL))
}
Expand Down Expand Up @@ -70,9 +70,9 @@ class DirectoryAsyncAPITests extends APISpec {

def "Create directory error"() {
given:
def testShareName = testResourceName.randomName(methodName, 60)
def testShareName = namer.getRandomName(60)
when:
def createDirErrorVerifier = StepVerifier.create(directoryBuilderHelper(interceptorManager, testShareName, directoryPath).buildDirectoryAsyncClient().create())
def createDirErrorVerifier = StepVerifier.create(directoryBuilderHelper(testShareName, directoryPath).buildDirectoryAsyncClient().create())
then:
createDirErrorVerifier.verifyErrorSatisfies {
assert FileTestHelper.assertExceptionStatusCodeAndMessage(it, 404, ShareErrorCode.SHARE_NOT_FOUND)
Expand Down Expand Up @@ -105,8 +105,8 @@ class DirectoryAsyncAPITests extends APISpec {

def "Create dir with file perm key"() {
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
expect:
StepVerifier.create(primaryDirectoryAsyncClient.createWithResponse(smbProperties, null, null))
Expand Down Expand Up @@ -191,8 +191,8 @@ class DirectoryAsyncAPITests extends APISpec {
def "Set properties file permission key"() {
given:
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
primaryDirectoryAsyncClient.createWithResponse(null, null, null).block()
expect:
Expand Down Expand Up @@ -307,7 +307,7 @@ class DirectoryAsyncAPITests extends APISpec {
given:
primaryDirectoryAsyncClient.create().block()
LinkedList<String> nameList = new LinkedList<>()
def dirPrefix = testResourceName.randomName(methodName, 60)
def dirPrefix = namer.getRandomName(60)
for (int i = 0; i < 2; i++) {
def subDirClient = primaryDirectoryAsyncClient.getSubdirectoryClient(dirPrefix + i)
subDirClient.create().block()
Expand All @@ -322,7 +322,8 @@ class DirectoryAsyncAPITests extends APISpec {
}

when:
def listFileAndDirVerifier = StepVerifier.create(primaryDirectoryAsyncClient.listFilesAndDirectories(prefix,
def listFileAndDirVerifier = StepVerifier.create(primaryDirectoryAsyncClient.listFilesAndDirectories(
namer.getResourcePrefix() + extraPrefix,
maxResults))

then:
Expand All @@ -334,10 +335,10 @@ class DirectoryAsyncAPITests extends APISpec {
}
nameList.isEmpty()
where:
prefix | maxResults | numOfResults
"directoryasyncapitestslistfilesanddirectoriesargs" | null | 3
"directoryasyncapitestslistfilesanddirectoriesargs" | 1 | 3
"directoryasyncapitestslistfilesanddirectoriesargsnoops" | 1 | 0
extraPrefix | maxResults | numOfResults
"" | null | 3
"" | 1 | 3
"noops" | 1 | 0
}

@Unroll
Expand Down Expand Up @@ -449,8 +450,8 @@ class DirectoryAsyncAPITests extends APISpec {
def "Create sub directory file perm key"() {
given:
def filePermissionKey = shareClient.createPermission(filePermission)
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())
.setFilePermissionKey(filePermissionKey)
primaryDirectoryAsyncClient.create().block()
expect:
Expand Down Expand Up @@ -515,8 +516,8 @@ class DirectoryAsyncAPITests extends APISpec {
primaryDirectoryAsyncClient.create().block()
ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
.setContentType("txt")
smbProperties.setFileCreationTime(getUTCNow())
.setFileLastWriteTime(getUTCNow())
smbProperties.setFileCreationTime(namer.getUtcNow())
.setFileLastWriteTime(namer.getUtcNow())

expect:
StepVerifier.create(primaryDirectoryAsyncClient.createFileWithResponse("testCreateFile", 1024, httpHeaders, smbProperties, filePermission, testMetadata))
Expand Down Expand Up @@ -566,7 +567,7 @@ class DirectoryAsyncAPITests extends APISpec {

expect:
StepVerifier.create(primaryDirectoryAsyncClient.createFileWithResponse("testCreateFile", 1024, null, null, null,
null, new ShareRequestConditions().setLeaseId(getRandomUUID()))).verifyError(ShareStorageException)
null, new ShareRequestConditions().setLeaseId(namer.getRandomUuid()))).verifyError(ShareStorageException)
}

def "Delete file"() {
Expand Down Expand Up @@ -603,7 +604,7 @@ class DirectoryAsyncAPITests extends APISpec {

expect:
StepVerifier.create(primaryDirectoryAsyncClient.deleteFileWithResponse(fileName,
new ShareRequestConditions().setLeaseId(getRandomUUID())))
new ShareRequestConditions().setLeaseId(namer.getRandomUuid())))
.verifyError(ShareStorageException)
}

Expand All @@ -612,7 +613,7 @@ class DirectoryAsyncAPITests extends APISpec {
def snapshot = OffsetDateTime.of(LocalDateTime.of(2000, 1, 1,
1, 1), ZoneOffset.UTC).toString()
when:
def shareSnapshotClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath).snapshot(snapshot).buildDirectoryAsyncClient()
def shareSnapshotClient = directoryBuilderHelper(shareName, directoryPath).snapshot(snapshot).buildDirectoryAsyncClient()
then:
snapshot == shareSnapshotClient.getShareSnapshotId()
}
Expand Down
Loading

0 comments on commit 153351f

Please sign in to comment.