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

[Merged by Bors] - Add sleep to make data race less likely #6231

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions fetch/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ func TestFetch_RequestHashBatchFromPeers(t *testing.T) {

for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

f := createFetch(t)
f.cfg.MaxRetriesForRequest = 0
peer := p2p.Peer("buddy")
Expand Down
8 changes: 7 additions & 1 deletion fetch/p2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func createP2PFetch(
) (*testP2PFetch, context.Context) {
lg := zaptest.NewLogger(t)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
t.Cleanup(cancel)

serverHost, err := p2p.AutoStart(ctx, lg, p2pCfg(t), []byte{}, []byte{})
require.NoError(t, err)
Expand All @@ -100,6 +99,13 @@ func createP2PFetch(
require.NoError(t, err)
t.Cleanup(func() { assert.NoError(t, clientHost.Stop()) })

t.Cleanup(func() {
cancel()
time.Sleep(10 * time.Millisecond)
// mafa: p2p internally uses a global logger this should prevent logging after
// the test ends (send PR with fix to libp2p/go-libp2p-pubsub) (go loop in pubsub.go)
})

var sqlOpts []sql.Opt
if sqlCache {
sqlOpts = []sql.Opt{sql.WithQueryCache(true)}
Expand Down
Loading