Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running all the integration test with --only-dir mounting #1100

Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
56e868d
secreat
Tulsishah Apr 11, 2023
f60cfea
secreat
Tulsishah Apr 11, 2023
6cb073c
secreat
Tulsishah Apr 11, 2023
46d1ac5
secreat
Tulsishah Apr 11, 2023
27b65d5
secreat
Tulsishah Apr 11, 2023
d54a6b3
secreat
Tulsishah Apr 11, 2023
59d9835
secreat
Tulsishah Apr 11, 2023
dc35dd0
secreat
Tulsishah Apr 11, 2023
7af33bf
secreat
Tulsishah Apr 11, 2023
47ba602
removing unnecessary line
Tulsishah Apr 12, 2023
e632aed
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 17, 2023
9c78554
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 18, 2023
3a29347
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 19, 2023
1cb9f48
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 21, 2023
c5dfebe
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 27, 2023
c737815
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 28, 2023
7011678
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah Apr 28, 2023
146cbb8
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah May 3, 2023
860dff5
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah May 4, 2023
1e4fef0
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah May 8, 2023
e4b9b4b
Merge branch 'GoogleCloudPlatform:master' into master
Tulsishah May 9, 2023
c098a83
adding --only-dir mounting in integration tests
Tulsishah May 9, 2023
b782c6d
updating function name and removing unnecessary files
Tulsishah May 9, 2023
eb78ea8
Upating comments
Tulsishah May 9, 2023
51d7d59
linux tests
Tulsishah May 9, 2023
f69118c
local changes
Tulsishah May 11, 2023
be0de40
renaming directory
Tulsishah May 12, 2023
0b16058
fixing merge conflict
Tulsishah May 12, 2023
fe0388f
fixing merge conflict
Tulsishah May 12, 2023
3dd9a35
fixing merge conflict
Tulsishah May 12, 2023
f0ca065
small fix
Tulsishah May 12, 2023
26392dc
adding test case where directory exist in only dir mounting
Tulsishah May 12, 2023
bf5de46
adding test case where directory exist in only dir mounting
Tulsishah May 12, 2023
98e85d6
new line
Tulsishah May 12, 2023
f68d81c
adding licence
Tulsishah May 12, 2023
9de70a7
fixed comments
Tulsishah May 12, 2023
b79609f
fixing comments
Tulsishah May 12, 2023
462b777
formating
Tulsishah May 12, 2023
314316e
fixing lint tests
Tulsishah May 12, 2023
c5d7320
fixing comments
Tulsishah May 15, 2023
17ad282
fixing comments
Tulsishah May 17, 2023
535b294
Merge branch 'master' into running_integration_test_with_only_dir_mou…
Tulsishah May 17, 2023
695a539
fixing lint tests
Tulsishah May 17, 2023
e902357
fixing lint tests
Tulsishah May 17, 2023
87b4973
small fix
Tulsishah May 17, 2023
7b04598
small fix
Tulsishah May 17, 2023
b135f97
updating functions name
Tulsishah May 18, 2023
f2a7000
Merge branch 'GoogleCloudPlatform:master' into running_integration_te…
Tulsishah May 19, 2023
53f0125
small fix
Tulsishah May 19, 2023
52129dc
adding comment
Tulsishah May 19, 2023
059a75d
adding comment
Tulsishah May 19, 2023
0cd61ae
fixing comments
Tulsishah May 19, 2023
18af686
Merge branch 'GoogleCloudPlatform:master' into running_integration_te…
Tulsishah May 19, 2023
76c576c
resolving comments
Tulsishah May 22, 2023
9d411f4
fixed comments
Tulsishah May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion perfmetrics/scripts/continuous_test/gcp_ubuntu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ commitId=$(git log --before='yesterday 23:59:59' --max-count=1 --pretty=%H)
git checkout $commitId

echo "Executing integration tests"
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=gcsfuse-integration-test
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=gcsfuse-integration-test -timeout=20m
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved

