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

Flake: List Add/Delete Unit Tests #3627

Merged
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
42 changes: 20 additions & 22 deletions pkg/sdkserver/sdkserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1437,16 +1437,8 @@ func TestSDKServerAddListValue(t *testing.T) {
require.NoError(t, err)
assert.NoError(t, sc.WaitForConnection(ctx))
sc.informerFactory.Start(ctx.Done())
assert.True(t, cache.WaitForCacheSync(ctx.Done(), sc.gameServerSynced))

wg := sync.WaitGroup{}
wg.Add(1)

go func() {
err = sc.Run(ctx)
assert.NoError(t, err)
wg.Done()
}()
require.True(t, cache.WaitForCacheSync(ctx.Done(), sc.gameServerSynced))
sc.gsWaitForSync.Done()

// check initial value comes through
require.Eventually(t, func() bool {
Expand All @@ -1469,6 +1461,14 @@ func TestSDKServerAddListValue(t *testing.T) {
assert.Equal(t, testCase.want.Values, got.Values)
assert.Equal(t, testCase.want.Capacity, got.Capacity)

// start workerqueue processing at this point, so there is no chance of processing the above updates
// earlier.
sc.gsWaitForSync.Add(1)
zmerlynn marked this conversation as resolved.
Show resolved Hide resolved
go func() {
err = sc.Run(ctx)
assert.NoError(t, err)
}()

// on an update, confirm that the update hits the K8s api
if testCase.updated {
select {
Expand All @@ -1487,7 +1487,6 @@ func TestSDKServerAddListValue(t *testing.T) {
assert.Equal(t, testCase.expectedUpdatesQueueLen, glu)

cancel()
wg.Wait()
})
}
}
Expand Down Expand Up @@ -1586,16 +1585,8 @@ func TestSDKServerRemoveListValue(t *testing.T) {
require.NoError(t, err)
assert.NoError(t, sc.WaitForConnection(ctx))
sc.informerFactory.Start(ctx.Done())
assert.True(t, cache.WaitForCacheSync(ctx.Done(), sc.gameServerSynced))

wg := sync.WaitGroup{}
wg.Add(1)

go func() {
err = sc.Run(ctx)
assert.NoError(t, err)
wg.Done()
}()
require.True(t, cache.WaitForCacheSync(ctx.Done(), sc.gameServerSynced))
sc.gsWaitForSync.Done()

// check initial value comes through
require.Eventually(t, func() bool {
Expand All @@ -1618,6 +1609,14 @@ func TestSDKServerRemoveListValue(t *testing.T) {
assert.Equal(t, testCase.want.Values, got.Values)
assert.Equal(t, testCase.want.Capacity, got.Capacity)

// start workerqueue processing at this point, so there is no chance of processing the above updates
// earlier.
sc.gsWaitForSync.Add(1)
go func() {
err = sc.Run(ctx)
assert.NoError(t, err)
}()

// on an update, confirm that the update hits the K8s api
if testCase.updated {
select {
Expand All @@ -1636,7 +1635,6 @@ func TestSDKServerRemoveListValue(t *testing.T) {
assert.Equal(t, testCase.expectedUpdatesQueueLen, glu)

cancel()
wg.Wait()
})
}
}
Expand Down
Loading