Skip to content

Commit 63c0094

Browse files
committed
fix: disable WatchListClient feature gate in tests using fake client
k8s.io/client-go v0.35.0 enables WatchListClient by default, which requires bookmark events from the API server. The Istio fake client doesn't support this, causing informers to hang indefinitely.
1 parent c3e3075 commit 63c0094

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

extvirtualservice/action_reusable_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Test_attackLifecycle(t *testing.T) {
2121
// General preparation
2222
stopCh := make(chan struct{})
2323
defer close(stopCh)
24-
client, clientset := getTestClient(stopCh)
24+
client, clientset := getTestClient(t, stopCh)
2525
extclient.Istio = client
2626
extconfig.Config.ClusterName = "development"
2727

@@ -163,7 +163,7 @@ func Test_attackLifecycle_with_client_restriction(t *testing.T) {
163163
// General preparation
164164
stopCh := make(chan struct{})
165165
defer close(stopCh)
166-
client, clientset := getTestClient(stopCh)
166+
client, clientset := getTestClient(t, stopCh)
167167
extclient.Istio = client
168168
extconfig.Config.ClusterName = "development"
169169

@@ -323,7 +323,7 @@ func Test_attackLifecycle_with_source_label(t *testing.T) {
323323
// General preparation
324324
stopCh := make(chan struct{})
325325
defer close(stopCh)
326-
client, clientset := getTestClient(stopCh)
326+
client, clientset := getTestClient(t, stopCh)
327327
extclient.Istio = client
328328
extconfig.Config.ClusterName = "development"
329329

extvirtualservice/discovery_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
versionedClient "istio.io/client-go/pkg/clientset/versioned"
1414
testclient "istio.io/client-go/pkg/clientset/versioned/fake"
1515
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/client-go/features"
17+
clientfeaturestesting "k8s.io/client-go/features/testing"
1618
"testing"
1719
"time"
1820
)
@@ -21,7 +23,7 @@ func Test_getDiscoveredVirtualServices(t *testing.T) {
2123
// Given
2224
stopCh := make(chan struct{})
2325
defer close(stopCh)
24-
client, clientset := getTestClient(stopCh)
26+
client, clientset := getTestClient(t, stopCh)
2527
extconfig.Config.ClusterName = "development"
2628
extconfig.Config.DiscoveryAttributesExcludesVirtualSerice = []string{"k8s.virtual-service.label.toIgnore"}
2729

@@ -64,7 +66,11 @@ func Test_getDiscoveredVirtualServices(t *testing.T) {
6466
}, target.Attributes)
6567
}
6668

67-
func getTestClient(stopCh <-chan struct{}) (*extclient.IstioClient, versionedClient.Interface) {
69+
func getTestClient(t testing.TB, stopCh <-chan struct{}) (*extclient.IstioClient, versionedClient.Interface) {
70+
// Disable WatchListClient feature gate: the fake client doesn't support
71+
// the bookmark events required by the WatchList stream, causing informers
72+
// to hang indefinitely.
73+
clientfeaturestesting.SetFeatureDuringTest(t, features.WatchListClient, false)
6874
clientset := testclient.NewSimpleClientset()
6975
client := extclient.NewIstioClient(clientset, stopCh)
7076
return client, clientset

0 commit comments

Comments
 (0)