Skip to content

Commit

Permalink
Fix the flaky failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ravishankar15 committed Dec 19, 2024
1 parent 61f5b97 commit 2167bbf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/component/faro/receiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func Test(t *testing.T) {
defer resp.Body.Close()

require.Equal(t, http.StatusAccepted, resp.StatusCode)
lr.wg.Wait() // Wait for the fakelogreceiver goroutine to process
require.Len(t, lr.GetEntries(), 1)

require.Equal(t, tc.expect, lr.entries[0])
Expand All @@ -146,6 +147,7 @@ type fakeLogsReceiver struct {
ch chan loki.Entry

entriesMut sync.RWMutex
wg sync.WaitGroup
entries []loki.Entry
}

Expand All @@ -158,6 +160,7 @@ func newFakeLogsReceiver(t *testing.T) *fakeLogsReceiver {
ch: make(chan loki.Entry, 1),
}

lr.wg.Add(1)
go func() {
defer close(lr.ch)

Expand All @@ -175,6 +178,7 @@ func newFakeLogsReceiver(t *testing.T) *fakeLogsReceiver {
},
})
lr.entriesMut.Unlock()
lr.wg.Done()
}
}()

Expand Down

0 comments on commit 2167bbf

Please sign in to comment.