[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.
This commit is contained in:
Daenney 2023-06-27 18:32:03 +02:00 committed by GitHub
parent d98b6318ac
commit 2a40c81f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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")