# Checkout back to master branch to use latest CI test scripts in master.
git checkout master
Expand Down
2 changes: 1 addition & 1 deletion perfmetrics/scripts/presubmit_test/pr_perf_test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ echo checkout PR branch
git checkout pr/$KOKORO_GITHUB_PULL_REQUEST_NUMBER

# Executing integration tests
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=gcsfuse-integration-test
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=gcsfuse-integration-test -timeout=20m

# Executing perf tests
echo Mounting gcs bucket from pr branch
Expand Down
10 changes: 9 additions & 1 deletion tools/integration_tests/operations/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"os"
"testing"

"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/only_dir_mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/static_mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup"
)

Expand All @@ -34,12 +36,18 @@ func TestMain(m *testing.M) {
{"--implicit-dirs=true"},
{"--implicit-dirs=false"}}

setup.CheckIfBothTheFlagsAreEnabled()

if setup.TestBucket() != "" && setup.MountedDirectory() != "" {
log.Printf("Both --testbucket and --mountedDirectory can't be specified at the same time.")
os.Exit(1)
}

successCode := setup.RunTests(flags, m)
successCode := static_mounting.RunTests(flags, m)

if successCode == 0 {
successCode = only_dir_mounting.RunTests(flags, m)
}

os.Exit(successCode)
}
21 changes: 7 additions & 14 deletions tools/integration_tests/readonly/readonly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package readonly_test
import (
"log"
"os"
"os/exec"
"strings"
"testing"

"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/static_mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup"
)

Expand All @@ -41,15 +41,6 @@ const ContentInFileInSubDirectoryTestBucket = "This is from directory Test/b fil
const RenameFile = "rename.txt"
const RenameDir = "rename"

// Run shell script
func runScriptForTestData(script string, testBucket string) {
sethiay marked this conversation as resolved.
Show resolved Hide resolved
cmd := exec.Command("/bin/bash", script, testBucket)
_, err := cmd.Output()
if err != nil {
panic(err)
}
}

