Skip to content

Commit

Permalink
skip tests which are not compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulsishah committed Aug 21, 2024
1 parent 244245f commit ea57e45
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tools/integration_tests/explicit_dir/explicit_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
package explicit_dir_test

import (
"context"
"log"
"os"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/setup"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/setup/implicit_and_explicit_dir_setup"
)
Expand All @@ -28,6 +33,24 @@ const DirForExplicitDirTests = "dirForExplicitDirTests"
func TestMain(m *testing.M) {
setup.ParseSetUpFlags()

// Create storage client before running tests.
var storageClient *storage.Client
ctx := context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
defer func() {
err := closeStorageClient()
if err != nil {
log.Fatalf("closeStorageClient failed: %v", err)
}
}()

// In hierarchical buckets, directories are not implicit.
// unlike in flat buckets where directories can be created implicitly which are visible only with --implicit-dirs=true.
// As a result, these tests are not compatible with hierarchical buckets.
if setup.IsHierarchicalBucket(ctx, storageClient) {
return
}

flags := [][]string{{"--implicit-dirs=false"}}

if !testing.Short() {
Expand Down
19 changes: 19 additions & 0 deletions tools/integration_tests/rename_dir_limit/rename_dir_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
package rename_dir_limit_test

import (
"context"
"log"
"os"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/mounting/only_dir_mounting"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/mounting/persistent_mounting"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/mounting/static_mounting"
Expand All @@ -38,11 +42,26 @@ const RenamedDirectory = "renamedDirectory"
const PrefixTempFile = "temp"
const onlyDirMounted = "OnlyDirMountRenameDirLimit"

var (
storageClient *storage.Client
ctx context.Context
)

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

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

// Create storage client before running tests.
ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
defer func() {
err := closeStorageClient()
if err != nil {
log.Fatalf("closeStorageClient failed: %v", err)
}
}()

setup.ExitWithFailureIfBothTestBucketAndMountedDirectoryFlagsAreNotSet()

if setup.TestBucket() != "" && setup.MountedDirectory() != "" {
Expand Down
10 changes: 10 additions & 0 deletions tools/integration_tests/rename_dir_limit/rename_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func TestRenameDirectoryWithTwoFiles(t *testing.T) {
// As --rename-directory-limit = 3, and the number of objects in the directory is two,
// which is greater than the limit, the operation should get fail.
func TestRenameDirectoryWithFourFiles(t *testing.T) {
// Rename in hierarchical bucket have no limits. So it will not fail and rename folder successfully.
if setup.IsHierarchicalBucket(ctx, storageClient) {
t.SkipNow()
}

testDir := setup.SetupTestDirectory(DirForRenameDirLimitTests)
// Creating directory structure
// testBucket/dirForRenameDirLimitTests/directoryWithFourFiles -- Dir
Expand Down Expand Up @@ -128,6 +133,11 @@ func TestRenameDirectoryWithTwoFilesAndOneEmptyDirectory(t *testing.T) {
// As --rename-directory-limit = 3, and the number of objects in the directory is Four,
// which is greater than the limit, the operation should get fail.
func TestRenameDirectoryWithTwoFilesAndOneNonEmptyDirectory(t *testing.T) {
// Rename in hierarchical bucket have no limits. So it will not fail and rename folder successfully.
if setup.IsHierarchicalBucket(ctx, storageClient) {
t.SkipNow()
}

testDir := setup.SetupTestDirectory(DirForRenameDirLimitTests)
// Creating directory structure
// testBucket/dirForRenameDirLimitTests/directoryWithTwoFilesOneNonEmptyDirectory -- Dir
Expand Down

0 comments on commit ea57e45

Please sign in to comment.