mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +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()
|
errs := sets.NewString()
|
||||||
// watchEventsLoop:
|
// watchEventsLoop:
|
||||||
totalValidWatchEvents := 0
|
totalValidWatchEvents := 0
|
||||||
|
actualWatchEventsHasDelete := false
|
||||||
for watchEventIndex, _ := range expectedWatchEvents {
|
for watchEventIndex, _ := range expectedWatchEvents {
|
||||||
foundExpectedWatchEvent := false
|
foundExpectedWatchEvent := false
|
||||||
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount must be greater than or equal to expected watch events amount")
|
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 {
|
if actualWatchEvents[watchEventIndex].Type == expectedWatchEvents[actualWatchEventIndex].Type {
|
||||||
foundExpectedWatchEvent = true
|
foundExpectedWatchEvent = true
|
||||||
}
|
}
|
||||||
|
if actualWatchEvents[actualWatchEventIndex].Type == watch.Deleted && actualWatchEventsHasDelete != true {
|
||||||
|
actualWatchEventsHasDelete = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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", expectedWatchEvents[watchEventIndex].Type))
|
||||||
}
|
}
|
||||||
totalValidWatchEvents ++
|
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
|
// TODO restructure failures handling
|
||||||
if errs.Len() > 0 && try < retries {
|
if errs.Len() > 0 && try < retries {
|
||||||
fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* "))
|
fmt.Println(fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* ")))
|
||||||
// TODO delete resources via DynamicClient (on failure)
|
|
||||||
continue retriesLoop
|
continue retriesLoop
|
||||||
}
|
}
|
||||||
ExpectEqual(errs.Len() > 0, false, fmt.Errorf("invariants violated:\n* %s", strings.Join(errs.List(), "\n* ")))
|
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