Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed May 18, 2023
1 parent 1dd0725 commit 3c1b059
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
7 changes: 2 additions & 5 deletions internal/dataplane/kong_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ func (m mockConfigurationChangeDetector) HasConfigurationChanged(
}

func TestKongClientUpdate_AllExpectedClientsAreCalledAndErrorIsPropagated(t *testing.T) {
t.Parallel()

var (
ctx = context.Background()
testKonnectClient = mustSampleKonnectClient(t)
Expand Down Expand Up @@ -409,8 +407,6 @@ func (p *mockKongConfigBuilder) returnTranslationFailures(enabled bool) {
}

func TestKongClientUpdate_ConfigStatusIsAlwaysNotified(t *testing.T) {
t.Parallel()

var (
ctx = context.Background()
testKonnectClient = mustSampleKonnectClient(t)
Expand Down Expand Up @@ -525,7 +521,8 @@ func newFakeEventsRecorder() *record.FakeRecorder {

// Ingest events to unblock writing side.
go func() {
for range eventRecorder.Events {
for {
<-eventRecorder.Events
}
}()

Expand Down
21 changes: 4 additions & 17 deletions internal/konnect/node_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,9 @@ func TestNodeAgentUpdateNodes(t *testing.T) {
)

ctx, cancel := context.WithCancel(context.Background())
agentReturned := make(chan struct{})
defer cancel()
go func() {
require.NoError(t, nodeAgent.Start(ctx))
close(agentReturned)
_ = nodeAgent.Start(ctx)
}()

if tc.configStatus != nil {
Expand Down Expand Up @@ -323,21 +322,11 @@ func TestNodeAgentUpdateNodes(t *testing.T) {

return true
}, timeout, tick)

// Cancel the context and wait for the nodeAgent.Start() to return.
cancel()
select {
case <-time.After(timeout):
t.Fatal("expected the agent to return after the context was cancelled")
case <-agentReturned:
}
})
}
}

func TestNodeAgent_StartDoesntReturnUntilContextGetsCancelled(t *testing.T) {
t.Parallel()

nodeClient := newMockNodeClient(nil)
// Always return errors from ListNodes to ensure that the agent doesn't propagate it to the Start() caller.
// ListNodes is the first call made by the agent in Start(), so we care only about this one.
Expand Down Expand Up @@ -402,10 +391,8 @@ func TestNodeAgent_ControllerNodeStatusGetsUpdatedOnStatusNotification(t *testin

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
agentReturned := make(chan struct{})
go func() {
require.NoError(t, nodeAgent.Start(ctx))
close(agentReturned)
_ = nodeAgent.Start(ctx)
}()

testCases := []struct {
Expand Down Expand Up @@ -457,7 +444,7 @@ func TestNodeAgent_ControllerNodeStatusGetsUpdatedOnStatusNotification(t *testin
}

return true
}, time.Second, time.Millisecond*10)
}, time.Second, time.Millisecond)
})
}
}

0 comments on commit 3c1b059

Please sign in to comment.