|
15 | 15 | package e2e
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "context" |
18 | 19 | "fmt"
|
19 | 20 | "testing"
|
20 | 21 | "time"
|
@@ -45,17 +46,28 @@ func TestSurfaceFightError(t *testing.T) {
|
45 | 46 | nt.Must(nt.WatchForAllSyncs())
|
46 | 47 |
|
47 | 48 | // Make the # of updates exceed the fightThreshold defined in pkg/syncer/reconcile/fight_detector.go
|
| 49 | + ctx, cancel := context.WithCancel(t.Context()) |
48 | 50 | go func() {
|
49 |
| - for i := 0; i <= 5; i++ { |
50 |
| - nt.MustMergePatch(ns, `{"metadata": {"annotations": {"foo": "baz"}}}`) |
51 |
| - nt.MustMergePatch(rb, `{"metadata": {"annotations": {"foo": "baz"}}}`) |
52 |
| - time.Sleep(time.Second) |
| 51 | + for { |
| 52 | + select { |
| 53 | + case <-ctx.Done(): |
| 54 | + nt.T.Log("Stopping async status updates") |
| 55 | + return |
| 56 | + default: |
| 57 | + nt.T.Log("async status update") |
| 58 | + nt.MustMergePatch(ns, `{"metadata": {"annotations": {"foo": "baz"}}}`) |
| 59 | + time.Sleep(time.Second) |
| 60 | + } |
53 | 61 | }
|
54 | 62 | }()
|
55 | 63 |
|
56 | 64 | nt.T.Log("The RootSync reports a fight error")
|
57 |
| - nt.Must(nt.Watcher.WatchForRootSyncSyncError(configsync.RootSyncName, status.FightErrorCode, |
58 |
| - "This may indicate Config Sync is fighting with another controller over the object.", nil)) |
| 65 | + err := nt.Watcher.WatchForRootSyncSyncError(configsync.RootSyncName, status.FightErrorCode, |
| 66 | + "This may indicate Config Sync is fighting with another controller over the object.", nil) |
| 67 | + cancel() |
| 68 | + if err != nil { |
| 69 | + nt.T.Fatal(err) |
| 70 | + } |
59 | 71 |
|
60 | 72 | rootSyncNN := nomostest.RootSyncNN(configsync.RootSyncName)
|
61 | 73 | rootSyncLabels, err := nomostest.MetricLabelsForRootSync(nt, rootSyncNN)
|
|
0 commit comments