Fixing a flaky EndpointSliceMirroring integration test
This test was trying to create an Endpoints resource that the Endpoints controller would also attempt to create. This could result in a failure if the Endpoints controller created the resource before the test did.
This commit is contained in:
		| @@ -84,7 +84,7 @@ func TestEndpointSliceMirroring(t *testing.T) { | |||||||
| 	testCases := []struct { | 	testCases := []struct { | ||||||
| 		testName                     string | 		testName                     string | ||||||
| 		service                      *corev1.Service | 		service                      *corev1.Service | ||||||
| 		endpoints                    *corev1.Endpoints | 		customEndpoints              *corev1.Endpoints | ||||||
| 		expectEndpointSlice          bool | 		expectEndpointSlice          bool | ||||||
| 		expectEndpointSliceManagedBy string | 		expectEndpointSliceManagedBy string | ||||||
| 	}{{ | 	}{{ | ||||||
| @@ -102,11 +102,6 @@ func TestEndpointSliceMirroring(t *testing.T) { | |||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		endpoints: &corev1.Endpoints{ |  | ||||||
| 			ObjectMeta: metav1.ObjectMeta{ |  | ||||||
| 				Name: "test-123", |  | ||||||
| 			}, |  | ||||||
| 		}, |  | ||||||
| 		expectEndpointSlice:          true, | 		expectEndpointSlice:          true, | ||||||
| 		expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io", | 		expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io", | ||||||
| 	}, { | 	}, { | ||||||
| @@ -121,7 +116,7 @@ func TestEndpointSliceMirroring(t *testing.T) { | |||||||
| 				}}, | 				}}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		endpoints: &corev1.Endpoints{ | 		customEndpoints: &corev1.Endpoints{ | ||||||
| 			ObjectMeta: metav1.ObjectMeta{ | 			ObjectMeta: metav1.ObjectMeta{ | ||||||
| 				Name: "test-123", | 				Name: "test-123", | ||||||
| 			}, | 			}, | ||||||
| @@ -151,13 +146,13 @@ func TestEndpointSliceMirroring(t *testing.T) { | |||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		endpoints:                    nil, | 		customEndpoints:              nil, | ||||||
| 		expectEndpointSlice:          true, | 		expectEndpointSlice:          true, | ||||||
| 		expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io", | 		expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io", | ||||||
| 	}, { | 	}, { | ||||||
| 		testName: "Endpoints without Service", | 		testName: "Endpoints without Service", | ||||||
| 		service:  nil, | 		service:  nil, | ||||||
| 		endpoints: &corev1.Endpoints{ | 		customEndpoints: &corev1.Endpoints{ | ||||||
| 			ObjectMeta: metav1.ObjectMeta{ | 			ObjectMeta: metav1.ObjectMeta{ | ||||||
| 				Name: "test-123", | 				Name: "test-123", | ||||||
| 			}, | 			}, | ||||||
| @@ -180,10 +175,10 @@ func TestEndpointSliceMirroring(t *testing.T) { | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if tc.endpoints != nil { | 			if tc.customEndpoints != nil { | ||||||
| 				resourceName = tc.endpoints.Name | 				resourceName = tc.customEndpoints.Name | ||||||
| 				tc.endpoints.Namespace = ns.Name | 				tc.customEndpoints.Namespace = ns.Name | ||||||
| 				_, err = client.CoreV1().Endpoints(ns.Name).Create(context.TODO(), tc.endpoints, metav1.CreateOptions{}) | 				_, err = client.CoreV1().Endpoints(ns.Name).Create(context.TODO(), tc.customEndpoints, metav1.CreateOptions{}) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("Error creating endpoints: %v", err) | 					t.Fatalf("Error creating endpoints: %v", err) | ||||||
| 				} | 				} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rob Scott
					Rob Scott