From a6d52bb401efc90df61b617a8d916065536622d7 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Thu, 6 Jun 2024 13:28:59 +0100 Subject: [PATCH] fix(build): put in a nasty sleep because cache invalidation Signed-off-by: George MacRorie --- build/testing/integration.go | 4 +++- build/testing/integration/api/api.go | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build/testing/integration.go b/build/testing/integration.go index e3cdb4803b..0f3d7125bd 100644 --- a/build/testing/integration.go +++ b/build/testing/integration.go @@ -327,7 +327,8 @@ func withCockroach(fn testCaseFn) testCaseFn { func cache(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Container, conf testConfig) func() error { flipt = flipt. WithEnvVariable("FLIPT_LOG_LEVEL", "DEBUG"). - WithEnvVariable("FLIPT_CACHE_ENABLED", "true") + WithEnvVariable("FLIPT_CACHE_ENABLED", "true"). + WithEnvVariable("FLIPT_CACHE_TTL", "1s") return suite(ctx, "api", base, flipt.WithExec(nil), conf) } @@ -379,6 +380,7 @@ func cacheWithTLS(ctx context.Context, client *dagger.Client, base, flipt *dagge flipt = flipt. WithEnvVariable("FLIPT_LOG_LEVEL", "DEBUG"). WithEnvVariable("FLIPT_CACHE_ENABLED", "true"). + WithEnvVariable("FLIPT_CACHE_TTL", "1s"). WithEnvVariable("FLIPT_CACHE_BACKEND", "redis"). WithEnvVariable("FLIPT_CACHE_REDIS_REQUIRE_TLS", "true"). WithEnvVariable("FLIPT_CACHE_REDIS_HOST", "redis"). diff --git a/build/testing/integration/api/api.go b/build/testing/integration/api/api.go index 8c9bbd6b1d..e286b65705 100644 --- a/build/testing/integration/api/api.go +++ b/build/testing/integration/api/api.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "testing" + "time" "github.com/gofrs/uuid" "github.com/google/go-cmp/cmp" @@ -101,7 +102,7 @@ func API(t *testing.T, ctx context.Context, client sdk.SDK, opts integration.Tes assert.Equal(t, "Some kind of description", updated.Description) }) - for _, namespace := range integration.Namespaces { + for i, namespace := range integration.Namespaces { t.Run(fmt.Sprintf("namespace %q", namespace.Key), func(t *testing.T) { t.Run("Flags and Variants", func(t *testing.T) { t.Log("Create a new enabled flag with key \"test\".") @@ -1323,6 +1324,15 @@ func API(t *testing.T, ctx context.Context, client sdk.SDK, opts integration.Tes } }) }) + + if i < len(integration.Namespaces)-1 { + // this is lame I know, but its for the cache to attempt to ensure + // evictions between each loop iteration so that we don't polute + // the state between runs + // we could always thread something in to trigger this just + // for the cache tests this impacts things too much + time.Sleep(time.Second) + } } t.Run("Metrics", func(t *testing.T) {