From 2a40c81f105d592ee474dd28fe8a7fdc31cb73f1 Mon Sep 17 00:00:00 2001 From: Daenney Date: Tue, 27 Jun 2023 18:32:03 +0200 Subject: [PATCH] [bugfix] Try to fix the webfinger test, again (#1931) For some reason we hit the case in CI where the TestFingerWithHostMetaCacheStrategy seems to experience some time dilation. It's possible this is a genuine bug, but I can't for the life of me reproduce it locally, even after having run this test thousands of times (-count=1000 when invoking go test etc.) This changes the test to explicitly stop the webfinger cache, set TTL and Sweep frequency to something well beyond the lifetime of the cache during the test and then starts the cache again. Hopefully that does it, because the other option that remains is that for some reason timekeeping in CI/Docker is not as precise as when running the test on a host. --- internal/transport/finger_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/transport/finger_test.go b/internal/transport/finger_test.go index e6814ac84..1e4a5a92a 100644 --- a/internal/transport/finger_test.go +++ b/internal/transport/finger_test.go @@ -20,6 +20,7 @@ package transport_test import ( "context" "testing" + "time" "github.com/stretchr/testify/suite" ) @@ -55,6 +56,12 @@ func (suite *FingerTestSuite) TestFingerWithHostMeta() { func (suite *FingerTestSuite) TestFingerWithHostMetaCacheStrategy() { wc := suite.state.Caches.GTS.Webfinger() + + // Reset the sweep frequency so nothing interferes with the test + wc.Stop() + wc.SetTTL(1*time.Hour, false) + wc.Start(1 * time.Hour) + suite.Equal(0, wc.Len(), "expect webfinger cache to be empty") _, err := suite.transport.Finger(context.TODO(), "someone", "misconfigured-instance.com")