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

Making implicit-explicit dir test package parallel #1851

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 0 deletions tools/integration_tests/explicit_dir/explicit_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup"
)

const DirForExplicitDirTests = "dirForExplicitDirTests"

func TestMain(m *testing.M) {
setup.ParseSetUpFlags()

Expand Down
12 changes: 5 additions & 7 deletions tools/integration_tests/explicit_dir/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import (
)

func TestListOnlyExplicitObjectsFromBucket(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

testDir := setup.SetupTestDirectory(DirForExplicitDirTests)
// Directory Structure
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
// testBucket/implicitDirectory -- Dir
// testBucket/implicitDirectory/fileInImplicitDir1 -- File
Expand All @@ -40,10 +38,10 @@ func TestListOnlyExplicitObjectsFromBucket(t *testing.T) {
// testBucket/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/explicitDirectory/fileInExplicitDir2 -- File

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure()
implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(t)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForExplicitDirTests)
implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(DirForExplicitDirTests, t)

err := filepath.WalkDir(setup.MntDir(), func(path string, dir fs.DirEntry, err error) error {
err := filepath.WalkDir(testDir, func(path string, dir fs.DirEntry, err error) error {
if err != nil {
fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err)
return err
Expand All @@ -60,7 +58,7 @@ func TestListOnlyExplicitObjectsFromBucket(t *testing.T) {
}

// Check if mntDir has correct objects.
if path == setup.MntDir() {
if path == testDir {
// numberOfObjects - 2
if len(objs) != implicit_and_explicit_dir_setup.NumberOfExplicitObjects {
t.Errorf("Incorrect number of objects in the bucket.")
Expand Down
124 changes: 56 additions & 68 deletions tools/integration_tests/implicit_dir/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,116 +25,104 @@ import (
)

// Directory Structure
// testBucket/implicitDirectory -- Dir
// testBucket/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteNonEmptyImplicitDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure()

dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory)
dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t)
}

// Directory Structure
// testBucket/implicitDirectory -- Dir
// testBucket/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteNonEmptyImplicitSubDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure()
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)

subDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory)
subDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(subDirPath, implicit_and_explicit_dir_setup.ImplicitSubDirectory, t)
}

// Directory Structure
// testBucket/implicitDirectory -- Dir
// testBucket/implicitDirectory/explicitDirInImplicitDir -- Dir
// testBucket/implicitDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File
// testBucket/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/explicitDirInImplicitDir -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure()
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)

explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir)
explicitDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir)

operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitDir, explicitDirPath, PrefixFileInExplicitDirInImplicitDir, t)

dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory)
dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t)
}

// Directory Structure
// testBucket/implicitDirectory -- Dir
// testBucket/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir -- Dir
// testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File
// testBucket/dirForImplicitDirTests/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir -- Dir
// testBucket/dirForImplicitDirTests/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File
func TestDeleteImplicitDirWithImplicitSubDirContainingExplicitDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure()
explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir)
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure(DirForImplicitDirTests)
explicitDirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir)

operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitSubDir, explicitDirPath, PrefixFileInExplicitDirInImplicitSubDir, t)

dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory)
dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ImplicitDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t)
}

// Directory Structure
// testBucket/explicitDirectory -- Dir
// testBucket/explictFile -- File
// testBucket/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/explicitDirectory/fileInExplicitDir2 -- File
// testBucket/explicitDirectory/implicitDirectory -- Dir
// testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/explictFile -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/fileInExplicitDir2 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteImplicitDirInExplicitDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(t)
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(DirForImplicitDirTests, t)

dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory, implicit_and_explicit_dir_setup.ImplicitDirectory)
dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ExplicitDirectory, implicit_and_explicit_dir_setup.ImplicitDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t)
}

// Directory Structure
// testBucket/explicitDirectory -- Dir
// testBucket/explictFile -- File
// testBucket/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/explicitDirectory/fileInExplicitDir2 -- File
// testBucket/explicitDirectory/implicitDirectory -- Dir
// testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/explictFile -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/fileInExplicitDir1 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/fileInExplicitDir2 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory -- Dir
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir
// testBucket/dirForImplicitDirTests/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File
func TestDeleteExplicitDirContainingImplicitSubDir(t *testing.T) {
// Clean the mountedDirectory before running test.
setup.CleanMntDir()

implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(t)
testDir := setup.SetupTestDirectory(DirForImplicitDirTests)
implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(DirForImplicitDirTests, t)

dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory)
dirPath := path.Join(testDir, implicit_and_explicit_dir_setup.ExplicitDirectory)

implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const PrefixFileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir"
const PrefixFileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir"
const NumberOfFilesInExplicitDirInImplicitSubDir = 1
const NumberOfFilesInExplicitDirInImplicitDir = 1
const DirForImplicitDirTests = "dirForImplicitDirTests"

func TestMain(m *testing.M) {
setup.ParseSetUpFlags()
Expand Down
Loading
Loading