From 9f0c24ddcffc7d857a3725b96f52c306186062f7 Mon Sep 17 00:00:00 2001 From: Caleb Woodbine Date: Mon, 25 May 2020 13:33:48 +1200 Subject: [PATCH] Fix checks, amount checking --- test/e2e/framework/util.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 2fbc016b4f3..b4b8049bd44 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -1312,22 +1312,22 @@ retriesLoop: // NOTE the test may need access to the events to see what's going on, such as a change in status actualWatchEvents := scenario(resourceWatch) errs := sets.NewString() - watchEventsLoop: + // watchEventsLoop: + totalValidWatchEvents := 0 for watchEventIndex, _ := range expectedWatchEvents { foundExpectedWatchEvent := false - watchEventNextIndex := watchEventIndex + 1 - if watchEventNextIndex >= len(expectedWatchEvents) { - continue watchEventsLoop - } + ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount must be greater than or equal to expected watch events amount") for actualWatchEventIndex, _ := range actualWatchEvents { - if actualWatchEvents[watchEventIndex] == expectedWatchEvents[actualWatchEventIndex] { + if actualWatchEvents[watchEventIndex].Type == expectedWatchEvents[actualWatchEventIndex].Type { foundExpectedWatchEvent = true } } if foundExpectedWatchEvent == false { - errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvents[watchEventIndex])) + errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvents[watchEventIndex].Type)) } + totalValidWatchEvents ++ } + ExpectEqual(totalValidWatchEvents, len(expectedWatchEvents), "Error: there must be an equal amount of total valid watch events (%v) and expected watch events (%v)", totalValidWatchEvents, len(expectedWatchEvents)) // TODO restructure failures handling if errs.Len() > 0 && try < retries { fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* "))