@@ -75,6 +75,84 @@ func TestUniqueClients(t *testing.T) {
75
75
})),
76
76
),
77
77
},
78
+ {
79
+ name : "two UCCs" ,
80
+ inputs : []any {
81
+ & corev1.Pod {
82
+ TypeMeta : metav1.TypeMeta {},
83
+ ObjectMeta : metav1.ObjectMeta {
84
+ Name : "podname" ,
85
+ Namespace : "ns" ,
86
+ Labels : map [string ]string {"a" : "b" },
87
+ },
88
+ Spec : corev1.PodSpec {
89
+ NodeName : "node" ,
90
+ },
91
+ },
92
+ & corev1.Node {
93
+ ObjectMeta : metav1.ObjectMeta {
94
+ Name : "node" ,
95
+ Labels : map [string ]string {
96
+ corev1 .LabelTopologyRegion : "region" ,
97
+ corev1 .LabelTopologyZone : "zone" ,
98
+ },
99
+ },
100
+ },
101
+ & corev1.Pod {
102
+ TypeMeta : metav1.TypeMeta {},
103
+ ObjectMeta : metav1.ObjectMeta {
104
+ Name : "podname2" ,
105
+ Namespace : "ns" ,
106
+ Labels : map [string ]string {"a" : "b" },
107
+ },
108
+ Spec : corev1.PodSpec {
109
+ NodeName : "node2" ,
110
+ },
111
+ },
112
+ & corev1.Node {
113
+ ObjectMeta : metav1.ObjectMeta {
114
+ Name : "node2" ,
115
+ Labels : map [string ]string {
116
+ corev1 .LabelTopologyRegion : "region2" ,
117
+ corev1 .LabelTopologyZone : "zone2" ,
118
+ },
119
+ },
120
+ },
121
+ },
122
+ requests : []* envoy_service_discovery_v3.DiscoveryRequest {
123
+ {
124
+ Node : & corev3.Node {
125
+ Id : "podname.ns" ,
126
+ Metadata : & structpb.Struct {
127
+ Fields : map [string ]* structpb.Value {
128
+ xds .RoleKey : structpb .NewStringValue (wellknown .GatewayApiProxyValue + "~best-proxy-role" ),
129
+ },
130
+ },
131
+ },
132
+ },
133
+ {
134
+ Node : & corev3.Node {
135
+ Id : "podname2.ns" ,
136
+ Metadata : & structpb.Struct {
137
+ Fields : map [string ]* structpb.Value {
138
+ xds .RoleKey : structpb .NewStringValue (wellknown .GatewayApiProxyValue + "~best-proxy-role" ),
139
+ },
140
+ },
141
+ },
142
+ },
143
+ },
144
+ result : sets .New (
145
+ fmt .Sprintf ("kgateway-kube-gateway-api~best-proxy-role~%d~ns" , utils .HashLabels (map [string ]string {
146
+ corev1 .LabelTopologyRegion : "region" ,
147
+ corev1 .LabelTopologyZone : "zone" ,
148
+ "a" : "b" ,
149
+ })), fmt .Sprintf ("kgateway-kube-gateway-api~best-proxy-role~%d~ns" , utils .HashLabels (map [string ]string {
150
+ corev1 .LabelTopologyRegion : "region2" ,
151
+ corev1 .LabelTopologyZone : "zone2" ,
152
+ "a" : "b" ,
153
+ })),
154
+ ),
155
+ },
78
156
{
79
157
name : "no-pods" ,
80
158
inputs : nil ,
@@ -140,16 +218,17 @@ func TestUniqueClients(t *testing.T) {
140
218
g .Expect (names ).To (Equal (tc .result ))
141
219
142
220
for i := range tc .requests {
143
- for j := 0 ; j < 10 ; j ++ {
144
- g .Expect (ucc .List ()).To (HaveLen (len (allUcc ) - i ))
221
+ for j := 0 ; j < 9 ; j ++ {
145
222
cb .OnStreamClosed (int64 (i * 10 + j ), nil )
146
223
}
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)))
224
+ }
225
+
226
+ g .Expect (ucc .List ()).Should (HaveLen (len (tc .result )))
227
+
228
+ for i := range tc .requests {
229
+ j := 9
230
+ g .Eventually (ucc .List ).Should (HaveLen (len (allUcc ) - i ))
231
+ cb .OnStreamClosed (int64 (i * 10 + j ), nil )
153
232
}
154
233
155
234
// as events happens async, eventually after all clients disconnect all UCCs should be removed
0 commit comments