From 935ad7365cd973c5b049b7a7964deb89af3340c6 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 13:03:34 +0000 Subject: [PATCH 01/34] adding delete tests --- .../implicit_dir/delete_test.go | 46 +++++++++++++++++++ .../implicit_dir/implicit_dir_test.go | 2 + 2 files changed, 48 insertions(+) create mode 100644 tools/integration_tests/implicit_dir/delete_test.go diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go new file mode 100644 index 0000000000..63c856bb65 --- /dev/null +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -0,0 +1,46 @@ +// Copyright 2023 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Provide test for deleting implicit directory. +package implicit_dir_test + +import ( + "os" + "path" + "testing" + + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" +) + +func TestDeleteNonEmptyImplicitDir(t *testing.T) { + // Directory Structure + // testBucket/implicitDirectory -- Dir + // testBucket/implicitDirectory/fileInImplicitDir1 -- File + // testBucket/implicitDirectory/implicitSubDirectory -- Dir + // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + dirPath := path.Join(setup.MntDir(), ImplicitDirectory) + err := os.RemoveAll(dirPath) + if err != nil { + t.Errorf("Error in deleting non-empty implicit directory.") + } + + dir, err := os.Stat(dirPath) + if err == nil && dir.Name() == ImplicitDirectory && dir.IsDir() { + t.Errorf("Directory is not deleted.") + } +} diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index a038acd775..6d35eb6525 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -21,6 +21,8 @@ import ( "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) +const ImplicitDirectory = "implicitDirectory" + func TestMain(m *testing.M) { flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} From d1f93ed5380f28500666ff77e77326454250f1f8 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 13:12:12 +0000 Subject: [PATCH 02/34] adding delete tests --- .../implicit_dir/delete_test.go | 21 +++++++++++++++++++ .../implicit_dir/implicit_dir_test.go | 1 + 2 files changed, 22 insertions(+) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 63c856bb65..3dc55f591a 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -44,3 +44,24 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { t.Errorf("Directory is not deleted.") } } + +func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { + // Directory Structure + // testBucket/implicitDirectory -- Dir + // testBucket/implicitDirectory/fileInImplicitDir1 -- File + // testBucket/implicitDirectory/implicitSubDirectory -- Dir + // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + subdirPath := path.Join(setup.MntDir(), ImplicitDirectory, ImplicitSubDirectory) + err := os.RemoveAll(subdirPath) + if err != nil { + t.Errorf("Error in deleting non-empty implicit directory.") + } + + subdir, err := os.Stat(subdirPath) + if err == nil && subdir.Name() == ImplicitDirectory && subdir.IsDir() { + t.Errorf("Directory is not deleted.") + } +} diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 6d35eb6525..55478ff377 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -22,6 +22,7 @@ import ( ) const ImplicitDirectory = "implicitDirectory" +const ImplicitSubDirectory = "implicitSubDirectory " func TestMain(m *testing.M) { flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} From a4ec6668058adb2f1ddbacda4d3414df4e2fe1e3 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 13:39:04 +0000 Subject: [PATCH 03/34] small fix --- tools/integration_tests/implicit_dir/implicit_dir_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 55478ff377..8087acfa8c 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -22,7 +22,7 @@ import ( ) const ImplicitDirectory = "implicitDirectory" -const ImplicitSubDirectory = "implicitSubDirectory " +const ImplicitSubDirectory = "implicitSubDirectory" func TestMain(m *testing.M) { flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} From 6ee2cdb8e3ee3cbc62c3d1728de3f334dde97321 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 13:40:26 +0000 Subject: [PATCH 04/34] small fix --- tools/integration_tests/implicit_dir/delete_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 3dc55f591a..7a73d48331 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -61,7 +61,7 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { } subdir, err := os.Stat(subdirPath) - if err == nil && subdir.Name() == ImplicitDirectory && subdir.IsDir() { + if err == nil && subdir.Name() == ImplicitSubDirectory && subdir.IsDir() { t.Errorf("Directory is not deleted.") } } From 09116276c8d46fe37b75bc2a63cc452755eeeda0 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:03:12 +0000 Subject: [PATCH 05/34] testing --- .../implicit_dir/delete_test.go | 110 +++++++++++++----- .../implicit_dir/implicit_dir_test.go | 6 +- .../implicit_and_explicit_dir_setup.go | 26 +++++ 3 files changed, 109 insertions(+), 33 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 7a73d48331..eb6652ffe6 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,52 +16,100 @@ package implicit_dir_test import ( - "os" "path" "testing" + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/operations" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) +// Directory Structure +// testBucket/implicitDirectory -- Dir +// testBucket/implicitDirectory/fileInImplicitDir1 -- File +// testBucket/implicitDirectory/implicitSubDirectory -- Dir +// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitDir(t *testing.T) { - // Directory Structure - // testBucket/implicitDirectory -- Dir - // testBucket/implicitDirectory/fileInImplicitDir1 -- File - // testBucket/implicitDirectory/implicitSubDirectory -- Dir - // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - dirPath := path.Join(setup.MntDir(), ImplicitDirectory) - err := os.RemoveAll(dirPath) - if err != nil { - t.Errorf("Error in deleting non-empty implicit directory.") - } - - dir, err := os.Stat(dirPath) - if err == nil && dir.Name() == ImplicitDirectory && dir.IsDir() { - t.Errorf("Directory is not deleted.") - } + dirPath := path.Join(setup.MntDir(), 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 func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { - // Directory Structure - // testBucket/implicitDirectory -- Dir - // testBucket/implicitDirectory/fileInImplicitDir1 -- File - // testBucket/implicitDirectory/implicitSubDirectory -- Dir - // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + subDirPath := path.Join(setup.MntDir(), 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 +func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) + + operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitDir, t) + dirPath := path.Join(setup.MntDir(), 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 +func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + + operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitSubDir, t) + + dirPath := path.Join(setup.MntDir(), 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 +func TestDeleteImplicitDirInExplicitDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) + + dirPath := path.Join(setup.MntDir(), 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) +} - subdirPath := path.Join(setup.MntDir(), ImplicitDirectory, ImplicitSubDirectory) - err := os.RemoveAll(subdirPath) - if err != nil { - t.Errorf("Error in deleting non-empty implicit directory.") - } +// 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 +func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) - subdir, err := os.Stat(subdirPath) - if err == nil && subdir.Name() == ImplicitSubDirectory && subdir.IsDir() { - t.Errorf("Directory is not deleted.") - } + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitFile, t) } diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 8087acfa8c..33a5d281cd 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -21,8 +21,10 @@ import ( "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) -const ImplicitDirectory = "implicitDirectory" -const ImplicitSubDirectory = "implicitSubDirectory" +const ExplicitDirInImplicitDir = "explicitDirInImplicitDir" +const ExplicitDirInImplicitSubDir = "explicitDirInImplicitSubDir" +const FileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" +const FileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" func TestMain(m *testing.M) { flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 6a0294ae6b..ee245e1f4a 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -61,6 +61,18 @@ func RunTestsForImplicitDirAndExplicitDir(flags [][]string, m *testing.M) { os.Exit(successCode) } +func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) { + err := os.RemoveAll(dirPath) + if err != nil { + t.Errorf("Error in deleting non-empty implicit directory.") + } + + dir, err := os.Stat(dirPath) + if err == nil && dir.Name() == dirName && dir.IsDir() { + t.Errorf("Directory is not deleted.") + } +} + func CreateImplicitDirectory() { // Implicit Directory Structure // testBucket/implicitDirectory -- Dir @@ -90,3 +102,17 @@ func CreateExplicitDirectory(t *testing.T) { t.Errorf("Create file at %q: %v", setup.MntDir(), err) } } + +func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { + // 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 + CreateExplicitDirectory(t) + dirPathInBucket := path.Join(setup.TestBucket(), ExplicitDirectory) + setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket) +} From 3686b6c5e3e515175cbdb0ad13c24538c4d4bf2a Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:12:57 +0000 Subject: [PATCH 06/34] testing --- .../implicit_dir/delete_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index eb6652ffe6..9ee41646e2 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,6 +16,7 @@ package implicit_dir_test import ( + "os" "path" "testing" @@ -46,6 +47,9 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { subDirPath := path.Join(setup.MntDir(), 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) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -63,6 +67,9 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -80,6 +87,9 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -96,6 +106,9 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), 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) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -112,4 +125,7 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitFile, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } From 8a2210a3bd9463d2d3e1f0e2ed7e75e879507672 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:23:27 +0000 Subject: [PATCH 07/34] testing --- .../implicit_dir/delete_test.go | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 9ee41646e2..0e044e026a 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -72,26 +72,6 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { os.RemoveAll(setup.MntDir()) } -// 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 -func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - - operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitSubDir, t) - - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} - // Directory Structure // testBucket/explicitDirectory -- Dir // testBucket/explictFile -- File @@ -129,3 +109,23 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { // Cleaning the bucket. os.RemoveAll(setup.MntDir()) } + +// 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 +func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + + operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitSubDir, t) + + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) +} From d832274ce93fd0fcd00c3df526f82be521f73ab8 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:26:08 +0000 Subject: [PATCH 08/34] testing --- .../implicit_dir/delete_test.go | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 0e044e026a..0df3a4ebf5 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -52,6 +52,26 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { os.RemoveAll(setup.MntDir()) } +// 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 +func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) + + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) +} + // Directory Structure // testBucket/implicitDirectory -- Dir // testBucket/implicitDirectory/explicitDirInImplicitDir -- Dir @@ -109,23 +129,3 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { // Cleaning the bucket. os.RemoveAll(setup.MntDir()) } - -// 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 -func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - - operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitSubDir, t) - - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} From cec45b8104be273ed320c4259b8aa586becc8a30 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:29:14 +0000 Subject: [PATCH 09/34] testing --- .../implicit_dir/delete_test.go | 57 +++++++++++++------ .../persistent_mounting/scripts/go_to_root.sh | 0 2 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 0df3a4ebf5..0af82f43cc 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -31,10 +31,16 @@ import ( // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectory() dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -43,6 +49,9 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectory() subDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) @@ -53,17 +62,20 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.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 -func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { +// 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 +func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) + operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) @@ -73,17 +85,20 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.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 -func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { +// 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 +func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitDir, t) + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) @@ -102,6 +117,9 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirInExplicitDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory, implicit_and_explicit_dir_setup.ImplicitDirectory) @@ -121,6 +139,9 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) diff --git a/tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh b/tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh new file mode 100644 index 0000000000..e69de29bb2 From fa9842d9b0909fa923e76d3e2dea6e3437786dc8 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:40:27 +0000 Subject: [PATCH 10/34] testing --- .../implicit_dir/delete_test.go | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 0af82f43cc..e411e4b57a 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,6 +16,7 @@ package implicit_dir_test import ( + "log" "os" "path" "testing" @@ -69,9 +70,6 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) @@ -79,9 +77,6 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -92,19 +87,19 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir -- Dir // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) + dir, err := os.Stat(d) + if err != nil { + log.Print(dir.Name()) + } + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -141,7 +136,7 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { // Cleaning the bucket. os.RemoveAll(setup.MntDir()) - + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) From 287b28af9b2f201c18d87145df829c06edecfb37 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:41:26 +0000 Subject: [PATCH 11/34] testing --- tools/integration_tests/implicit_dir/delete_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index e411e4b57a..deba603208 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -92,7 +92,7 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) dir, err := os.Stat(d) - if err != nil { + if err == nil { log.Print(dir.Name()) } From fad47a440c952caffedef9ac09bd9b666bd3953a Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:44:00 +0000 Subject: [PATCH 12/34] testing --- .../implicit_dir/delete_test.go | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index deba603208..0b56bad8ec 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -32,16 +32,10 @@ import ( // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectory() dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -50,16 +44,10 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectory() subDirPath := path.Join(setup.MntDir(), 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) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -90,8 +78,9 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) + d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) dir, err := os.Stat(d) + log.Print(err) if err == nil { log.Print(dir.Name()) } @@ -112,16 +101,10 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirInExplicitDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), 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) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -134,14 +117,8 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitFile, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } From cbe8a121e809fc6b103144b2e50debee37915746 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 16:48:02 +0000 Subject: [PATCH 13/34] testing --- tools/integration_tests/implicit_dir/delete_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 0b56bad8ec..5278b8d752 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -79,10 +79,10 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - dir, err := os.Stat(d) + dir, err := os.ReadDir(d) log.Print(err) if err == nil { - log.Print(dir.Name()) + log.Print(len(dir)) } operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) From ddac411dc1b1fd0b7bef9bf9f9feae670d1cbe99 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 17:00:40 +0000 Subject: [PATCH 14/34] testing --- tools/build_gcsfuse/main.go | 6 +++--- .../implicit_dir/delete_test.go | 19 ++++++++----------- .../implicit_dir/fileInImplicitDir1 | 1 + 3 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 tools/integration_tests/implicit_dir/fileInImplicitDir1 diff --git a/tools/build_gcsfuse/main.go b/tools/build_gcsfuse/main.go index 3636524239..3b73ecd07a 100644 --- a/tools/build_gcsfuse/main.go +++ b/tools/build_gcsfuse/main.go @@ -133,10 +133,10 @@ func buildBinaries(dstDir, srcDir, version string, buildArgs []string) (err erro cmd := exec.Command( "go", "build", - "-o", - path.Join(dstDir, bin.outputPath), "-C", - srcDir) + srcDir, + "-o", + path.Join(dstDir, bin.outputPath)) if path.Base(bin.outputPath) == "gcsfuse" { cmd.Args = append( diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 5278b8d752..68c495bb45 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,12 +16,10 @@ package implicit_dir_test import ( - "log" "os" "path" "testing" - "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/operations" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) @@ -59,9 +57,12 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - operations.CreateDirectoryWithNFiles(1, explicitDir, FileInExplicitDirInImplicitDir, t) + err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) + if err != nil { + t.Errorf("Error in creating directory: %v", err) + } dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) @@ -78,15 +79,11 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - d := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - dir, err := os.ReadDir(d) - log.Print(err) - if err == nil { - log.Print(len(dir)) + err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) + if err != nil { + t.Errorf("Error in creating directory: %v", err) } - operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) } diff --git a/tools/integration_tests/implicit_dir/fileInImplicitDir1 b/tools/integration_tests/implicit_dir/fileInImplicitDir1 new file mode 100644 index 0000000000..fa1aac1f94 --- /dev/null +++ b/tools/integration_tests/implicit_dir/fileInImplicitDir1 @@ -0,0 +1 @@ +This is from directory fileInImplicitDir1 file implicitDirectory From d686fa36e7cdad3e05ed2e21964f67d89965fab7 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 17:06:17 +0000 Subject: [PATCH 15/34] small fix --- tools/integration_tests/implicit_dir/delete_test.go | 2 +- tools/integration_tests/implicit_dir/fileInImplicitDir1 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 tools/integration_tests/implicit_dir/fileInImplicitDir1 diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 68c495bb45..fb8048f0ad 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -117,5 +117,5 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitFile, t) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) } diff --git a/tools/integration_tests/implicit_dir/fileInImplicitDir1 b/tools/integration_tests/implicit_dir/fileInImplicitDir1 deleted file mode 100644 index fa1aac1f94..0000000000 --- a/tools/integration_tests/implicit_dir/fileInImplicitDir1 +++ /dev/null @@ -1 +0,0 @@ -This is from directory fileInImplicitDir1 file implicitDirectory From b659de892f830635e92f52ab0d785881b5e3d0e8 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Mon, 19 Jun 2023 17:18:32 +0000 Subject: [PATCH 16/34] small fix --- tools/integration_tests/implicit_dir/fileInImplicitDir2 | 1 + .../implicit_and_explicit_dir_setup.go | 1 + 2 files changed, 2 insertions(+) create mode 100644 tools/integration_tests/implicit_dir/fileInImplicitDir2 diff --git a/tools/integration_tests/implicit_dir/fileInImplicitDir2 b/tools/integration_tests/implicit_dir/fileInImplicitDir2 new file mode 100644 index 0000000000..568260e350 --- /dev/null +++ b/tools/integration_tests/implicit_dir/fileInImplicitDir2 @@ -0,0 +1 @@ +This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2 diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index ee245e1f4a..e6099fab52 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -112,6 +112,7 @@ func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + os.RemoveAll(setup.MntDir()) CreateExplicitDirectory(t) dirPathInBucket := path.Join(setup.TestBucket(), ExplicitDirectory) setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket) From 4d6d364f5f24a4a6734d6ecbcec3e842b88b2bac Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 05:39:50 +0000 Subject: [PATCH 17/34] fixed tests --- tools/build_gcsfuse/main.go | 6 +++--- .../implicit_dir/delete_test.go | 18 ++++++++++++++++++ .../implicit_dir/fileInImplicitDir2 | 1 - .../implicit_dir/list_test.go | 3 +++ .../implicit_and_explicit_dir_setup.go | 1 - 5 files changed, 24 insertions(+), 5 deletions(-) delete mode 100644 tools/integration_tests/implicit_dir/fileInImplicitDir2 diff --git a/tools/build_gcsfuse/main.go b/tools/build_gcsfuse/main.go index 3b73ecd07a..3636524239 100644 --- a/tools/build_gcsfuse/main.go +++ b/tools/build_gcsfuse/main.go @@ -133,10 +133,10 @@ func buildBinaries(dstDir, srcDir, version string, buildArgs []string) (err erro cmd := exec.Command( "go", "build", - "-C", - srcDir, "-o", - path.Join(dstDir, bin.outputPath)) + path.Join(dstDir, bin.outputPath), + "-C", + srcDir) if path.Base(bin.outputPath) == "gcsfuse" { cmd.Args = append( diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index fb8048f0ad..e9ac60acec 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -34,6 +34,9 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -46,6 +49,9 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { subDirPath := path.Join(setup.MntDir(), 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) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -66,6 +72,9 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -86,6 +95,9 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -102,6 +114,9 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), 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) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -118,4 +133,7 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } diff --git a/tools/integration_tests/implicit_dir/fileInImplicitDir2 b/tools/integration_tests/implicit_dir/fileInImplicitDir2 deleted file mode 100644 index 568260e350..0000000000 --- a/tools/integration_tests/implicit_dir/fileInImplicitDir2 +++ /dev/null @@ -1 +0,0 @@ -This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2 diff --git a/tools/integration_tests/implicit_dir/list_test.go b/tools/integration_tests/implicit_dir/list_test.go index 39061839a1..fd0a37884e 100644 --- a/tools/integration_tests/implicit_dir/list_test.go +++ b/tools/integration_tests/implicit_dir/list_test.go @@ -137,4 +137,7 @@ func TestListImplicitObjectsFromBucket(t *testing.T) { t.Errorf("error walking the path : %v\n", err) return } + + // Cleaning the bucket. + os.RemoveAll(setup.MntDir()) } diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index e6099fab52..ee245e1f4a 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -112,7 +112,6 @@ func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - os.RemoveAll(setup.MntDir()) CreateExplicitDirectory(t) dirPathInBucket := path.Join(setup.TestBucket(), ExplicitDirectory) setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket) From 1fc743362fb47672abef81c20be6d4d921d2860e Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 05:46:58 +0000 Subject: [PATCH 18/34] remove unnecessary tests --- .../util/mounting/persistent_mounting/scripts/go_to_root.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh diff --git a/tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh b/tools/integration_tests/util/mounting/persistent_mounting/scripts/go_to_root.sh deleted file mode 100644 index e69de29bb2..0000000000 From 0b0a0f5318c73699280790d6d0c677a1c02a8760 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 07:09:32 +0000 Subject: [PATCH 19/34] testing --- .../implicit_dir/delete_test.go | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index e9ac60acec..a903963f62 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -20,6 +20,7 @@ import ( "path" "testing" + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/operations" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) @@ -33,6 +34,7 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) // Cleaning the bucket. @@ -48,6 +50,7 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() subDirPath := path.Join(setup.MntDir(), 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) // Cleaning the bucket. @@ -63,14 +66,13 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) - if err != nil { - t.Errorf("Error in creating directory: %v", err) - } + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) // Cleaning the bucket. @@ -86,14 +88,26 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + //time.Sleep(1 * time.Minute) + err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) if err != nil { t.Errorf("Error in creating directory: %v", err) } + //time.Sleep(1 * time.Minute) + + //filePath := path.Join(explicitDirPath, FileInExplicitDirInImplicitSubDir) + //_, err = os.Create(filePath) + //if err != nil { + // t.Errorf("Create file at %q: %v", explicitDirPath, err) + //} + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) // Cleaning the bucket. @@ -113,6 +127,7 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), 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) // Cleaning the bucket. @@ -132,6 +147,7 @@ func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) // Cleaning the bucket. From 6116945c7831386e5251b7c6928af8a5b1177e66 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 07:10:46 +0000 Subject: [PATCH 20/34] testing --- tools/build_gcsfuse/main.go | 6 +++--- .../implicit_and_explicit_dir_setup.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/build_gcsfuse/main.go b/tools/build_gcsfuse/main.go index 3636524239..3b73ecd07a 100644 --- a/tools/build_gcsfuse/main.go +++ b/tools/build_gcsfuse/main.go @@ -133,10 +133,10 @@ func buildBinaries(dstDir, srcDir, version string, buildArgs []string) (err erro cmd := exec.Command( "go", "build", - "-o", - path.Join(dstDir, bin.outputPath), "-C", - srcDir) + srcDir, + "-o", + path.Join(dstDir, bin.outputPath)) if path.Base(bin.outputPath) == "gcsfuse" { cmd.Args = append( diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index ee245e1f4a..60fc4a1da0 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -112,6 +112,7 @@ func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + CreateExplicitDirectory(t) dirPathInBucket := path.Join(setup.TestBucket(), ExplicitDirectory) setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket) From f36f606bb16a6c3e4931e1549205e44b1b64bcc1 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 16:09:19 +0000 Subject: [PATCH 21/34] testing --- .../implicit_dir/create_objects.sh | 21 ++ .../implicit_dir/delete_objects.sh | 22 ++ .../implicit_dir/delete_test.go | 181 +++++++------- .../implicit_dir/implicit_dir_test.go | 2 +- .../implicit_dir/list_test.go | 231 +++++++++--------- tools/integration_tests/implicit_dir/test.go | 48 ++++ .../util/operations/dir_operations.go | 4 +- .../implicit_and_explicit_dir_setup.go | 22 +- .../testdata/create_object2.sh | 21 ++ tools/integration_tests/util/setup/setup.go | 2 +- 10 files changed, 338 insertions(+), 216 deletions(-) create mode 100644 tools/integration_tests/implicit_dir/create_objects.sh create mode 100644 tools/integration_tests/implicit_dir/delete_objects.sh create mode 100644 tools/integration_tests/implicit_dir/test.go create mode 100644 tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh diff --git a/tools/integration_tests/implicit_dir/create_objects.sh b/tools/integration_tests/implicit_dir/create_objects.sh new file mode 100644 index 0000000000..cfc7c30185 --- /dev/null +++ b/tools/integration_tests/implicit_dir/create_objects.sh @@ -0,0 +1,21 @@ +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Here $1 refers to the testBucket argument +echo "This is from directory fileInImplicitDir1 file implicitDirectory" >> fileInImplicitDir1 +# bucket/implicitDirectory/fileInImplicitDir1 +gsutil mv fileInImplicitDir1 gs://$1/implicitDirectory/ +echo "This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2" >> fileInImplicitDir2 +# bucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 +gsutil mv fileInImplicitDir2 gs://$1/implicitDirectory/implicitSubDirectory/ diff --git a/tools/integration_tests/implicit_dir/delete_objects.sh b/tools/integration_tests/implicit_dir/delete_objects.sh new file mode 100644 index 0000000000..14a1278987 --- /dev/null +++ b/tools/integration_tests/implicit_dir/delete_objects.sh @@ -0,0 +1,22 @@ +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Here $1 refers to the testBucket argument +gsutil rm -a gs://$1/** + +# If bucket is empty it will throw an CommandException. +if [ $? -eq 1 ]; then + echo "Bucket is already empty." + exit 0 +fi diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index a903963f62..9928f2a58e 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,7 +16,7 @@ package implicit_dir_test import ( - "os" + "fmt" "path" "testing" @@ -30,32 +30,26 @@ import ( // testBucket/implicitDirectory/fileInImplicitDir1 -- File // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File -func TestDeleteNonEmptyImplicitDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} - -// Directory Structure -// testBucket/implicitDirectory -- Dir -// testBucket/implicitDirectory/fileInImplicitDir1 -- File -// testBucket/implicitDirectory/implicitSubDirectory -- Dir -// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File -func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - - subDirPath := path.Join(setup.MntDir(), 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) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} +//func TestDeleteNonEmptyImplicitDir(t *testing.T) { +// implicit_and_explicit_dir_setup.CreateImplicitDirectory() +// +// dirPath := path.Join(setup.MntDir(), 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 +//func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { +// implicit_and_explicit_dir_setup.CreateImplicitDirectory() +// +// subDirPath := path.Join(setup.MntDir(), 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 @@ -69,14 +63,16 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitDir, t) + //err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) + //if err != nil { + // t.Errorf("Error in creating directory: %v", err) + //} + + operations.CreateDirectoryWithNFiles(1, explicitDirPath, "temp", t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -89,67 +85,74 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() - explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - - //time.Sleep(1 * time.Minute) - - err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) - if err != nil { - t.Errorf("Error in creating directory: %v", err) - } - - //time.Sleep(1 * time.Minute) - - //filePath := path.Join(explicitDirPath, FileInExplicitDirInImplicitSubDir) - //_, err = os.Create(filePath) + dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + fmt.Println(dir) + //_, err := os.Stat(dir) + //log.Print(err) + dir = path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) + //_, err = os.Stat(dir) + //log.Print(err) + //explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + + ////time.Sleep(1 * time.Minute) + // + //err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) //if err != nil { - // t.Errorf("Create file at %q: %v", explicitDirPath, err) + // t.Errorf("Error in creating directory: %v", err) //} - - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + // + ////time.Sleep(1 * time.Minute) + // + ////filePath := path.Join(explicitDirPath, FileInExplicitDirInImplicitSubDir) + ////_, err = os.Create(filePath) + ////if err != nil { + //// t.Errorf("Create file at %q: %v", explicitDirPath, err) + ////} + // + //dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + // + //implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) + //os.RemoveAll(setup.MntDir()) } -// 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 -func TestDeleteImplicitDirInExplicitDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) - - dirPath := path.Join(setup.MntDir(), 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) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} - -// 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 -func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) - - dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) - - implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) -} +//// 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 +//func TestDeleteImplicitDirInExplicitDir(t *testing.T) { +// implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) +// +// dirPath := path.Join(setup.MntDir(), 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) +// +// // Cleaning the bucket. +// os.RemoveAll(setup.MntDir()) +//} +// +//// 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 +//func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { +// implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) +// +// dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) +// +// implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) +// +// // Cleaning the bucket. +// os.RemoveAll(setup.MntDir()) +//} diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 33a5d281cd..d035a14484 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -27,7 +27,7 @@ const FileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" const FileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" func TestMain(m *testing.M) { - flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} + flags := [][]string{{"--enable-storage-client-library=false", "--implicit-dirs"}, {"--implicit-dirs"}} implicit_and_explicit_dir_setup.RunTestsForImplicitDirAndExplicitDir(flags, m) } diff --git a/tools/integration_tests/implicit_dir/list_test.go b/tools/integration_tests/implicit_dir/list_test.go index fd0a37884e..d7e8386b4a 100644 --- a/tools/integration_tests/implicit_dir/list_test.go +++ b/tools/integration_tests/implicit_dir/list_test.go @@ -15,129 +15,118 @@ package implicit_dir_test import ( - "fmt" - "io/fs" - "log" - "os" - "path/filepath" "testing" - - "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" - "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) func TestListImplicitObjectsFromBucket(t *testing.T) { - // Directory Structure - // testBucket/implicitDirectory -- Dir - // testBucket/implicitDirectory/fileInImplicitDir1 -- File - // testBucket/implicitDirectory/implicitSubDirectory -- Dir - // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - // testBucket/explicitDirectory -- Dir - // testBucket/explicitFile -- File - // testBucket/explicitDirectory/fileInExplicitDir1 -- File - // testBucket/explicitDirectory/fileInExplicitDir2 -- File - - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) - - // Delete objects from bucket after testing. - defer os.RemoveAll(setup.MntDir()) - - err := filepath.WalkDir(setup.MntDir(), 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 - } - - // The object type is not directory. - if !dir.IsDir() { - return nil - } - - objs, err := os.ReadDir(path) - if err != nil { - log.Fatal(err) - } - - // Check if mntDir has correct objects. - if path == setup.MntDir() { - // numberOfObjects - 3 - if len(objs) != implicit_and_explicit_dir_setup.NumberOfTotalObjects { - t.Errorf("Incorrect number of objects in the bucket.") - } - - // testBucket/explicitDir -- Dir - if objs[0].Name() != implicit_and_explicit_dir_setup.ExplicitDirectory || objs[0].IsDir() != true { - t.Errorf("Listed incorrect object") - } - // testBucket/explicitFile -- File - if objs[1].Name() != implicit_and_explicit_dir_setup.ExplicitFile || objs[1].IsDir() != false { - t.Errorf("Listed incorrect object") - } - - // testBucket/implicitDir -- Dir - if objs[2].Name() != implicit_and_explicit_dir_setup.ImplicitDirectory || objs[2].IsDir() != true { - t.Errorf("Listed incorrect object") - } - } - - // Check if explictDir directory has correct data. - if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ExplicitDirectory { - // numberOfObjects - 2 - if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInExplicitDirectory { - t.Errorf("Incorrect number of objects in the explicitDirectory.") - } - - // testBucket/explicitDir/fileInExplicitDir1 -- File - if objs[0].Name() != implicit_and_explicit_dir_setup.FirstFileInExplicitDirectory || objs[0].IsDir() != false { - t.Errorf("Listed incorrect object") - } - - // testBucket/explicitDir/fileInExplicitDir2 -- File - if objs[1].Name() != implicit_and_explicit_dir_setup.SecondFileInExplicitDirectory || objs[1].IsDir() != false { - t.Errorf("Listed incorrect object") - } - return nil - } - - // Check if implicitDir directory has correct data. - if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitDirectory { - // numberOfObjects - 2 - if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitDirectory { - t.Errorf("Incorrect number of objects in the implicitDirectory.") - } - - // testBucket/implicitDir/fileInImplicitDir1 -- File - if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitDirectory || objs[0].IsDir() != false { - t.Errorf("Listed incorrect object") - } - // testBucket/implicitDir/implicitSubDirectory -- Dir - if objs[1].Name() != implicit_and_explicit_dir_setup.ImplicitSubDirectory || objs[1].IsDir() != true { - t.Errorf("Listed incorrect object") - } - return nil - } - - // Check if implicit sub directory has correct data. - if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitSubDirectory { - // numberOfObjects - 1 - if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitSubDirectory { - t.Errorf("Incorrect number of objects in the implicitSubDirectoryt.") - } - - // testBucket/implicitDir/implicitSubDir/fileInImplicitDir2 -- File - if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitSubDirectory || objs[0].IsDir() != false { - t.Errorf("Listed incorrect object") - } - return nil - } - return nil - }) - if err != nil { - t.Errorf("error walking the path : %v\n", err) - return - } - - // Cleaning the bucket. - os.RemoveAll(setup.MntDir()) + //// Directory Structure + //// testBucket/implicitDirectory -- Dir + //// testBucket/implicitDirectory/fileInImplicitDir1 -- File + //// testBucket/implicitDirectory/implicitSubDirectory -- Dir + //// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + //// testBucket/explicitDirectory -- Dir + //// testBucket/explicitFile -- File + //// testBucket/explicitDirectory/fileInExplicitDir1 -- File + //// testBucket/explicitDirectory/fileInExplicitDir2 -- File + // + //implicit_and_explicit_dir_setup.CreateImplicitDirectory() + //implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) + // + //// Delete objects from bucket after testing. + ////defer os.RemoveAll(setup.MntDir()) + // + //err := filepath.Walk(setup.MntDir(), func(path string, dir fs.FileInfo, err error) error { + // if err != nil { + // fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err) + // return err + // } + // + // // The object type is not directory. + // if !dir.IsDir() { + // return nil + // } + // + // objs, err := os.ReadDir(path) + // if err != nil { + // log.Fatal(err) + // } + // + // // Check if mntDir has correct objects. + // if path == setup.MntDir() { + // // numberOfObjects - 3 + // if len(objs) != implicit_and_explicit_dir_setup.NumberOfTotalObjects { + // t.Errorf("Incorrect number of objects in the bucket.") + // } + // + // // testBucket/explicitDir -- Dir + // if objs[0].Name() != implicit_and_explicit_dir_setup.ExplicitDirectory || objs[0].IsDir() != true { + // t.Errorf("Listed incorrect object") + // } + // // testBucket/explicitFile -- File + // if objs[1].Name() != implicit_and_explicit_dir_setup.ExplicitFile || objs[1].IsDir() != false { + // t.Errorf("Listed incorrect object") + // } + // + // // testBucket/implicitDir -- Dir + // if objs[2].Name() != implicit_and_explicit_dir_setup.ImplicitDirectory || objs[2].IsDir() != true { + // t.Errorf("Listed incorrect object") + // } + // } + // + // // Check if explictDir directory has correct data. + // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ExplicitDirectory { + // // numberOfObjects - 2 + // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInExplicitDirectory { + // t.Errorf("Incorrect number of objects in the explicitDirectory.") + // } + // + // // testBucket/explicitDir/fileInExplicitDir1 -- File + // if objs[0].Name() != implicit_and_explicit_dir_setup.FirstFileInExplicitDirectory || objs[0].IsDir() != false { + // t.Errorf("Listed incorrect object") + // } + // + // // testBucket/explicitDir/fileInExplicitDir2 -- File + // if objs[1].Name() != implicit_and_explicit_dir_setup.SecondFileInExplicitDirectory || objs[1].IsDir() != false { + // t.Errorf("Listed incorrect object") + // } + // return nil + // } + // + // // Check if implicitDir directory has correct data. + // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitDirectory { + // // numberOfObjects - 2 + // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitDirectory { + // t.Errorf("Incorrect number of objects in the implicitDirectory.") + // } + // + // // testBucket/implicitDir/fileInImplicitDir1 -- File + // if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitDirectory || objs[0].IsDir() != false { + // t.Errorf("Listed incorrect object") + // } + // // testBucket/implicitDir/implicitSubDirectory -- Dir + // if objs[1].Name() != implicit_and_explicit_dir_setup.ImplicitSubDirectory || objs[1].IsDir() != true { + // t.Errorf("Listed incorrect object") + // } + // return nil + // } + // + // // Check if implicit sub directory has correct data. + // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitSubDirectory { + // // numberOfObjects - 1 + // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitSubDirectory { + // t.Errorf("Incorrect number of objects in the implicitSubDirectoryt.") + // } + // + // // testBucket/implicitDir/implicitSubDir/fileInImplicitDir2 -- File + // if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitSubDirectory || objs[0].IsDir() != false { + // t.Errorf("Listed incorrect object") + // } + // return nil + // } + // return nil + //}) + //if err != nil { + // t.Errorf("error walking the path : %v\n", err) + // return + //} } diff --git a/tools/integration_tests/implicit_dir/test.go b/tools/integration_tests/implicit_dir/test.go new file mode 100644 index 0000000000..f60cf65f50 --- /dev/null +++ b/tools/integration_tests/implicit_dir/test.go @@ -0,0 +1,48 @@ +package main + +import ( + "log" + "os" + "path" + + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" +) + +func main() { + setup.RunScriptForTestData("delete_objects.sh", "tulsishah-test") + + setup.RunScriptForTestData("create_objects.sh", "tulsishah-test") + + err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) + if err != nil { + log.Printf("Error in creating directory: %v", err) + } + + filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") + _, err = os.Create(filePath) + if err != nil { + log.Printf("Create file at : %v", err) + } + + os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") + + setup.RunScriptForTestData("delete_objects.sh", "tulsishah-test") + + setup.RunScriptForTestData("create_objects.sh", "tulsishah-test") + + err = os.Mkdir("/usr/local/google/home/tulsishah/gcs/A", 777) + if err != nil { + log.Printf("Error in creating directory: %v", err) + } + + filePath = path.Join("/usr/local/google/home/tulsishah/gcs/A/a.txt") + _, err = os.Create(filePath) + if err != nil { + log.Printf("Create file at : %v", err) + } + + _, err = os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") + if err != nil { + log.Printf("Stating file at : %v", err) + } +} diff --git a/tools/integration_tests/util/operations/dir_operations.go b/tools/integration_tests/util/operations/dir_operations.go index e27ccc50cc..c3bac61971 100644 --- a/tools/integration_tests/util/operations/dir_operations.go +++ b/tools/integration_tests/util/operations/dir_operations.go @@ -22,8 +22,6 @@ import ( "path" "strconv" "testing" - - "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" ) func CopyDir(srcDirPath string, destDirPath string) (err error) { @@ -59,7 +57,7 @@ func RenameDir(dirName string, newDirName string) (err error) { } func CreateDirectoryWithNFiles(numberOfFiles int, dirPath string, prefix string, t *testing.T) { - err := os.Mkdir(dirPath, setup.FilePermission_0600) + err := os.Mkdir(dirPath, 777) if err != nil { t.Errorf("Error in creating directory: %v", err) } diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 60fc4a1da0..502c3e8a20 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -17,6 +17,7 @@ package implicit_and_explicit_dir_setup import ( "log" "os" + "os/exec" "path" "testing" @@ -62,7 +63,12 @@ func RunTestsForImplicitDirAndExplicitDir(flags [][]string, m *testing.M) { } func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) { - err := os.RemoveAll(dirPath) + cmd := exec.Command( + "rm", + "-r", + dirPath, + ) + _, err := cmd.CombinedOutput() if err != nil { t.Errorf("Error in deleting non-empty implicit directory.") } @@ -73,6 +79,20 @@ func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) } } +func CreateImplicitDirectory2() { + // Implicit Directory Structure + // testBucket/implicitDirectory -- Dir + // testBucket/implicitDirectory/fileInImplicitDir1 -- File + // testBucket/implicitDirectory/implicitSubDirectory -- Dir + // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + + // Clean the bucket. + setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/delete_objects.sh", setup.TestBucket()) + + // Create implicit directory in bucket for testing. + setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh", setup.TestBucket()) +} + func CreateImplicitDirectory() { // Implicit Directory Structure // testBucket/implicitDirectory -- Dir diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh new file mode 100644 index 0000000000..2ac7a61202 --- /dev/null +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh @@ -0,0 +1,21 @@ +# Copyright 2023 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Here $1 refers to the testBucket argument +echo "This is from directory fileInImplicitDir1 file implicitDirectory" >> fileInImplicitDir1 +# bucket/implicitDirectory/fileInImplicitDir1 +gsutil mv fileInImplicitDir1 gs://$1/implicitDirectory2/ +echo "This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2" >> fileInImplicitDir2 +# bucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 +gsutil mv fileInImplicitDir2 gs://$1/implicitDirectory2/implicitSubDirectory/ diff --git a/tools/integration_tests/util/setup/setup.go b/tools/integration_tests/util/setup/setup.go index 5f867ecaa1..e04249aa4b 100644 --- a/tools/integration_tests/util/setup/setup.go +++ b/tools/integration_tests/util/setup/setup.go @@ -169,7 +169,7 @@ func UnMount() error { func executeTest(m *testing.M) (successCode int) { successCode = m.Run() - os.RemoveAll(mntDir) + //os.RemoveAll(mntDir) return successCode } From cd21bf9b3fbf61581f30c828799cde41124d1617 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 20 Jun 2023 16:30:25 +0000 Subject: [PATCH 22/34] testing --- tools/integration_tests/implicit_dir/test.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tools/integration_tests/implicit_dir/test.go b/tools/integration_tests/implicit_dir/test.go index f60cf65f50..f2019fe276 100644 --- a/tools/integration_tests/implicit_dir/test.go +++ b/tools/integration_tests/implicit_dir/test.go @@ -30,17 +30,6 @@ func main() { setup.RunScriptForTestData("create_objects.sh", "tulsishah-test") - err = os.Mkdir("/usr/local/google/home/tulsishah/gcs/A", 777) - if err != nil { - log.Printf("Error in creating directory: %v", err) - } - - filePath = path.Join("/usr/local/google/home/tulsishah/gcs/A/a.txt") - _, err = os.Create(filePath) - if err != nil { - log.Printf("Create file at : %v", err) - } - _, err = os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") if err != nil { log.Printf("Stating file at : %v", err) From 9704e5999f715c6ff76043d055f555bf07464add Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 21 Jun 2023 10:42:49 +0000 Subject: [PATCH 23/34] testing --- .../implicit_dir/delete_test.go | 23 +++++-- .../implicit_dir/implicit_dir_test.go | 2 +- tools/integration_tests/implicit_dir/test.go | 66 ++++++++++++------- tools/integration_tests/implicit_dir/test2.go | 36 ++++++++++ 4 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 tools/integration_tests/implicit_dir/test2.go diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 9928f2a58e..71ab5237b2 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,7 +16,8 @@ package implicit_dir_test import ( - "fmt" + "log" + "os" "path" "testing" @@ -73,6 +74,16 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + //dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + //fmt.Println(dir) + //_, err := os.Stat(dir) + //log.Print(err) + dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) + _, err := os.Stat(dir) + log.Print(err) + } // Directory Structure @@ -85,13 +96,13 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() - dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - fmt.Println(dir) + //dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + //fmt.Println(dir) //_, err := os.Stat(dir) //log.Print(err) - dir = path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) - //_, err = os.Stat(dir) - //log.Print(err) + dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) + _, err := os.Stat(dir) + log.Print(err) //explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) ////time.Sleep(1 * time.Minute) diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index d035a14484..1ba3ba5dd4 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -27,7 +27,7 @@ const FileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" const FileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" func TestMain(m *testing.M) { - flags := [][]string{{"--enable-storage-client-library=false", "--implicit-dirs"}, {"--implicit-dirs"}} + flags := [][]string{{"--enable-storage-client-library=false", "--implicit-dirs"}} implicit_and_explicit_dir_setup.RunTestsForImplicitDirAndExplicitDir(flags, m) } diff --git a/tools/integration_tests/implicit_dir/test.go b/tools/integration_tests/implicit_dir/test.go index f2019fe276..94386df0ad 100644 --- a/tools/integration_tests/implicit_dir/test.go +++ b/tools/integration_tests/implicit_dir/test.go @@ -3,34 +3,50 @@ package main import ( "log" "os" - "path" - - "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" ) func main() { - setup.RunScriptForTestData("delete_objects.sh", "tulsishah-test") - - setup.RunScriptForTestData("create_objects.sh", "tulsishah-test") - - err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) - if err != nil { - log.Printf("Error in creating directory: %v", err) - } - - filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") - _, err = os.Create(filePath) - if err != nil { - log.Printf("Create file at : %v", err) - } - - os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") - - setup.RunScriptForTestData("delete_objects.sh", "tulsishah-test") - - setup.RunScriptForTestData("create_objects.sh", "tulsishah-test") - - _, err = os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") + // setup.RunScriptForTestData("delete_objects.sh", "tulsishah_test") + + //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) + //os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") + //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) + // + //err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) + //if err != nil { + // log.Printf("Error in creating directory: %v", err) + //} + // + //filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") + //_, err = os.Create(filePath) + //if err != nil { + // log.Printf("Create file at : %v", err) + //} + // + //os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") + // + //// setup.RunScriptForTestData("delete_objects.sh", "tulsishah_test") + //os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") + // + //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) + //os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") + //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) + // + //err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) + //if err != nil { + // log.Printf("Error in creating directory: %v", err) + //} + // + //filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") + //_, err = os.Create(filePath) + //if err != nil { + // log.Printf("Create file at : %v", err) + //} + + // setup.RunScriptForTestData("create_objects.sh", "tulsishah_test") + // os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") + + _, err := os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") if err != nil { log.Printf("Stating file at : %v", err) } diff --git a/tools/integration_tests/implicit_dir/test2.go b/tools/integration_tests/implicit_dir/test2.go new file mode 100644 index 0000000000..c36e18223c --- /dev/null +++ b/tools/integration_tests/implicit_dir/test2.go @@ -0,0 +1,36 @@ +package main + +import ( + "log" + "os" + "path" +) + +func main() { + + os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) + os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") + os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) + + err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) + if err != nil { + log.Printf("Error in creating directory: %v", err) + } + + filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") + _, err = os.Create(filePath) + if err != nil { + log.Printf("Create file at : %v", err) + } + + os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") + + os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) + os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") + os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) + + _, err = os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") + if err != nil { + log.Printf("Stating file at : %v", err) + } +} From 734f29e4f2896fe939afbfb8883c3357eeb30107 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 21 Jun 2023 16:37:23 +0000 Subject: [PATCH 24/34] testing --- .../implicit_dir/create_objects.sh | 21 -- .../implicit_dir/delete_objects.sh | 22 -- .../implicit_dir/delete_test.go | 182 ++++++-------- .../implicit_dir/list_test.go | 228 +++++++++--------- tools/integration_tests/implicit_dir/test.go | 53 ---- tools/integration_tests/implicit_dir/test2.go | 36 --- .../util/operations/dir_operations.go | 6 +- tools/integration_tests/util/setup/setup.go | 2 +- 8 files changed, 201 insertions(+), 349 deletions(-) delete mode 100644 tools/integration_tests/implicit_dir/create_objects.sh delete mode 100644 tools/integration_tests/implicit_dir/delete_objects.sh delete mode 100644 tools/integration_tests/implicit_dir/test.go delete mode 100644 tools/integration_tests/implicit_dir/test2.go diff --git a/tools/integration_tests/implicit_dir/create_objects.sh b/tools/integration_tests/implicit_dir/create_objects.sh deleted file mode 100644 index cfc7c30185..0000000000 --- a/tools/integration_tests/implicit_dir/create_objects.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2023 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Here $1 refers to the testBucket argument -echo "This is from directory fileInImplicitDir1 file implicitDirectory" >> fileInImplicitDir1 -# bucket/implicitDirectory/fileInImplicitDir1 -gsutil mv fileInImplicitDir1 gs://$1/implicitDirectory/ -echo "This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2" >> fileInImplicitDir2 -# bucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -gsutil mv fileInImplicitDir2 gs://$1/implicitDirectory/implicitSubDirectory/ diff --git a/tools/integration_tests/implicit_dir/delete_objects.sh b/tools/integration_tests/implicit_dir/delete_objects.sh deleted file mode 100644 index 14a1278987..0000000000 --- a/tools/integration_tests/implicit_dir/delete_objects.sh +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2023 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Here $1 refers to the testBucket argument -gsutil rm -a gs://$1/** - -# If bucket is empty it will throw an CommandException. -if [ $? -eq 1 ]; then - echo "Bucket is already empty." - exit 0 -fi diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 71ab5237b2..9884f00ce5 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,7 +16,6 @@ package implicit_dir_test import ( - "log" "os" "path" "testing" @@ -31,26 +30,32 @@ import ( // testBucket/implicitDirectory/fileInImplicitDir1 -- File // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File -//func TestDeleteNonEmptyImplicitDir(t *testing.T) { -// implicit_and_explicit_dir_setup.CreateImplicitDirectory() -// -// dirPath := path.Join(setup.MntDir(), 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 -//func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { -// implicit_and_explicit_dir_setup.CreateImplicitDirectory() -// -// subDirPath := path.Join(setup.MntDir(), 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) -//} +func TestDeleteNonEmptyImplicitDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) + + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning directory + os.RemoveAll(setup.MntDir()) +} + +// Directory Structure +// testBucket/implicitDirectory -- Dir +// testBucket/implicitDirectory/fileInImplicitDir1 -- File +// testBucket/implicitDirectory/implicitSubDirectory -- Dir +// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File +func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + + subDirPath := path.Join(setup.MntDir(), 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) + + // Cleaning directory + os.RemoveAll(setup.MntDir()) +} // Directory Structure // testBucket/implicitDirectory -- Dir @@ -64,26 +69,14 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - //err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) - //if err != nil { - // t.Errorf("Error in creating directory: %v", err) - //} - - operations.CreateDirectoryWithNFiles(1, explicitDirPath, "temp", t) + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - - //dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - //fmt.Println(dir) - //_, err := os.Stat(dir) - //log.Print(err) - dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) - _, err := os.Stat(dir) - log.Print(err) + // Cleaning directory + os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -95,75 +88,54 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() + explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) + + operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) + + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - //dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - //fmt.Println(dir) - //_, err := os.Stat(dir) - //log.Print(err) - dir := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) - _, err := os.Stat(dir) - log.Print(err) - //explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - - ////time.Sleep(1 * time.Minute) - // - //err := os.Mkdir(explicitDirPath, setup.FilePermission_0600) - //if err != nil { - // t.Errorf("Error in creating directory: %v", err) - //} - // - ////time.Sleep(1 * time.Minute) - // - ////filePath := path.Join(explicitDirPath, FileInExplicitDirInImplicitSubDir) - ////_, err = os.Create(filePath) - ////if err != nil { - //// t.Errorf("Create file at %q: %v", explicitDirPath, err) - ////} - // - //dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) - // - //implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning the bucket. - //os.RemoveAll(setup.MntDir()) + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) + + // Cleaning directory + os.RemoveAll(setup.MntDir()) } -//// 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 -//func TestDeleteImplicitDirInExplicitDir(t *testing.T) { -// implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) -// -// dirPath := path.Join(setup.MntDir(), 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) -// -// // Cleaning the bucket. -// os.RemoveAll(setup.MntDir()) -//} -// -//// 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 -//func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { -// implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) -// -// dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) -// -// implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) -// -// // Cleaning the bucket. -// os.RemoveAll(setup.MntDir()) -//} +// 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 +func TestDeleteImplicitDirInExplicitDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) + + dirPath := path.Join(setup.MntDir(), 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) + + // Cleaning directory + os.RemoveAll(setup.MntDir()) +} + +// 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 +func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) + + dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) + + implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) + + // Cleaning directory + os.RemoveAll(setup.MntDir()) +} diff --git a/tools/integration_tests/implicit_dir/list_test.go b/tools/integration_tests/implicit_dir/list_test.go index d7e8386b4a..d21ebfdfc7 100644 --- a/tools/integration_tests/implicit_dir/list_test.go +++ b/tools/integration_tests/implicit_dir/list_test.go @@ -15,118 +15,126 @@ package implicit_dir_test import ( + "fmt" + "io/fs" + "log" + "os" + "path/filepath" "testing" + + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup" + "github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup" ) func TestListImplicitObjectsFromBucket(t *testing.T) { - //// Directory Structure - //// testBucket/implicitDirectory -- Dir - //// testBucket/implicitDirectory/fileInImplicitDir1 -- File - //// testBucket/implicitDirectory/implicitSubDirectory -- Dir - //// testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - //// testBucket/explicitDirectory -- Dir - //// testBucket/explicitFile -- File - //// testBucket/explicitDirectory/fileInExplicitDir1 -- File - //// testBucket/explicitDirectory/fileInExplicitDir2 -- File - // - //implicit_and_explicit_dir_setup.CreateImplicitDirectory() - //implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) - // - //// Delete objects from bucket after testing. - ////defer os.RemoveAll(setup.MntDir()) - // - //err := filepath.Walk(setup.MntDir(), func(path string, dir fs.FileInfo, err error) error { - // if err != nil { - // fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err) - // return err - // } - // - // // The object type is not directory. - // if !dir.IsDir() { - // return nil - // } - // - // objs, err := os.ReadDir(path) - // if err != nil { - // log.Fatal(err) - // } - // - // // Check if mntDir has correct objects. - // if path == setup.MntDir() { - // // numberOfObjects - 3 - // if len(objs) != implicit_and_explicit_dir_setup.NumberOfTotalObjects { - // t.Errorf("Incorrect number of objects in the bucket.") - // } - // - // // testBucket/explicitDir -- Dir - // if objs[0].Name() != implicit_and_explicit_dir_setup.ExplicitDirectory || objs[0].IsDir() != true { - // t.Errorf("Listed incorrect object") - // } - // // testBucket/explicitFile -- File - // if objs[1].Name() != implicit_and_explicit_dir_setup.ExplicitFile || objs[1].IsDir() != false { - // t.Errorf("Listed incorrect object") - // } - // - // // testBucket/implicitDir -- Dir - // if objs[2].Name() != implicit_and_explicit_dir_setup.ImplicitDirectory || objs[2].IsDir() != true { - // t.Errorf("Listed incorrect object") - // } - // } - // - // // Check if explictDir directory has correct data. - // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ExplicitDirectory { - // // numberOfObjects - 2 - // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInExplicitDirectory { - // t.Errorf("Incorrect number of objects in the explicitDirectory.") - // } - // - // // testBucket/explicitDir/fileInExplicitDir1 -- File - // if objs[0].Name() != implicit_and_explicit_dir_setup.FirstFileInExplicitDirectory || objs[0].IsDir() != false { - // t.Errorf("Listed incorrect object") - // } - // - // // testBucket/explicitDir/fileInExplicitDir2 -- File - // if objs[1].Name() != implicit_and_explicit_dir_setup.SecondFileInExplicitDirectory || objs[1].IsDir() != false { - // t.Errorf("Listed incorrect object") - // } - // return nil - // } - // - // // Check if implicitDir directory has correct data. - // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitDirectory { - // // numberOfObjects - 2 - // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitDirectory { - // t.Errorf("Incorrect number of objects in the implicitDirectory.") - // } - // - // // testBucket/implicitDir/fileInImplicitDir1 -- File - // if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitDirectory || objs[0].IsDir() != false { - // t.Errorf("Listed incorrect object") - // } - // // testBucket/implicitDir/implicitSubDirectory -- Dir - // if objs[1].Name() != implicit_and_explicit_dir_setup.ImplicitSubDirectory || objs[1].IsDir() != true { - // t.Errorf("Listed incorrect object") - // } - // return nil - // } - // - // // Check if implicit sub directory has correct data. - // if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitSubDirectory { - // // numberOfObjects - 1 - // if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitSubDirectory { - // t.Errorf("Incorrect number of objects in the implicitSubDirectoryt.") - // } - // - // // testBucket/implicitDir/implicitSubDir/fileInImplicitDir2 -- File - // if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitSubDirectory || objs[0].IsDir() != false { - // t.Errorf("Listed incorrect object") - // } - // return nil - // } - // return nil - //}) - //if err != nil { - // t.Errorf("error walking the path : %v\n", err) - // return - //} + // Directory Structure + // testBucket/implicitDirectory -- Dir + // testBucket/implicitDirectory/fileInImplicitDir1 -- File + // testBucket/implicitDirectory/implicitSubDirectory -- Dir + // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File + // testBucket/explicitDirectory -- Dir + // testBucket/explicitFile -- File + // testBucket/explicitDirectory/fileInExplicitDir1 -- File + // testBucket/explicitDirectory/fileInExplicitDir2 -- File + + implicit_and_explicit_dir_setup.CreateImplicitDirectory() + implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) + + // Delete objects from bucket after testing. + //defer os.RemoveAll(setup.MntDir()) + + err := filepath.Walk(setup.MntDir(), func(path string, dir fs.FileInfo, err error) error { + if err != nil { + fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err) + return err + } + + // The object type is not directory. + if !dir.IsDir() { + return nil + } + + objs, err := os.ReadDir(path) + if err != nil { + log.Fatal(err) + } + + // Check if mntDir has correct objects. + if path == setup.MntDir() { + // numberOfObjects - 3 + if len(objs) != implicit_and_explicit_dir_setup.NumberOfTotalObjects { + t.Errorf("Incorrect number of objects in the bucket.") + } + + // testBucket/explicitDir -- Dir + if objs[0].Name() != implicit_and_explicit_dir_setup.ExplicitDirectory || objs[0].IsDir() != true { + t.Errorf("Listed incorrect object") + } + // testBucket/explicitFile -- File + if objs[1].Name() != implicit_and_explicit_dir_setup.ExplicitFile || objs[1].IsDir() != false { + t.Errorf("Listed incorrect object") + } + + // testBucket/implicitDir -- Dir + if objs[2].Name() != implicit_and_explicit_dir_setup.ImplicitDirectory || objs[2].IsDir() != true { + t.Errorf("Listed incorrect object") + } + } + + // Check if explictDir directory has correct data. + if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ExplicitDirectory { + // numberOfObjects - 2 + if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInExplicitDirectory { + t.Errorf("Incorrect number of objects in the explicitDirectory.") + } + + // testBucket/explicitDir/fileInExplicitDir1 -- File + if objs[0].Name() != implicit_and_explicit_dir_setup.FirstFileInExplicitDirectory || objs[0].IsDir() != false { + t.Errorf("Listed incorrect object") + } + + // testBucket/explicitDir/fileInExplicitDir2 -- File + if objs[1].Name() != implicit_and_explicit_dir_setup.SecondFileInExplicitDirectory || objs[1].IsDir() != false { + t.Errorf("Listed incorrect object") + } + return nil + } + + // Check if implicitDir directory has correct data. + if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitDirectory { + // numberOfObjects - 2 + if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitDirectory { + t.Errorf("Incorrect number of objects in the implicitDirectory.") + } + + // testBucket/implicitDir/fileInImplicitDir1 -- File + if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitDirectory || objs[0].IsDir() != false { + t.Errorf("Listed incorrect object") + } + // testBucket/implicitDir/implicitSubDirectory -- Dir + if objs[1].Name() != implicit_and_explicit_dir_setup.ImplicitSubDirectory || objs[1].IsDir() != true { + t.Errorf("Listed incorrect object") + } + return nil + } + + // Check if implicit sub directory has correct data. + if dir.IsDir() && dir.Name() == implicit_and_explicit_dir_setup.ImplicitSubDirectory { + // numberOfObjects - 1 + if len(objs) != implicit_and_explicit_dir_setup.NumberOfFilesInImplicitSubDirectory { + t.Errorf("Incorrect number of objects in the implicitSubDirectoryt.") + } + + // testBucket/implicitDir/implicitSubDir/fileInImplicitDir2 -- File + if objs[0].Name() != implicit_and_explicit_dir_setup.FileInImplicitSubDirectory || objs[0].IsDir() != false { + t.Errorf("Listed incorrect object") + } + return nil + } + return nil + }) + if err != nil { + t.Errorf("error walking the path : %v\n", err) + return + } } diff --git a/tools/integration_tests/implicit_dir/test.go b/tools/integration_tests/implicit_dir/test.go deleted file mode 100644 index 94386df0ad..0000000000 --- a/tools/integration_tests/implicit_dir/test.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "log" - "os" -) - -func main() { - // setup.RunScriptForTestData("delete_objects.sh", "tulsishah_test") - - //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) - //os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") - //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) - // - //err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) - //if err != nil { - // log.Printf("Error in creating directory: %v", err) - //} - // - //filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") - //_, err = os.Create(filePath) - //if err != nil { - // log.Printf("Create file at : %v", err) - //} - // - //os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") - // - //// setup.RunScriptForTestData("delete_objects.sh", "tulsishah_test") - //os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") - // - //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) - //os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") - //os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) - // - //err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) - //if err != nil { - // log.Printf("Error in creating directory: %v", err) - //} - // - //filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") - //_, err = os.Create(filePath) - //if err != nil { - // log.Printf("Create file at : %v", err) - //} - - // setup.RunScriptForTestData("create_objects.sh", "tulsishah_test") - // os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") - - _, err := os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") - if err != nil { - log.Printf("Stating file at : %v", err) - } -} diff --git a/tools/integration_tests/implicit_dir/test2.go b/tools/integration_tests/implicit_dir/test2.go deleted file mode 100644 index c36e18223c..0000000000 --- a/tools/integration_tests/implicit_dir/test2.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "log" - "os" - "path" -) - -func main() { - - os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) - os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") - os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) - - err := os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A", 777) - if err != nil { - log.Printf("Error in creating directory: %v", err) - } - - filePath := path.Join("/usr/local/google/home/tulsishah/gcs/implicitDirectory/A/a.txt") - _, err = os.Create(filePath) - if err != nil { - log.Printf("Create file at : %v", err) - } - - os.RemoveAll("/usr/local/google/home/tulsishah/gcs/implicitDirectory") - - os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory", 777) - os.Create("/usr/local/google/home/tulsishah/gcs/implicitDirectory/f1.txt") - os.Mkdir("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory", 777) - - _, err = os.Stat("/usr/local/google/home/tulsishah/gcs/implicitDirectory/implicitSubDirectory/") - if err != nil { - log.Printf("Stating file at : %v", err) - } -} diff --git a/tools/integration_tests/util/operations/dir_operations.go b/tools/integration_tests/util/operations/dir_operations.go index c3bac61971..02f2bcc353 100644 --- a/tools/integration_tests/util/operations/dir_operations.go +++ b/tools/integration_tests/util/operations/dir_operations.go @@ -17,6 +17,7 @@ package operations import ( "fmt" + "log" "os" "os/exec" "path" @@ -66,9 +67,12 @@ func CreateDirectoryWithNFiles(numberOfFiles int, dirPath string, prefix string, // Create file with name prefix + i // e.g. If prefix = temp then temp1, temp2 filePath := path.Join(dirPath, prefix+strconv.Itoa(i)) - _, err := os.Create(filePath) + f, err := os.Create(filePath) if err != nil { t.Errorf("Create file at %q: %v", dirPath, err) } + if err = f.Close(); err != nil { + log.Printf("error in closing: %v", err) + } } } diff --git a/tools/integration_tests/util/setup/setup.go b/tools/integration_tests/util/setup/setup.go index e04249aa4b..5f867ecaa1 100644 --- a/tools/integration_tests/util/setup/setup.go +++ b/tools/integration_tests/util/setup/setup.go @@ -169,7 +169,7 @@ func UnMount() error { func executeTest(m *testing.M) (successCode int) { successCode = m.Run() - //os.RemoveAll(mntDir) + os.RemoveAll(mntDir) return successCode } From d60370ca4c59509edd9be513c0810f9e04bb77bb Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 06:34:58 +0000 Subject: [PATCH 25/34] small fix --- .../implicit_dir/delete_test.go | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 9884f00ce5..ff73bf0b59 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -16,7 +16,6 @@ package implicit_dir_test import ( - "os" "path" "testing" @@ -31,14 +30,14 @@ import ( // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectory() dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -47,14 +46,14 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectory() subDirPath := path.Join(setup.MntDir(), 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) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -65,6 +64,9 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory -- Dir // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) @@ -74,9 +76,6 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -87,6 +86,9 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir -- Dir // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) @@ -95,9 +97,6 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ImplicitDirectory, t) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -110,14 +109,14 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteImplicitDirInExplicitDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), 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) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } // Directory Structure @@ -130,12 +129,12 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { + // Clean the mountedDirectory before running test. + setup.CleanMntDir() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) implicit_and_explicit_dir_setup.RemoveAndCheckIfDirIsDeleted(dirPath, implicit_and_explicit_dir_setup.ExplicitDirectory, t) - - // Cleaning directory - os.RemoveAll(setup.MntDir()) } From 05fc4f246d4d4c7c5affad1e5e205c6f07da49bd Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 06:48:32 +0000 Subject: [PATCH 26/34] resolving conflict --- .../util/operations/dir_operations.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tools/integration_tests/util/operations/dir_operations.go b/tools/integration_tests/util/operations/dir_operations.go index 4b7d16215e..1a4d92bdf9 100644 --- a/tools/integration_tests/util/operations/dir_operations.go +++ b/tools/integration_tests/util/operations/dir_operations.go @@ -60,11 +60,7 @@ func RenameDir(dirName string, newDirName string) (err error) { } func CreateDirectoryWithNFiles(numberOfFiles int, dirPath string, prefix string, t *testing.T) { -<<<<<<< HEAD - err := os.Mkdir(dirPath, 777) -======= err := os.Mkdir(dirPath, FilePermission_0600) ->>>>>>> 48296dc6fd0060da8aad0335171db89d7a989566 if err != nil { t.Errorf("Error in creating directory: %v", err) } @@ -73,15 +69,6 @@ func CreateDirectoryWithNFiles(numberOfFiles int, dirPath string, prefix string, // Create file with name prefix + i // e.g. If prefix = temp then temp1, temp2 filePath := path.Join(dirPath, prefix+strconv.Itoa(i)) -<<<<<<< HEAD - f, err := os.Create(filePath) - if err != nil { - t.Errorf("Create file at %q: %v", dirPath, err) - } - if err = f.Close(); err != nil { - log.Printf("error in closing: %v", err) - } -======= file, err := os.Create(filePath) if err != nil { t.Errorf("Create file at %q: %v", dirPath, err) @@ -95,6 +82,5 @@ func CreateDirectoryWithNFiles(numberOfFiles int, dirPath string, prefix string, func RemoveDir(dirPath string) { if err := os.RemoveAll(dirPath); err != nil { log.Printf("Error in removing direcitory: %v", err) ->>>>>>> 48296dc6fd0060da8aad0335171db89d7a989566 } } From a6751ec08c57ed17f4b8d04ef84efb72af068f89 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 06:55:10 +0000 Subject: [PATCH 27/34] removing unnecessary changes --- .../implicit_dir/implicit_dir_test.go | 2 +- .../implicit_and_explicit_dir_setup.go | 32 ------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 1ba3ba5dd4..33a5d281cd 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -27,7 +27,7 @@ const FileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" const FileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" func TestMain(m *testing.M) { - flags := [][]string{{"--enable-storage-client-library=false", "--implicit-dirs"}} + flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} implicit_and_explicit_dir_setup.RunTestsForImplicitDirAndExplicitDir(flags, m) } diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 34c5f86d36..29e443fd8b 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -17,7 +17,6 @@ package implicit_and_explicit_dir_setup import ( "log" "os" - "os/exec" "path" "testing" @@ -62,37 +61,6 @@ func RunTestsForImplicitDirAndExplicitDir(flags [][]string, m *testing.M) { os.Exit(successCode) } -func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) { - cmd := exec.Command( - "rm", - "-r", - dirPath, - ) - _, err := cmd.CombinedOutput() - if err != nil { - t.Errorf("Error in deleting non-empty implicit directory.") - } - - dir, err := os.Stat(dirPath) - if err == nil && dir.Name() == dirName && dir.IsDir() { - t.Errorf("Directory is not deleted.") - } -} - -func CreateImplicitDirectory2() { - // Implicit Directory Structure - // testBucket/implicitDirectory -- Dir - // testBucket/implicitDirectory/fileInImplicitDir1 -- File - // testBucket/implicitDirectory/implicitSubDirectory -- Dir - // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - - // Clean the bucket. - setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/delete_objects.sh", setup.TestBucket()) - - // Create implicit directory in bucket for testing. - setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh", setup.TestBucket()) -} - func CreateImplicitDirectory() { // Implicit Directory Structure // testBucket/implicitDirectory -- Dir From 58fc3fd24dde91311999c8ffcb63809edea16a09 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 06:55:57 +0000 Subject: [PATCH 28/34] removing unnecessary changes --- .../testdata/create_object2.sh | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh deleted file mode 100644 index 2ac7a61202..0000000000 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/testdata/create_object2.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2023 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Here $1 refers to the testBucket argument -echo "This is from directory fileInImplicitDir1 file implicitDirectory" >> fileInImplicitDir1 -# bucket/implicitDirectory/fileInImplicitDir1 -gsutil mv fileInImplicitDir1 gs://$1/implicitDirectory2/ -echo "This is from directory implicitDirectory/implicitSubDirectory file fileInImplicitDir2" >> fileInImplicitDir2 -# bucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -gsutil mv fileInImplicitDir2 gs://$1/implicitDirectory2/implicitSubDirectory/ From 7c5c59be06cb001c7dcbdf32f62888228efb39ed Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 06:59:36 +0000 Subject: [PATCH 29/34] removing unnecessary changes --- .../implicit_and_explicit_dir_setup.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 29e443fd8b..00b5fb9cfe 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -61,6 +61,18 @@ func RunTestsForImplicitDirAndExplicitDir(flags [][]string, m *testing.M) { os.Exit(successCode) } +func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) { + err := os.RemoveAll(dirPath) + if err != nil { + t.Errorf("Error in deleting non-empty implicit directory:%v", err) + } + + dir, err := os.Stat(dirPath) + if err == nil && dir.Name() == dirName && dir.IsDir() { + t.Errorf("Directory is not deleted.") + } +} + func CreateImplicitDirectory() { // Implicit Directory Structure // testBucket/implicitDirectory -- Dir From 19ad1edad757b7dfe53659bacbf9ceb0183eeda8 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Tue, 27 Jun 2023 07:06:44 +0000 Subject: [PATCH 30/34] small fix --- tools/integration_tests/implicit_dir/delete_test.go | 4 ++-- tools/integration_tests/implicit_dir/implicit_dir_test.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index ff73bf0b59..71613de2fc 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -71,7 +71,7 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) - operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitDir, t) + operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitDir, explicitDirPath, PrefixFileInExplicitDirInImplicitDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) @@ -92,7 +92,7 @@ func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { implicit_and_explicit_dir_setup.CreateImplicitDirectory() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) - operations.CreateDirectoryWithNFiles(1, explicitDirPath, FileInExplicitDirInImplicitSubDir, t) + operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitSubDir, explicitDirPath, PrefixFileInExplicitDirInImplicitSubDir, t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) diff --git a/tools/integration_tests/implicit_dir/implicit_dir_test.go b/tools/integration_tests/implicit_dir/implicit_dir_test.go index 33a5d281cd..e710445dee 100644 --- a/tools/integration_tests/implicit_dir/implicit_dir_test.go +++ b/tools/integration_tests/implicit_dir/implicit_dir_test.go @@ -23,8 +23,10 @@ import ( const ExplicitDirInImplicitDir = "explicitDirInImplicitDir" const ExplicitDirInImplicitSubDir = "explicitDirInImplicitSubDir" -const FileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" -const FileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" +const PrefixFileInExplicitDirInImplicitDir = "fileInExplicitDirInImplicitDir" +const PrefixFileInExplicitDirInImplicitSubDir = "fileInExplicitDirInImplicitSubDir" +const NumberOfFilesInExplicitDirInImplicitSubDir = 1 +const NumberOfFilesInExplicitDirInImplicitDir = 1 func TestMain(m *testing.M) { flags := [][]string{{"--implicit-dirs"}, {"--enable-storage-client-library=false", "--implicit-dirs"}} From 499b454c6c55af5ca67580cfc8868454a9d972f2 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 28 Jun 2023 11:37:04 +0000 Subject: [PATCH 31/34] renaming test --- tools/integration_tests/implicit_dir/delete_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 71613de2fc..7bd68d856a 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -85,7 +85,7 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // testBucket/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir -- Dir // testBucket/implicitDirectory/implicitSubDirectory/explicitDirInImplicitDir/fileInExplicitDirInImplicitDir -- File -func TestDeleteImplicitDirWithExplicitSubDirInImplicitSubDir(t *testing.T) { +func TestDeleteImplicitDirWithImplicitSubDirContainingExplicitDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() From 967ce672e9eea08ad5af85967e64c929084dfee4 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 28 Jun 2023 12:27:43 +0000 Subject: [PATCH 32/34] renaming --- tools/integration_tests/explicit_dir/list_test.go | 4 ++-- tools/integration_tests/implicit_dir/delete_test.go | 10 +++++----- tools/integration_tests/implicit_dir/list_test.go | 4 ++-- .../implicit_and_explicit_dir_setup.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/integration_tests/explicit_dir/list_test.go b/tools/integration_tests/explicit_dir/list_test.go index b69f8ea656..0312e88b69 100644 --- a/tools/integration_tests/explicit_dir/list_test.go +++ b/tools/integration_tests/explicit_dir/list_test.go @@ -40,8 +40,8 @@ func TestListOnlyExplicitObjectsFromBucket(t *testing.T) { // testBucket/explicitDirectory/fileInExplicitDir1 -- File // testBucket/explicitDirectory/fileInExplicitDir2 -- File - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() + implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(t) err := filepath.WalkDir(setup.MntDir(), func(path string, dir fs.DirEntry, err error) error { if err != nil { diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 7bd68d856a..1726799983 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -33,7 +33,7 @@ func TestDeleteNonEmptyImplicitDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectory() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory) @@ -49,7 +49,7 @@ func TestDeleteNonEmptyImplicitSubDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectory() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() subDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory) @@ -67,7 +67,7 @@ func TestDeleteImplicitDirWithExplicitSubDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectory() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, ExplicitDirInImplicitDir) @@ -89,7 +89,7 @@ func TestDeleteImplicitDirWithImplicitSubDirContainingExplicitDir(t *testing.T) // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectory() + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() explicitDirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ImplicitDirectory, implicit_and_explicit_dir_setup.ImplicitSubDirectory, ExplicitDirInImplicitSubDir) operations.CreateDirectoryWithNFiles(NumberOfFilesInExplicitDirInImplicitSubDir, explicitDirPath, PrefixFileInExplicitDirInImplicitSubDir, t) @@ -128,7 +128,7 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/fileInImplicitDir1 -- File // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File -func TestDeleteExplicitDirWithImplicitSubDir(t *testing.T) { +func TestDeleteExplicitDirContainingImplicitSubDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() diff --git a/tools/integration_tests/implicit_dir/list_test.go b/tools/integration_tests/implicit_dir/list_test.go index 7cecb1eca9..d4e5ca9e62 100644 --- a/tools/integration_tests/implicit_dir/list_test.go +++ b/tools/integration_tests/implicit_dir/list_test.go @@ -40,8 +40,8 @@ func TestListImplicitObjectsFromBucket(t *testing.T) { // testBucket/explicitDirectory/fileInExplicitDir1 -- File // testBucket/explicitDirectory/fileInExplicitDir2 -- File - implicit_and_explicit_dir_setup.CreateImplicitDirectory() - implicit_and_explicit_dir_setup.CreateExplicitDirectory(t) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryStructure() + implicit_and_explicit_dir_setup.CreateExplicitDirectoryStructure(t) err := filepath.WalkDir(setup.MntDir(), func(path string, dir fs.DirEntry, err error) error { if err != nil { diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 00b5fb9cfe..b89fe62d9b 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -73,7 +73,7 @@ func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) } } -func CreateImplicitDirectory() { +func CreateImplicitDirectoryStructure() { // Implicit Directory Structure // testBucket/implicitDirectory -- Dir // testBucket/implicitDirectory/fileInImplicitDir1 -- File @@ -87,7 +87,7 @@ func CreateImplicitDirectory() { setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", setup.TestBucket()) } -func CreateExplicitDirectory(t *testing.T) { +func CreateExplicitDirectoryStructure(t *testing.T) { // Explicit Directory structure // testBucket/explicitDirectory -- Dir // testBucket/explictFile -- File @@ -116,7 +116,7 @@ func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory -- Dir // testBucket/explicitDirectory/implicitDirectory/implicitSubDirectory/fileInImplicitDir2 -- File - CreateExplicitDirectory(t) + CreateExplicitDirectoryStructure(t) dirPathInBucket := path.Join(setup.TestBucket(), ExplicitDirectory) setup.RunScriptForTestData("../util/setup/implicit_and_explicit_dir_setup/testdata/create_objects.sh", dirPathInBucket) } From 588a6f2868620122a30f85ed109e19335d2d42d7 Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 28 Jun 2023 12:42:27 +0000 Subject: [PATCH 33/34] renaming --- tools/integration_tests/implicit_dir/delete_test.go | 4 ++-- .../implicit_and_explicit_dir_setup.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/integration_tests/implicit_dir/delete_test.go b/tools/integration_tests/implicit_dir/delete_test.go index 1726799983..f05bd3335f 100644 --- a/tools/integration_tests/implicit_dir/delete_test.go +++ b/tools/integration_tests/implicit_dir/delete_test.go @@ -112,7 +112,7 @@ func TestDeleteImplicitDirInExplicitDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory, implicit_and_explicit_dir_setup.ImplicitDirectory) @@ -132,7 +132,7 @@ func TestDeleteExplicitDirContainingImplicitSubDir(t *testing.T) { // Clean the mountedDirectory before running test. setup.CleanMntDir() - implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectory(t) + implicit_and_explicit_dir_setup.CreateImplicitDirectoryInExplicitDirectoryStructure(t) dirPath := path.Join(setup.MntDir(), implicit_and_explicit_dir_setup.ExplicitDirectory) diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index b89fe62d9b..355ee80b24 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -106,7 +106,7 @@ func CreateExplicitDirectoryStructure(t *testing.T) { defer operations.CloseFile(file) } -func CreateImplicitDirectoryInExplicitDirectory(t *testing.T) { +func CreateImplicitDirectoryInExplicitDirectoryStructure(t *testing.T) { // testBucket/explicitDirectory -- Dir // testBucket/explictFile -- File // testBucket/explicitDirectory/fileInExplicitDir1 -- File From 6cb407de11696933ccd077b887a215419011004b Mon Sep 17 00:00:00 2001 From: Tulsi Shah Date: Wed, 28 Jun 2023 13:42:21 +0000 Subject: [PATCH 34/34] using function --- .../implicit_and_explicit_dir_setup.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go index 355ee80b24..77fee597c3 100644 --- a/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go +++ b/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup/implicit_and_explicit_dir_setup.go @@ -62,10 +62,7 @@ func RunTestsForImplicitDirAndExplicitDir(flags [][]string, m *testing.M) { } func RemoveAndCheckIfDirIsDeleted(dirPath string, dirName string, t *testing.T) { - err := os.RemoveAll(dirPath) - if err != nil { - t.Errorf("Error in deleting non-empty implicit directory:%v", err) - } + operations.RemoveDir(dirPath) dir, err := os.Stat(dirPath) if err == nil && dir.Name() == dirName && dir.IsDir() {