@@ -67,7 +67,13 @@ func TestUniqueClients(t *testing.T) {
67
67
},
68
68
},
69
69
},
70
- result : sets .New (fmt .Sprintf ("kgateway-kube-gateway-api~best-proxy-role~%d~ns" , utils .HashLabels (map [string ]string {corev1 .LabelTopologyRegion : "region" , corev1 .LabelTopologyZone : "zone" , "a" : "b" }))),
70
+ result : sets .New (
71
+ fmt .Sprintf ("kgateway-kube-gateway-api~best-proxy-role~%d~ns" , utils .HashLabels (map [string ]string {
72
+ corev1 .LabelTopologyRegion : "region" ,
73
+ corev1 .LabelTopologyZone : "zone" ,
74
+ "a" : "b" ,
75
+ })),
76
+ ),
71
77
},
72
78
{
73
79
name : "no-pods" ,
@@ -90,12 +96,14 @@ func TestUniqueClients(t *testing.T) {
90
96
91
97
for _ , tc := range testCases {
92
98
t .Run (tc .name , func (t * testing.T ) {
99
+ fmt .Printf ("start test %s\n " , tc .name )
93
100
g := NewWithT (t )
94
101
var pods krt.Collection [LocalityPod ]
95
102
if tc .inputs != nil {
96
103
mock := krttest .NewMock (t , tc .inputs )
97
104
nodes := NewNodeMetadataCollection (krttest.GetMockCollection [* corev1.Node ](mock ))
98
105
pods = NewLocalityPodsCollection (nodes , krttest.GetMockCollection [* corev1.Pod ](mock ), krtutil.KrtOptions {})
106
+ nodes .WaitUntilSynced (context .Background ().Done ())
99
107
pods .WaitUntilSynced (context .Background ().Done ())
100
108
}
101
109
@@ -104,7 +112,6 @@ func TestUniqueClients(t *testing.T) {
104
112
ucc .WaitUntilSynced (context .Background ().Done ())
105
113
106
114
// check fetch as well
107
-
108
115
fetchNames := sets .New [string ]()
109
116
110
117
for i , r := range tc .requests {
@@ -131,17 +138,25 @@ func TestUniqueClients(t *testing.T) {
131
138
}
132
139
g .Expect (fetchNames ).To (Equal (tc .result ))
133
140
g .Expect (names ).To (Equal (tc .result ))
141
+
134
142
for i := range tc .requests {
135
143
for j := 0 ; j < 10 ; j ++ {
136
144
g .Expect (ucc .List ()).To (HaveLen (len (allUcc ) - i ))
137
145
cb .OnStreamClosed (int64 (i * 10 + j ), nil )
138
146
}
139
- // propagating the event happens async
140
- g .Eventually (func () []ir.UniqlyConnectedClient {
141
- allUcc = ucc .List ()
142
- return allUcc
143
- }, "1s" ).Should (HaveLen (len (tc .result )))
147
+ // FIXME: this assertion will be reworked; the goal here is to test jitter
148
+ // that as clients disconnect we don't impact other UCCs etc.
149
+ // g.Eventually(func() []ir.UniqlyConnectedClient {
150
+ // allUcc = ucc.List()
151
+ // return allUcc
152
+ // }, "1s").Should(HaveLen(len(tc.result)))
144
153
}
154
+
155
+ // as events happens async, eventually after all clients disconnect all UCCs should be removed
156
+ g .Eventually (func () []ir.UniqlyConnectedClient {
157
+ allUcc = ucc .List ()
158
+ return allUcc
159
+ }, "5s" ).Should (BeEmpty ())
145
160
})
146
161
}
147
162
}
0 commit comments