-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add deadlock regression test #61
base: main
Are you sure you want to change the base?
Changes from all commits
5f8244c
628f799
1ed1cca
c0f91ca
270f20c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,17 @@ package coord | |
|
||
import ( | ||
"context" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/benbjohnson/clock" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/plprobelab/zikade/internal/coord/coordt" | ||
"github.com/plprobelab/zikade/internal/kadtest" | ||
"github.com/plprobelab/zikade/internal/nettest" | ||
"github.com/plprobelab/zikade/kadt" | ||
"github.com/plprobelab/zikade/pb" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPooledQueryConfigValidate(t *testing.T) { | ||
|
@@ -275,7 +274,6 @@ func (ts *QueryBehaviourBaseTestSuite) TestNotifiesQueryFinished() { | |
} | ||
|
||
func TestPooledQuery_deadlock_regression(t *testing.T) { | ||
t.Skip() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uncommented this test |
||
ctx := kadtest.CtxShort(t) | ||
msg := &pb.Message{} | ||
queryID := coordt.QueryID("test") | ||
|
@@ -342,16 +340,13 @@ func TestPooledQuery_deadlock_regression(t *testing.T) { | |
// Advance the query pool state machine. Because we returned a new node | ||
// above, the query pool state machine wants to send another outbound query | ||
ev, _ = c.queryBehaviour.Perform(ctx) | ||
require.IsType(t, &EventAddNode{}, ev) // event to notify the routing table | ||
ev, _ = c.queryBehaviour.Perform(ctx) | ||
require.IsType(t, &EventOutboundSendMessage{}, ev) | ||
ev, _ = c.queryBehaviour.Perform(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best to use DrainBehaviour from #64 here. We just want to run the behaviour until it has completed all its work. Future changes might introduce new events that would affect this test. |
||
require.IsType(t, &EventAddNode{}, ev) // event to notify the routing table | ||
|
||
hasLock := make(chan struct{}) | ||
var once sync.Once | ||
wrappedWaiter.BeforeProgressed = func() { | ||
once.Do(func() { | ||
close(hasLock) | ||
}) | ||
wrappedWaiter.BeforeFinished = func() { | ||
close(hasLock) | ||
} | ||
|
||
// Simulate a successful response from the new node. This node didn't return | ||
|
@@ -361,7 +356,11 @@ func TestPooledQuery_deadlock_regression(t *testing.T) { | |
// of 1, the channel cannot hold both events. At the same time, the waiter | ||
// doesn't consume the messages because it's busy processing the previous | ||
// query event (because we haven't released the blocking waiterMsg call above). | ||
go c.queryBehaviour.Notify(ctx, successMsg(nodes[2].NodeID)) | ||
c.queryBehaviour.Notify(ctx, successMsg(nodes[2].NodeID)) | ||
|
||
ev, ok := c.queryBehaviour.Perform(ctx) | ||
require.Nil(t, ev) | ||
require.False(t, ok) | ||
|
||
// wait until the above Notify call was handled by waiting until the hasLock | ||
// channel was closed in the above BeforeNotify hook. If that hook is called | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to change this, because BeforeFinished was called twice here.