Skip to content

Commit

Permalink
[bugfix] Try to fix the webfinger test, again
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daenney committed Jun 27, 2023
1 parent d98b631 commit fb4cecb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/transport/finger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package transport_test
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit fb4cecb

Please sign in to comment.