Skip to content

Commit

Permalink
test: Fix DataRace test cleanup ordering (#1958)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Feb 4, 2025
1 parent 7a3e97b commit 6cf451f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1498,14 +1498,17 @@ var _ = Describe("Consolidated State", func() {
})

var _ = Describe("Data Races", func() {
var wg sync.WaitGroup
var cancelCtx context.Context
var cancel context.CancelFunc
BeforeEach(func() {
cancelCtx, cancel = context.WithCancel(ctx)
})
AfterEach(func() {
cancel()
wg.Wait()
})
It("should ensure that calling Synced() is valid while making updates to Nodes", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
Expand All @@ -1528,13 +1531,6 @@ var _ = Describe("Data Races", func() {
}
})
It("should ensure that calling Synced() is valid while making updates to NodeClaims", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
Expand Down

0 comments on commit 6cf451f

Please sign in to comment.