Skip to content

Commit

Permalink
Add testcase for dfs ep
Browse files Browse the repository at this point in the history
  • Loading branch information
nakulkar-msft committed Jul 3, 2023
1 parent 66969f3 commit 5e887b4
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/copyEnumeratorInit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestValidateSourceFileDoesNotExist(t *testing.T) {

// List
rawBlobURLWithSAS := scenarioHelper{}.getRawBlobURLWithSAS(a, containerName, fileName)
blobTraverser := newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None())
blobTraverser := newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None(), false)

cca := CookedCopyCmdArgs{StripTopDir: false, Recursive: false}
err := cca.validateSourceDir(blobTraverser)
Expand All @@ -156,7 +156,7 @@ func TestValidateSourceWithWildCard(t *testing.T) {

// List
rawBlobURLWithSAS := scenarioHelper{}.getRawBlobURLWithSAS(a, containerName, dirName)
blobTraverser := newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None())
blobTraverser := newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None(), false)

// dir but recursive flag not set - fail
cca := CookedCopyCmdArgs{StripTopDir: true, Recursive: false}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zt_copy_blob_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestDownloadAccount(t *testing.T) {

// Traverse the account ahead of time and determine the relative paths for testing.
relPaths := make([]string, 0) // Use a map for easy lookup
blobTraverser := newBlobAccountTraverser(&rawBSU, p, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None())
blobTraverser := newBlobAccountTraverser(&rawBSU, p, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None(), false)
processor := func(object StoredObject) error {
// Append the container name to the relative path
relPath := "/" + object.ContainerName + "/" + object.relativePath
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestDownloadAccountWildcard(t *testing.T) {

// Traverse the account ahead of time and determine the relative paths for testing.
relPaths := make([]string, 0) // Use a map for easy lookup
blobTraverser := newBlobAccountTraverser(&rawBSU, p, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None())
blobTraverser := newBlobAccountTraverser(&rawBSU, p, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None(), false)
processor := func(object StoredObject) error {
// Append the container name to the relative path
relPath := "/" + object.ContainerName + "/" + object.relativePath
Expand Down
5 changes: 3 additions & 2 deletions cmd/zt_generic_service_traverser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestServiceTraverserWithManyObjects(t *testing.T) {
// construct a blob account traverser
blobPipeline := azblob.NewPipeline(azblob.NewAnonymousCredential(), azblob.PipelineOptions{})
rawBSU := scenarioHelper{}.getRawBlobServiceURLWithSAS(a)
blobAccountTraverser := newBlobAccountTraverser(&rawBSU, blobPipeline, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None())
blobAccountTraverser := newBlobAccountTraverser(&rawBSU, blobPipeline, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None(), false)

// invoke the blob account traversal with a dummy processor
blobDummyProcessor := dummyProcessor{}
Expand Down Expand Up @@ -278,7 +278,8 @@ func TestServiceTraverserWithWildcards(t *testing.T) {
blobPipeline := azblob.NewPipeline(azblob.NewAnonymousCredential(), azblob.PipelineOptions{})
rawBSU := scenarioHelper{}.getRawBlobServiceURLWithSAS(a)
rawBSU.Path = "/objectmatch*" // set the container name to contain a wildcard
blobAccountTraverser := newBlobAccountTraverser(&rawBSU, blobPipeline, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None())
blobAccountTraverser := newBlobAccountTraverser(&rawBSU, blobPipeline, ctx, false, func(common.EntityType) {}, false, common.CpkOptions{}, common.EPreservePermissionsOption.None(), false)


// invoke the blob account traversal with a dummy processor
blobDummyProcessor := dummyProcessor{}
Expand Down
67 changes: 67 additions & 0 deletions cmd/zt_traverser_blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,73 @@ func TestIsDestDirWithBlobEP(t *testing.T) {
a.Nil(err)
}

func TestIsDestDirWithDFSEP(t *testing.T) {
a := assert.New(t)
bfsu := GetBFSSU()

// Generate source container and blobs
fileSystemURL, fileSystemName := createNewFilesystem(a, bfsu)
defer deleteFilesystem(a, fileSystemURL)
a.NotNil(fileSystemURL)

parentDirName := "dest_dir"
parentDirURL := fileSystemURL.NewDirectoryURL(parentDirName)
_, err := parentDirURL.Create(ctx, true)
a.Nil(err)

ctx := context.WithValue(context.TODO(), ste.ServiceAPIVersionOverride, ste.DefaultServiceApiVersion)
p := azblob.NewPipeline(azblob.NewAnonymousCredential(), azblob.PipelineOptions{})

// List
rawBlobURLWithSAS := scenarioHelper{}.getRawBlobURLWithSAS(a, fileSystemName, parentDirName)
blobTraverser := newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None(), true)

// a directory with name parentDirName exists on target. So irrespective of
// isSource, IsDirectory() should return true.
isDir, err := blobTraverser.IsDirectory(true)
a.True(isDir)
a.Nil(err)

isDir, err = blobTraverser.IsDirectory(false)
a.True(isDir)
a.Nil(err)

//===================================================================//

// With a directory that does not exist, without path separator.
parentDirName = "dirDoesNotExist"
rawBlobURLWithSAS = scenarioHelper{}.getRawBlobURLWithSAS(a, fileSystemName, parentDirName)
blobTraverser = newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None(), true)

// The directory does not exist, so IsDirectory()
// should return false, in all cases
isDir, err = blobTraverser.IsDirectory(true)
a.False(isDir)
a.Nil(err)

isDir, err = blobTraverser.IsDirectory(false)
a.False(isDir)
a.Nil(err)

//===================================================================//

// With a directory that does not exist, with path separator
parentDirNameWithSeparator := "dirDoesNotExist\\"
rawBlobURLWithSAS = scenarioHelper{}.getRawBlobURLWithSAS(a, fileSystemName, parentDirNameWithSeparator)
blobTraverser = newBlobTraverser(&rawBlobURLWithSAS, p, ctx, true, true, func(common.EntityType) {}, false, common.CpkOptions{}, false, false, false, common.EPreservePermissionsOption.None(), true)

// The directory does not exist, but with a path separator
// we should identify it as a directory.
isDir, err = blobTraverser.IsDirectory(true)
a.True(isDir)
a.Nil(err)

isDir, err = blobTraverser.IsDirectory(false)
a.True(isDir)
a.Nil(err)

}

func TestIsSourceFileExists(t *testing.T) {
a := assert.New(t)
bsu := getBSU()
Expand Down

0 comments on commit 5e887b4

Please sign in to comment.