gossamer icon indicating copy to clipboard operation
gossamer copied to clipboard

Flaky Test In dot/peerset/peerset_test.go

Open juanri0s opened this issue 2 years ago • 3 comments

Describe the bug

Sometimes succeeds, sometimes doesn't. Looks like when it fails its due to the times being equal, so milliseconds matter here.

	triedToConnectAt := ps.peerState.nodes[peer1].lastConnected[testSetID]
	require.True(t, lastDisconectedAt.Before(triedToConnectAt))

go test -timeout 30s -run $Test$ github.com/ChainSafe/gossamer/dot/peerset -count=1

=== TestBanRejectAcceptPeer
    peerset_test.go:56: 
        	Error Trace:	C:/Users/User/Path/To/gossamer/dot/peerset/peerset_test.go:56
        	Error:      	Should be true
        	Test:       	TestBanRejectAcceptPeer
lastDisconnectedAt:  2023-07-05 02:24:22.0133831 -0400 EDT m=+0.112701101
triedToConnectAt:  2023-07-05 02:24:22.0133831 -0400 EDT m=+0.112701101
Equal Times:  true

Machine: Windows 10 x64 based Version: 10.0.19045 Build 19045

juanri0s avatar Jul 05 '23 06:07 juanri0s

I think our best option is to check for equal-ness as well. I tried extending the time to nanoseconds, but the test still failed every now and then.

	triedToConnectAt := ps.peerState.nodes[peer1].lastConnected[testSetID]
	beforeOrEqualTime := lastDisconectedAt.Before(triedToConnectAt) || lastDisconectedAt.Equal(triedToConnectAt)
	require.True(t, beforeOrEqualTime)

Let me know your thoughts. Happy to work on this

juanri0s avatar Jul 06 '23 01:07 juanri0s

@juanri0s, feel free to propose a fix to this problem! If you need help tag me 👍

EclesioMeloJunior avatar Jul 20 '23 18:07 EclesioMeloJunior

Is this issue still relevant? I run the test many times and it always pass:

go test -timeout 30000s -run=TestBanRejectAcceptPeer -count=1000
PASS
ok  	github.com/ChainSafe/gossamer/dot/peerset	1301.643s

EmilGeorgiev avatar Jun 09 '24 11:06 EmilGeorgiev