mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Add resource deleting if there wasn't a delete watch event found
This commit is contained in:
parent
9f0c24ddcf
commit
1bdb854e7e
@ -1314,6 +1314,7 @@ retriesLoop:
|
||||
errs := sets.NewString()
|
||||
// watchEventsLoop:
|
||||
totalValidWatchEvents := 0
|
||||
actualWatchEventsHasDelete := false
|
||||
for watchEventIndex, _ := range expectedWatchEvents {
|
||||
foundExpectedWatchEvent := false
|
||||
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount must be greater than or equal to expected watch events amount")
|
||||
@ -1321,20 +1322,24 @@ retriesLoop:
|
||||
if actualWatchEvents[watchEventIndex].Type == expectedWatchEvents[actualWatchEventIndex].Type {
|
||||
foundExpectedWatchEvent = true
|
||||
}
|
||||
if actualWatchEvents[actualWatchEventIndex].Type == watch.Deleted && actualWatchEventsHasDelete != true {
|
||||
actualWatchEventsHasDelete = true
|
||||
}
|
||||
}
|
||||
if foundExpectedWatchEvent == false {
|
||||
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))
|
||||
if actualWatchEventsHasDelete == false {
|
||||
_ = dc.Resource(resourceType).Namespace(namespace).DeleteCollection(testContext, metav1.DeleteOptions{}, listOptions)
|
||||
}
|
||||
// TODO restructure failures handling
|
||||
if errs.Len() > 0 && try < retries {
|
||||
fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* "))
|
||||
// TODO delete resources via DynamicClient (on failure)
|
||||
fmt.Println(fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* ")))
|
||||
continue retriesLoop
|
||||
}
|
||||
ExpectEqual(errs.Len() > 0, false, fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* ")))
|
||||
// TODO delete resources via DynamicClient (on failure)
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user