func checkErrorForReadOnlyFileSystem(err error, t *testing.T) {
if !strings.Contains(err.Error(), "read-only file system") && !strings.Contains(err.Error(), "permission denied") {
t.Errorf("Incorrect error for readonly filesystem: %v", err.Error())
Expand All @@ -67,21 +58,23 @@ func TestMain(m *testing.M) {

flags := [][]string{{"--o=ro", "--implicit-dirs=true"}, {"--file-mode=544", "--dir-mode=544", "--implicit-dirs=true"}}

setup.CheckIfBothTheFlagsAreEnabled()

if setup.TestBucket() == "" && setup.MountedDirectory() != "" {
log.Printf("Please pass the name of bucket mounted at mountedDirectory to --testBucket flag.")
os.Exit(1)
}

// Clean the bucket for readonly testing.
runScriptForTestData("testdata/delete_objects.sh", setup.TestBucket())
setup.RunScriptForTestData("testdata/delete_objects.sh", setup.TestBucket())

// Create objects in bucket for testing.
runScriptForTestData("testdata/create_objects.sh", setup.TestBucket())
setup.RunScriptForTestData("testdata/create_objects.sh", setup.TestBucket())

successCode := setup.RunTests(flags, m)
successCode := static_mounting.RunTests(flags, m)

// Delete objects from bucket after testing.
runScriptForTestData("testdata/delete_objects.sh", setup.TestBucket())
setup.RunScriptForTestData("testdata/delete_objects.sh", setup.TestBucket())

os.Exit(successCode)
}
14 changes: 14 additions & 0 deletions tools/integration_tests/readonly/testdata/create_objects.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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 Test file a" >> a.txt
gsutil mv a.txt gs://$1/Test/
Expand Down
14 changes: 14 additions & 0 deletions tools/integration_tests/readonly/testdata/delete_objects.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 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/**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"os"
"testing"

"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/only_dir_mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting/static_mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup"
)

Expand All @@ -37,12 +39,18 @@ func TestMain(m *testing.M) {

flags := [][]string{{"--rename-dir-limit=3", "--implicit-dirs"}, {"--rename-dir-limit=3"}}

setup.CheckIfBothTheFlagsAreEnabled()

if setup.TestBucket() != "" && setup.MountedDirectory() != "" {
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
log.Printf("Both --testbucket and --mountedDirectory can't be specified at the same time.")
os.Exit(1)
}

successCode := setup.RunTests(flags, m)
successCode := static_mounting.RunTests(flags, m)

if successCode == 0 {
successCode = only_dir_mounting.RunTests(flags, m)
}

os.Exit(successCode)
}
58 changes: 58 additions & 0 deletions tools/integration_tests/util/mounting/mounting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.

package mounting

import (
"bytes"
"fmt"
"log"
"os"
"os/exec"

"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup"
)

func MountGcsfuse(defaultArg []string, flags []string) error {
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
for i := 0; i < len(defaultArg); i++ {
flags = append(flags, defaultArg[i])
}

mountCmd := exec.Command(
setup.BinFile(),
flags...,
)

// Adding mount command in LogFile
file, err := os.OpenFile(setup.LogFile(), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println("Could not open logfile")
}
defer file.Close()

_, err = file.WriteString(mountCmd.String() + "\n")
if err != nil {
fmt.Println("Could not write cmd to logFile")
}

output, err := mountCmd.CombinedOutput()
if err != nil {
log.Println(mountCmd.String())
return fmt.Errorf("cannot mount gcsfuse: %w\n", err)
}
if lines := bytes.Count(output, []byte{'\n'}); lines > 1 {
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("mount output: %q\n", output)
}
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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.

package only_dir_mounting

import (
"fmt"
"log"
"path"
"testing"

"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/mounting"
"github.com/googlecloudplatform/gcsfuse/tools/integration_tests/util/setup"
)

const DirectoryInTestBucket = "Test"

func mountGcsfuseWithOnlyDir(flags []string, dir string) (err error) {
defaultArg := []string{"--only-dir",
dir,
"--debug_gcs",
"--debug_fs",
"--debug_fuse",
"--log-file=" + setup.LogFile(),
"--log-format=text",
setup.TestBucket(),
setup.MntDir()}

err = mounting.MountGcsfuse(defaultArg, flags)

return err
}

func mountGcsFuseForFlagsAndExecuteTests(flags [][]string, dir string, m *testing.M) (successCode int) {
for i := 0; i < len(flags); i++ {
if err := mountGcsfuseWithOnlyDir(flags[i], dir); err != nil {
setup.LogAndExit(fmt.Sprintf("mountGcsfuse: %v\n", err))
}
successCode = setup.ExecuteTestForFlagsSet(flags[i], m)
}
return
}

func executeTests(flags [][]string, m *testing.M) (successCode int) {
setup.SetUpTestDirForTestBucketFlag()

mountDirInBucket := path.Join(setup.TestBucket(), DirectoryInTestBucket)
// Clean the bucket.

setup.RunScriptForTestData("../util/mounting/only_dir_mounting/testdata/delete_objects.sh", setup.TestBucket())

// "Test" directory not exist in bucket.
mountGcsFuseForFlagsAndExecuteTests(flags, DirectoryInTestBucket, m)

// "Test" directory exist in bucket.
// Clean the bucket.
setup.RunScriptForTestData("../util/mounting/only_dir_mounting/testdata/delete_objects.sh", setup.TestBucket())

// Create Test directory in bucket.
setup.RunScriptForTestData("../util/mounting/only_dir_mounting/testdata/create_objects.sh", mountDirInBucket)

successCode = mountGcsFuseForFlagsAndExecuteTests(flags, DirectoryInTestBucket, m)

// Clean the bucket after testing.
setup.RunScriptForTestData("../util/mounting/only_dir_mounting/testdata/delete_objects.sh", setup.TestBucket())

return
}

func RunTests(flags [][]string, m *testing.M) (successCode int) {
setup.ParseSetUpFlags()

setup.RunTestsForMountedDirectoryFlag(m)

// Execute tests for testBucket
successCode = executeTests(flags, m)

log.Printf("Test log: %s\n", setup.LogFile())

return successCode
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.

touch a.txt
gsutil mv a.txt gs://$1/
Original file line number Diff line number Diff line change
@@ -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