Skip to content

Commit 43ce0c5

Browse files
committed
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.
1 parent 544b74c commit 43ce0c5

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

test/integration/endpointslice/endpointslicemirroring_test.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestEndpointSliceMirroring(t *testing.T) {
8484
testCases := []struct {
8585
testName string
8686
service *corev1.Service
87-
endpoints *corev1.Endpoints
87+
customEndpoints *corev1.Endpoints
8888
expectEndpointSlice bool
8989
expectEndpointSliceManagedBy string
9090
}{{
@@ -102,11 +102,6 @@ func TestEndpointSliceMirroring(t *testing.T) {
102102
},
103103
},
104104
},
105-
endpoints: &corev1.Endpoints{
106-
ObjectMeta: metav1.ObjectMeta{
107-
Name: "test-123",
108-
},
109-
},
110105
expectEndpointSlice: true,
111106
expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io",
112107
}, {
@@ -121,7 +116,7 @@ func TestEndpointSliceMirroring(t *testing.T) {
121116
}},
122117
},
123118
},
124-
endpoints: &corev1.Endpoints{
119+
customEndpoints: &corev1.Endpoints{
125120
ObjectMeta: metav1.ObjectMeta{
126121
Name: "test-123",
127122
},
@@ -151,13 +146,13 @@ func TestEndpointSliceMirroring(t *testing.T) {
151146
},
152147
},
153148
},
154-
endpoints: nil,
149+
customEndpoints: nil,
155150
expectEndpointSlice: true,
156151
expectEndpointSliceManagedBy: "endpointslice-controller.k8s.io",
157152
}, {
158153
testName: "Endpoints without Service",
159154
service: nil,
160-
endpoints: &corev1.Endpoints{
155+
customEndpoints: &corev1.Endpoints{
161156
ObjectMeta: metav1.ObjectMeta{
162157
Name: "test-123",
163158
},
@@ -180,10 +175,10 @@ func TestEndpointSliceMirroring(t *testing.T) {
180175
}
181176
}
182177

183-
if tc.endpoints != nil {
184-
resourceName = tc.endpoints.Name
185-
tc.endpoints.Namespace = ns.Name
186-
_, err = client.CoreV1().Endpoints(ns.Name).Create(context.TODO(), tc.endpoints, metav1.CreateOptions{})
178+
if tc.customEndpoints != nil {
179+
resourceName = tc.customEndpoints.Name
180+
tc.customEndpoints.Namespace = ns.Name
181+
_, err = client.CoreV1().Endpoints(ns.Name).Create(context.TODO(), tc.customEndpoints, metav1.CreateOptions{})
187182
if err != nil {
188183
t.Fatalf("Error creating endpoints: %v", err)
189184
}

0 commit comments

Comments
 (0)