mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Ensure events occur regardless of the events in between
This commit is contained in:
parent
39fd803140
commit
5268ba5488
@ -1317,22 +1317,26 @@ retriesLoop:
|
|||||||
// NOTE the test may need access to the events to see what's going on, such as a change in status
|
// NOTE the test may need access to the events to see what's going on, such as a change in status
|
||||||
actualWatchEvents := scenario(resourceWatch)
|
actualWatchEvents := scenario(resourceWatch)
|
||||||
errs := sets.NewString()
|
errs := sets.NewString()
|
||||||
// watchEventsLoop:
|
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
|
||||||
|
|
||||||
totalValidWatchEvents := 0
|
totalValidWatchEvents := 0
|
||||||
actualWatchEventsHasDelete := false
|
foundEventIndexes := map[int]*int{}
|
||||||
for watchEventIndex := range expectedWatchEvents {
|
|
||||||
|
for watchEventIndex, expectedWatchEvent := range expectedWatchEvents {
|
||||||
foundExpectedWatchEvent := false
|
foundExpectedWatchEvent := false
|
||||||
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
|
actualWatchEventsLoop:
|
||||||
for actualWatchEventIndex := range actualWatchEvents {
|
for actualWatchEventIndex, actualWatchEvent := range actualWatchEvents {
|
||||||
if actualWatchEvents[watchEventIndex].Type == expectedWatchEvents[actualWatchEventIndex].Type {
|
if foundEventIndexes[actualWatchEventIndex] != nil {
|
||||||
foundExpectedWatchEvent = true
|
continue actualWatchEventsLoop
|
||||||
}
|
}
|
||||||
if actualWatchEvents[actualWatchEventIndex].Type == watch.Deleted && actualWatchEventsHasDelete != true {
|
if actualWatchEvent.Type == expectedWatchEvent.Type {
|
||||||
actualWatchEventsHasDelete = true
|
foundExpectedWatchEvent = true
|
||||||
|
foundEventIndexes[actualWatchEventIndex] = &watchEventIndex
|
||||||
|
break actualWatchEventsLoop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if foundExpectedWatchEvent == false {
|
if foundExpectedWatchEvent == false {
|
||||||
errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvents[watchEventIndex].Type))
|
errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvent.Type))
|
||||||
}
|
}
|
||||||
totalValidWatchEvents++
|
totalValidWatchEvents++
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user