Skip to content

Commit b276b47

Browse files
author
Antonio Ojea
committed
Deflake TestServiceRegistryUpdateDryRun test
The test suite was using a /24 cluster network for the allocator. The ip allocator, if no ip is specified when creating the cluster, picks one randomly, that means that we had 1/256 chances of collision. The TestServiceRegistryUpdateDryRun was creating a service without a ClusterIP, the ip allocator assigned one random, and it was never deleting it. The same test was checking later if one specific IP was not allocated, not taking into consideration that the same ip may have allocated to the first Service. To avoid any randomness, we create the first Service with a specific IP address.
1 parent 343817e commit b276b47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/registry/core/service/storage/rest_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,10 +1182,10 @@ func TestServiceRegistryUpdateDryRun(t *testing.T) {
11821182
}},
11831183
},
11841184
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
1185-
svc := obj.(*api.Service)
11861185
if err != nil {
11871186
t.Fatalf("Expected no error: %v", err)
11881187
}
1188+
svc := obj.(*api.Service)
11891189

11901190
// Test dry run update request external name to node port
11911191
updatedSvc, created, err := storage.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(&api.Service{
@@ -1251,6 +1251,7 @@ func TestServiceRegistryUpdateDryRun(t *testing.T) {
12511251
Selector: map[string]string{"bar": "baz"},
12521252
SessionAffinity: api.ServiceAffinityNone,
12531253
Type: api.ServiceTypeNodePort,
1254+
ClusterIP: "1.2.3.5",
12541255
Ports: []api.ServicePort{{
12551256
NodePort: 30020,
12561257
Port: 6502,
@@ -1259,10 +1260,11 @@ func TestServiceRegistryUpdateDryRun(t *testing.T) {
12591260
}},
12601261
},
12611262
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
1262-
svc = obj.(*api.Service)
12631263
if err != nil {
12641264
t.Fatalf("Expected no error: %v", err)
12651265
}
1266+
svc = obj.(*api.Service)
1267+
12661268
_, _, err = storage.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(&api.Service{
12671269
ObjectMeta: metav1.ObjectMeta{
12681270
Name: svc.Name,
@@ -1301,10 +1303,10 @@ func TestServiceRegistryUpdateDryRun(t *testing.T) {
13011303
}},
13021304
},
13031305
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
1304-
svc = obj.(*api.Service)
13051306
if err != nil {
13061307
t.Fatalf("Expected no error: %v", err)
13071308
}
1309+
svc = obj.(*api.Service)
13081310
_, _, err = storage.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(&api.Service{
13091311
ObjectMeta: metav1.ObjectMeta{
13101312
Name: svc.Name,

0 commit comments

Comments
 (0)