Skip to content

Commit e9584ec

Browse files
committed
dial: Fix flake in TestLBServiceResolver
The test was prepending a reactor after Hive was started causing it sometimes to be added too late. Also remove the check that "store should not have started" as that makes no sense since call to "Resolve()" does not affect whether or not a reflector in the background has made the list call or not. $ stress -count 10000 ./dial.test 1m7s: 10000 runs total, 0 failures Fixes: cilium#43157 Fixes: 0e0242e ("dial: Use Table[Frontend] for looking up address") Signed-off-by: Jussi Maki <jussi@isovalent.com>
1 parent 638d5d4 commit e9584ec

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

pkg/dial/resolver_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,21 @@ func testResolver(t *testing.T, cells ...cell.Cell) {
107107

108108
cell.Invoke(func(cl_ *k8sClient.FakeClientset, resolver_ dial.Resolver) {
109109
cl = cl_
110+
111+
// Add a reactor to check that services are being watched.
112+
cl.SlimFakeClientset.PrependReactor("list", "services",
113+
func(action k8stest.Action) (handled bool, ret runtime.Object, err error) {
114+
started.Store(true)
115+
return false, nil, nil
116+
},
117+
)
110118
resolver = resolver_
111119
}),
112120
cell.Group(cells...))
113121

114122
require.NoError(t, h.Start(tlog, ctx))
115123
t.Cleanup(func() { require.NoError(t, h.Stop(tlog, ctx)) })
116124

117-
cl.SlimFakeClientset.PrependReactor("list", "services",
118-
func(action k8stest.Action) (handled bool, ret runtime.Object, err error) {
119-
started.Store(true)
120-
return false, nil, nil
121-
},
122-
)
123-
124125
_, err := cl.Slim().CoreV1().Services("bar").Create(ctx, &slim_corev1.Service{
125126
ObjectMeta: slim_metav1.ObjectMeta{Name: "foo", Namespace: "bar"},
126127
Spec: slim_corev1.ServiceSpec{ClusterIP: "192.168.0.1", Ports: []slim_corev1.ServicePort{{Port: 8080}}},
@@ -137,7 +138,6 @@ func testResolver(t *testing.T, cells ...cell.Cell) {
137138
host, port := resolver.Resolve(ctx, "foo.bar.com", "8080")
138139
require.Equal(t, "foo.bar.com", host)
139140
require.Equal(t, "8080", port)
140-
require.False(t, started.Load(), "The store should not have started")
141141

142142
require.EventuallyWithT(t, func(c *assert.CollectT) {
143143
host, port := resolver.Resolve(ctx, "foo.bar", "8080")

0 commit comments

Comments
 (0)