Skip to content

Commit

Permalink
test: Fix data race while calling Reset() in CI testing (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Feb 15, 2024
1 parent c5ffa75 commit 15bb262
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controllers/node/termination/terminator/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package terminator_test

import (
"context"
"sync"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -128,12 +129,17 @@ var _ = Describe("Eviction/Queue", func() {
})
It("should ensure that calling Evict() is valid while making Add() calls", func() {
cancelCtx, cancel := context.WithCancel(ctx)
wg := sync.WaitGroup{}
DeferCleanup(func() {
cancel()
wg.Wait() // Ensure that we wait for reconcile loop to finish so that we don't get a RACE
})

// Keep calling Reconcile() for the entirety of this test
wg.Add(1)
go func() {
defer wg.Done()

for {
ExpectReconcileSucceeded(ctx, queue, client.ObjectKey{})
if cancelCtx.Err() != nil {
Expand Down

0 comments on commit 15bb262

Please sign in to comment.