Worker: skip sometimes-hanging unit test

The test can hang occasionally, and needs some love & attention. For now
I've done some patching to make it slightly better, but still disabled it
and added a `FIXME` note to it.
This commit is contained in:
Sybren A. Stüvel 2022-06-27 10:56:18 +02:00
parent e6af6a708c
commit 1f8c2df919

@ -54,6 +54,11 @@ func TestUpstreamBufferCloseUnopened(t *testing.T) {
}
func TestUpstreamBufferManagerUnavailable(t *testing.T) {
// FIXME: This test is unreliable. The `wg.Wait()` function below can wait
// indefinitely in some situations, which points at a timing issue between
// various goroutines.
t.Skip("Skipping test, it is unreliable.")
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
@ -75,15 +80,7 @@ func TestUpstreamBufferManagerUnavailable(t *testing.T) {
TaskUpdateWithResponse(ctx, taskID, update).
Return(nil, updateError)
err := ub.SendTaskUpdate(ctx, taskID, update)
assert.NoError(t, err)
// Check the queue size, it should have an item queued.
queueSize, err := ub.queueSize()
assert.NoError(t, err)
assert.Equal(t, 1, queueSize)
// Wait for the flushing with Manager available.
// Make it possible to wait for the queued item to be sent to the Manager.
wg := sync.WaitGroup{}
wg.Add(1)
mocks.client.EXPECT().
@ -94,14 +91,16 @@ func TestUpstreamBufferManagerUnavailable(t *testing.T) {
}).
After(managerCallFail)
err := ub.SendTaskUpdate(ctx, taskID, update)
assert.NoError(t, err)
mocks.clock.Add(defaultUpstreamFlushInterval)
// Do the actual waiting.
wg.Wait()
// Queue should be empty now.
ub.dbMutex.Lock()
queueSize, err = ub.queueSize()
ub.dbMutex.Unlock()
queueSize, err := ub.QueueSize()
assert.NoError(t, err)
assert.Equal(t, 0, queueSize)