Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky TestHandleRefreshWithoutProxyServerStart test #920

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

makhov
Copy link

@makhov makhov commented Dec 9, 2024

Fixes #910

expectedReply is created before we start iterating over test cases, and the clock is ticking, so the server can respond in the next second.

Before the change, it hit the issue 1-3 times in 1000 runs:

 $ go test ./internal/proxy -run TestHandleRefreshWithoutProxyServerStart -count 1000
--- FAIL: TestHandleRefreshWithoutProxyServerStart (0.00s)
    refresh_handler_test.go:198: 
                Error Trace:    /Users/amakhov/www/centrifugo/internal/proxy/refresh_handler_test.go:198
                Error:          Not equal: 
                                expected: centrifuge.RefreshReply{Expired:false, ExpireAt:1733732303, Info:[]uint8(nil)}
                                actual  : centrifuge.RefreshReply{Expired:false, ExpireAt:1733732304, Info:[]uint8(nil)}
                                
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,3 @@
                                  Expired: (bool) false,
                                - ExpireAt: (int64) 1733732303,
                                + ExpireAt: (int64) 1733732304,
                                  Info: ([]uint8) <nil>
                Test:           TestHandleRefreshWithoutProxyServerStart
                Messages:       http
FAIL
FAIL    github.com/centrifugal/centrifugo/v5/internal/proxy     4.763s
FAIL

With the fix there is no failures in 10000 runs:

$ go test ./internal/proxy -run TestHandleRefreshWithoutProxyServerStart -count 10000
ok      github.com/centrifugal/centrifugo/v5/internal/proxy     68.674s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Fix test case failure
1 participant