Skip to content

Commit

Permalink
Fix flaky Local SDK test
Browse files Browse the repository at this point in the history
  • Loading branch information
aLekSer committed May 26, 2020
1 parent a26e0e2 commit d30668c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/sdkserver/localsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func TestLocalSDKServerSetLabel(t *testing.T) {
}

for k, v := range fixtures {
k := k
v := v
t.Run(k, func(t *testing.T) {
ctx := context.Background()
e := &sdk.Empty{}
Expand Down Expand Up @@ -257,6 +259,16 @@ func TestLocalSDKServerWatchGameServer(t *testing.T) {
err := l.WatchGameServer(e, stream)
assert.Nil(t, err)
}()
// wait for watching to begin
err = wait.Poll(time.Second, 10*time.Second, func() (bool, error) {
found := false
l.updateObservers.Range(func(_, _ interface{}) bool {
found = true
return false
})
return found, nil
})
assert.NoError(t, err)

assertNoWatchUpdate(t, stream)
fixture.ObjectMeta.Annotations = map[string]string{"foo": "bar"}
Expand Down Expand Up @@ -380,6 +392,8 @@ func TestLocalSDKServerPlayerConnectAndDisconnect(t *testing.T) {
}

for k, v := range fixtures {
k := k
v := v
t.Run(k, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -428,7 +442,9 @@ func TestLocalSDKServerPlayerConnectAndDisconnect(t *testing.T) {
id := &alpha.PlayerID{PlayerID: "one"}
ok, err := l.IsPlayerConnected(context.Background(), id)
assert.NoError(t, err)
assert.False(t, ok.Bool, "player should not be connected")
if assert.NotNil(t, ok) {
assert.False(t, ok.Bool, "player should not be connected")
}

count, err := l.GetPlayerCount(context.Background(), e)
assert.NoError(t, err)
Expand Down

0 comments on commit d30668c

Please sign in to comment.