From 64374fa4294cf1b143cc67e1e85dfbf726ed0572 Mon Sep 17 00:00:00 2001 From: Jaime Martinez Date: Sun, 22 Nov 2020 11:31:47 +1100 Subject: Increase time for flaky test Cleanup --- internal/config/config.go | 9 +-------- internal/serving/disk/zip/serving_test.go | 8 ++++++++ internal/vfs/zip/archive_test.go | 11 ++++++----- internal/vfs/zip/vfs.go | 2 -- internal/vfs/zip/vfs_test.go | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index f1d70f2c..66f1a2b9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -6,14 +6,7 @@ import ( // Default configuration that can be accessed by different packages var Default = &Config{ - // TODO: remove duplication once all flags are defined in this package - // https://gitlab.com/gitlab-org/gitlab-pages/-/issues/507 - Zip: &ZipServing{ - ExpirationInterval: time.Minute, - CleanupInterval: time.Minute / 2, - RefreshInterval: time.Minute / 2, - OpenTimeout: time.Minute / 2, - }, + Zip: &ZipServing{}, } type Config struct { diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go index bca2ae51..5bf16d7b 100644 --- a/internal/serving/disk/zip/serving_test.go +++ b/internal/serving/disk/zip/serving_test.go @@ -5,9 +5,11 @@ import ( "net/http" "net/http/httptest" "testing" + "time" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitlab-pages/internal/config" "gitlab.com/gitlab-org/gitlab-pages/internal/serving" "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) @@ -53,6 +55,12 @@ func TestZip_ServeFileHTTP(t *testing.T) { }, } + config.Default.Zip = &config.ZipServing{ + ExpirationInterval: 10 * time.Second, + CleanupInterval: 5 * time.Second, + RefreshInterval: 5 * time.Second, + OpenTimeout: 5 * time.Second, + } s := Instance() for name, test := range tests { diff --git a/internal/vfs/zip/archive_test.go b/internal/vfs/zip/archive_test.go index e5fcde54..da778e62 100644 --- a/internal/vfs/zip/archive_test.go +++ b/internal/vfs/zip/archive_test.go @@ -19,13 +19,14 @@ import ( var ( chdirSet = false - zipCfg *config.ZipServing + zipCfg = &config.ZipServing{ + ExpirationInterval: 10 * time.Second, + CleanupInterval: 5 * time.Second, + RefreshInterval: 5 * time.Second, + OpenTimeout: 5 * time.Second, + } ) -func init() { - zipCfg = config.Default.Zip -} - func TestOpen(t *testing.T) { zip, cleanup := openZipArchive(t, nil) defer cleanup() diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go index f853b0b9..d90d4796 100644 --- a/internal/vfs/zip/vfs.go +++ b/internal/vfs/zip/vfs.go @@ -3,7 +3,6 @@ package zip import ( "context" "errors" - "fmt" "net/url" "sync" "time" @@ -50,7 +49,6 @@ type zipVFS struct { // New creates a zipVFS instance that can be used by a serving request func New(cfg *config.ZipServing) vfs.VFS { - fmt.Printf("\n\n\n what the config?: %+v\n\n\n", cfg) zipVFS := &zipVFS{ cacheExpirationInterval: cfg.ExpirationInterval, cacheRefreshInterval: cfg.RefreshInterval, diff --git a/internal/vfs/zip/vfs_test.go b/internal/vfs/zip/vfs_test.go index 0a8a5e0b..ffda1fb6 100644 --- a/internal/vfs/zip/vfs_test.go +++ b/internal/vfs/zip/vfs_test.go @@ -98,7 +98,7 @@ func TestVFSFindOrOpenArchiveConcurrentAccess(t *testing.T) { require.Eventually(t, func() bool { _, err := vfs.findOrOpenArchive(context.Background(), path, path) return err == errAlreadyCached - }, time.Second, time.Nanosecond) + }, 3*time.Second, time.Nanosecond) } func TestVFSFindOrOpenArchiveRefresh(t *testing.T) { -- cgit v1.2.3