Updating EndpointSliceMirroring e2e test to accept multiple slices

Due to informer caching, this caused some flaky test failures.
This commit is contained in:
Rob Scott 2020-10-28 22:14:05 -07:00
parent 5937e7eef7
commit 2c7d186669
No known key found for this signature in database
GPG Key ID: 90C19B2D4A99C91B

View File

@ -79,11 +79,16 @@ var _ = SIGDescribe("EndpointSliceMirroring", func() {
framework.Logf("Error listing EndpointSlices: %v", err)
return false, nil
}
if len(esList.Items) != 1 {
framework.Logf("Waiting for 1 EndpointSlice to exist, got %d", len(esList.Items))
if len(esList.Items) == 0 {
framework.Logf("Waiting for at least 1 EndpointSlice to exist, got %d", len(esList.Items))
return false, nil
}
epSlice := esList.Items[0]
// Due to informer caching, it's possible for the controller
// to create a second EndpointSlice if it does not see the
// first EndpointSlice that was created during a sync. All
// EndpointSlices created should be valid though.
for _, epSlice := range esList.Items {
if len(epSlice.Ports) != 1 {
return false, fmt.Errorf("Expected EndpointSlice to have 1 Port, got %d", len(epSlice.Ports))
}
@ -102,6 +107,7 @@ var _ = SIGDescribe("EndpointSliceMirroring", func() {
if address != "10.1.2.3" {
return false, fmt.Errorf("Expected EndpointSlice to have 10.1.2.3 as address, got %s", address)
}
}
return true, nil
}); err != nil {