Skip to content

Commit

Permalink
Removed Timeout in StorageClient from all packages in integration_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vipnydav committed Aug 22, 2024
1 parent 574b76c commit ba670ae
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 41 deletions.
3 changes: 1 addition & 2 deletions tools/integration_tests/concurrent_operations/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand All @@ -47,7 +46,7 @@ func TestMain(m *testing.M) {

// Create common storage client to be used in test.
ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/implicit_dir/implicit_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand All @@ -47,7 +46,7 @@ func TestMain(m *testing.M) {

// Create storage client before running tests.
ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/interrupt/interrupt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand All @@ -41,7 +40,7 @@ func TestMain(m *testing.M) {

var storageClient *storage.Client
ctx := context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/kernel_list_cache/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestMain(m *testing.M) {

// Create common storage client to be used in test.
ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/local_file/local_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -78,7 +77,7 @@ func TestMain(m *testing.M) {

// Create storage client before running tests.
ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/log_rotation/log_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -69,7 +68,7 @@ func TestMain(m *testing.M) {

var storageClient *storage.Client
ctx := context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -56,7 +55,7 @@ func TestMain(m *testing.M) {
setup.ParseSetUpFlags()

ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*25)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions tools/integration_tests/operations/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -88,7 +87,6 @@ const FileInDirThreeInCreateThreeLevelDirTest = "fileInDirThreeInCreateThreeLeve
const ContentInFileInDirThreeInCreateThreeLevelDirTest = "Hello world!!"
const Content = "line 1\nline 2\n"
const onlyDirMounted = "OnlyDirMountOperations"
const storageClientTimeout = time.Minute * 50

func createMountConfigsAndEquivalentFlags() (flags [][]string) {
cacheDirPath := path.Join(os.Getenv("HOME"), "operations-cache-dir")
Expand Down Expand Up @@ -141,7 +139,7 @@ func TestMain(m *testing.M) {
// Create storage client before running tests.
ctx := context.Background()
var storageClient *storage.Client
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, storageClientTimeout)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tools/integration_tests/operations/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const tempFileContent = "line 1\nline 2\n"
func validateExtendedObjectAttributesNonEmpty(objectName string, t *testing.T) *storage.ObjectAttrs {
ctx := context.Background()
var storageClient *storage.Client
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*2)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"path"
"sync"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -129,7 +128,7 @@ func (s *cacheFileForRangeReadFalseTest) TestConcurrentReads_ReadIsTreatedNonSeq
func TestCacheFileForRangeReadFalseTest(t *testing.T) {
ts := &cacheFileForRangeReadFalseTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *cacheFileForRangeReadTrueTest) TestRangeReadsWithCacheHit(t *testing.T)
func TestCacheFileForRangeReadTrueTest(t *testing.T) {
ts := &cacheFileForRangeReadTrueTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"log"
"testing"
"time"

"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
Expand Down Expand Up @@ -80,7 +79,7 @@ func (s *disabledCacheTTLTest) TestReadAfterObjectUpdateIsCacheMiss(t *testing.T
func TestDisabledCacheTTLTest(t *testing.T) {
ts := &disabledCacheTTLTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/read_cache/job_chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"path"
"sync"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/util"
Expand Down Expand Up @@ -161,7 +160,7 @@ func (s *jobChunkTest) TestJobChunkSizeForMultipleFileReads(t *testing.T) {
func TestJobChunkTest(t *testing.T) {
ts := &jobChunkTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"log"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -84,7 +83,7 @@ func (s *localModificationTest) TestReadAfterLocalGCSFuseWriteIsCacheMiss(t *tes
func TestLocalModificationTest(t *testing.T) {
ts := &localModificationTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/read_cache/range_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"log"
"testing"
"time"

"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
Expand Down Expand Up @@ -92,7 +91,7 @@ func (s *rangeReadTest) TestRangeReadsBeyondReadChunkSizeWithFileCached(t *testi
func TestRangeReadTest(t *testing.T) {
ts := &rangeReadTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/read_cache/read_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"log"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -149,7 +148,7 @@ func (s *readOnlyTest) TestReadMultipleFilesWithinCacheLimit(t *testing.T) {
func TestReadOnlyTest(t *testing.T) {
ts := &readOnlyTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tools/integration_tests/read_cache/remount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestRemountTest(t *testing.T) {

// Create storage client before running tests.
ts := &remountTest{ctx: context.Background()}
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tools/integration_tests/read_cache/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/util"
Expand Down Expand Up @@ -131,7 +130,7 @@ func TestMain(m *testing.M) {
setup.ParseSetUpFlags()

ctx = context.Background()
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tools/integration_tests/read_cache/small_cache_ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *smallCacheTTLTest) TestReadForLowMetaDataCacheTTLIsCacheHit(t *testing.
func TestSmallCacheTTLTest(t *testing.T) {
ts := &smallCacheTTLTest{ctx: context.Background()}
// Create storage client before running tests.
closeStorageClient := client.CreateStorageClientWithTimeOut(&ts.ctx, &ts.storageClient, 15*time.Minute)
closeStorageClient := client.CreateStorageClientWithCancel(&ts.ctx, &ts.storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"path"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/client"
Expand Down Expand Up @@ -51,7 +50,7 @@ func TestMain(m *testing.M) {
// Create test directory.
ctx := context.Background()
var storageClient *storage.Client
closeStorageClient := client.CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*15)
closeStorageClient := client.CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions tools/integration_tests/util/client/storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"os"
"reflect"
"testing"
"time"

"cloud.google.com/go/storage"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
Expand Down Expand Up @@ -132,10 +131,10 @@ func CreateObjectOnGCS(ctx context.Context, client *storage.Client, object, cont
}

// CreateStorageClientWithTimeOut creates storage client with a configurable timeout and return a function to cancel the storage client
func CreateStorageClientWithTimeOut(ctx *context.Context, storageClient **storage.Client, time time.Duration) func() error {
func CreateStorageClientWithCancel(ctx *context.Context, storageClient **storage.Client) func() error {
var err error
var cancel context.CancelFunc
*ctx, cancel = context.WithTimeout(*ctx, time)
*ctx, cancel = context.WithCancel(*ctx)
*storageClient, err = CreateStorageClient(*ctx)
if err != nil {
log.Fatalf("client.CreateStorageClient: %v", err)
Expand All @@ -157,7 +156,7 @@ func DownloadObjectFromGCS(gcsFile string, destFileName string, t *testing.T) er

ctx := context.Background()
var storageClient *storage.Client
closeStorageClient := CreateStorageClientWithTimeOut(&ctx, &storageClient, time.Minute*5)
closeStorageClient := CreateStorageClientWithCancel(&ctx, &storageClient)
defer func() {
err := closeStorageClient()
if err != nil {
Expand Down

0 comments on commit ba670ae

Please sign in to comment.