Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ func TestAnonRuleParser_ParseAndValidate(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
// dumpToFile subtests share a hardcoded filename
// (anonRulesFile) and a deferred os.Remove of that path. Running
// them in parallel races: the error-case's cleanup can delete
// the success-case's file before its os.Stat check.
if !tc.dumpToFile {
t.Parallel()
}

// Clean up any test files
defer func() {
Expand Down
21 changes: 13 additions & 8 deletions pkg/wal/processor/webhook/notifier/webhook_notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,24 +363,29 @@ func TestNotifier(t *testing.T) {
close(doneChan)
}()

walEvent := &wal.Event{
CommitPosition: wal.CommitPosition("1"),
Data: &wal.Data{
Action: "I",
},
}

timer := time.NewTimer(5 * time.Second)
defer timer.Stop()
var processErr error
for {
select {
case <-doneChan:
require.ErrorIs(t, processErr, errTest)
// Notify has exited. The next ProcessWALEvent must observe the
// closed notifyDone and return the propagated error — assert on a
// fresh call rather than the previous loop iteration's result,
// which can be nil if Notify exited between PWE calls.
require.ErrorIs(t, n.ProcessWALEvent(context.Background(), walEvent), errTest)
return
case <-timer.C:
t.Error("test timeout")
return
default:
processErr = n.ProcessWALEvent(context.Background(), &wal.Event{
CommitPosition: wal.CommitPosition("1"),
Data: &wal.Data{
Action: "I",
},
})
_ = n.ProcessWALEvent(context.Background(), walEvent)
}
}
}
Expand Down
Loading