From 985acf66f466e9f03fd148c68b1d546c687c7da1 Mon Sep 17 00:00:00 2001 From: Scott Stevenson Date: Tue, 30 Apr 2019 02:57:10 -0400 Subject: [PATCH] Set chunkSize when creating a new GCS backend Adds a small step to TestBackend to prevent regression. --- physical/gcs/gcs.go | 6 +++--- physical/gcs/gcs_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/physical/gcs/gcs.go b/physical/gcs/gcs.go index 134a3773e4a6..da9c3b1fb0dc 100644 --- a/physical/gcs/gcs.go +++ b/physical/gcs/gcs.go @@ -158,9 +158,9 @@ func NewBackend(c map[string]string, logger log.Logger) (physical.Backend, error } return &Backend{ - bucket: bucket, - haEnabled: haEnabled, - + bucket: bucket, + haEnabled: haEnabled, + chunkSize: chunkSize, client: client, permitPool: physical.NewPermitPool(maxParallel), logger: logger, diff --git a/physical/gcs/gcs_test.go b/physical/gcs/gcs_test.go index 64aeaaeb4dbf..4caab730faa7 100644 --- a/physical/gcs/gcs_test.go +++ b/physical/gcs/gcs_test.go @@ -5,6 +5,7 @@ import ( "fmt" "math/rand" "os" + "strconv" "testing" "time" @@ -57,6 +58,17 @@ func TestBackend(t *testing.T) { t.Fatal(err) } + // Verify chunkSize is set correctly on the Backend + be := backend.(*Backend) + expectedChunkSize, err := strconv.Atoi(defaultChunkSize) + if err != nil { + t.Fatalf("failed to convert defaultChunkSize to int: %s", err) + } + expectedChunkSize = expectedChunkSize * 1024 + if be.chunkSize != expectedChunkSize { + t.Fatalf("expected chunkSize to be %d. got=%d", expectedChunkSize, be.chunkSize) + } + physical.ExerciseBackend(t, backend) physical.ExerciseBackend_ListPrefix(t, backend) }