@@ -21,6 +21,7 @@ import (
21
21
"fmt"
22
22
"math/rand"
23
23
"net"
24
+ "sync"
24
25
"testing"
25
26
"time"
26
27
@@ -1474,7 +1475,7 @@ var _ = Describe("Consolidated State", func() {
1474
1475
cluster .MarkUnconsolidated ()
1475
1476
Expect (cluster .ConsolidationState ()).ToNot (Equal (state ))
1476
1477
})
1477
- It ("should update the consolidated value when consolidation timeout (5m) has passed and state hasn't changed" , func () {
1478
+ It ("should update the consolidated value when state timeout (5m) has passed and state hasn't changed" , func () {
1478
1479
state := cluster .ConsolidationState ()
1479
1480
1480
1481
fakeClock .Step (time .Minute )
@@ -1497,14 +1498,21 @@ var _ = Describe("Consolidated State", func() {
1497
1498
})
1498
1499
1499
1500
var _ = Describe ("Data Races" , func () {
1501
+ var wg sync.WaitGroup
1502
+ var cancelCtx context.Context
1503
+ var cancel context.CancelFunc
1504
+ BeforeEach (func () {
1505
+ cancelCtx , cancel = context .WithCancel (ctx )
1506
+ })
1507
+ AfterEach (func () {
1508
+ cancel ()
1509
+ wg .Wait ()
1510
+ })
1500
1511
It ("should ensure that calling Synced() is valid while making updates to Nodes" , func () {
1501
- cancelCtx , cancel := context .WithCancel (ctx )
1502
- DeferCleanup (func () {
1503
- cancel ()
1504
- })
1505
-
1506
1512
// Keep calling Synced for the entirety of this test
1513
+ wg .Add (1 )
1507
1514
go func () {
1515
+ defer wg .Done ()
1508
1516
for {
1509
1517
_ = cluster .Synced (ctx )
1510
1518
if cancelCtx .Err () != nil {
@@ -1523,13 +1531,10 @@ var _ = Describe("Data Races", func() {
1523
1531
}
1524
1532
})
1525
1533
It ("should ensure that calling Synced() is valid while making updates to NodeClaims" , func () {
1526
- cancelCtx , cancel := context .WithCancel (ctx )
1527
- DeferCleanup (func () {
1528
- cancel ()
1529
- })
1530
-
1531
1534
// Keep calling Synced for the entirety of this test
1535
+ wg .Add (1 )
1532
1536
go func () {
1537
+ defer wg .Done ()
1533
1538
for {
1534
1539
_ = cluster .Synced (ctx )
1535
1540
if cancelCtx .Err () != nil {
0 commit comments