@@ -51,7 +51,7 @@ func TestGeneratePatches(
51
51
Path : "/spec/template/spec/network/cni" ,
52
52
ValueMatcher : gomega .HaveKeyWithValue (
53
53
"cniIngressRules" ,
54
- gomega .ContainElements (
54
+ gomega .ConsistOf (
55
55
gomega .SatisfyAll (
56
56
gomega .HaveKeyWithValue ("description" , "typha (calico)" ),
57
57
gomega .HaveKeyWithValue (
@@ -101,5 +101,177 @@ func TestGeneratePatches(
101
101
),
102
102
}},
103
103
},
104
+ capitest.PatchTestDef {
105
+ Name : "provider set with AWSClusterTemplate pre-existing rules" ,
106
+ Vars : []runtimehooksv1.Variable {
107
+ capitest .VariableWithValue (
108
+ variableName ,
109
+ v1alpha1.CNI {
110
+ Provider : v1alpha1 .CNIProviderCalico ,
111
+ },
112
+ variablePath ... ,
113
+ ),
114
+ },
115
+ RequestItem : request .NewAWSClusterTemplateRequestItem (
116
+ "1234" ,
117
+ capav1.AWSClusterTemplateSpec {
118
+ Template : capav1.AWSClusterTemplateResource {
119
+ Spec : capav1.AWSClusterSpec {
120
+ NetworkSpec : capav1.NetworkSpec {
121
+ CNI : & capav1.CNISpec {
122
+ CNIIngressRules : []capav1.CNIIngressRule {{
123
+ Description : "test" ,
124
+ Protocol : capav1 .SecurityGroupProtocolAll ,
125
+ FromPort : 1234 ,
126
+ ToPort : 12345 ,
127
+ }},
128
+ },
129
+ },
130
+ },
131
+ },
132
+ },
133
+ ),
134
+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
135
+ Operation : "add" ,
136
+ Path : "/spec/template/spec/network/cni/cniIngressRules/1" ,
137
+ ValueMatcher : gomega .SatisfyAll (
138
+ gomega .HaveKeyWithValue ("description" , "typha (calico)" ),
139
+ gomega .HaveKeyWithValue (
140
+ "protocol" ,
141
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
142
+ ),
143
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (5473 )),
144
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (5473 )),
145
+ ),
146
+ }, {
147
+ Operation : "add" ,
148
+ Path : "/spec/template/spec/network/cni/cniIngressRules/2" ,
149
+ ValueMatcher : gomega .SatisfyAll (
150
+ gomega .HaveKeyWithValue ("description" , "bgp (calico)" ),
151
+ gomega .HaveKeyWithValue (
152
+ "protocol" ,
153
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
154
+ ),
155
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (179 )),
156
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (179 )),
157
+ ),
158
+ }, {
159
+ Operation : "add" ,
160
+ Path : "/spec/template/spec/network/cni/cniIngressRules/3" ,
161
+ ValueMatcher : gomega .SatisfyAll (
162
+ gomega .HaveKeyWithValue ("description" , "IP-in-IP (calico)" ),
163
+ gomega .HaveKeyWithValue (
164
+ "protocol" ,
165
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolIPinIP ),
166
+ ),
167
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (- 1 )),
168
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (65535 )),
169
+ ),
170
+ }, {
171
+ Operation : "add" ,
172
+ Path : "/spec/template/spec/network/cni/cniIngressRules/4" ,
173
+ ValueMatcher : gomega .SatisfyAll (
174
+ gomega .HaveKeyWithValue ("description" , "node metrics (calico)" ),
175
+ gomega .HaveKeyWithValue (
176
+ "protocol" ,
177
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
178
+ ),
179
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (9091 )),
180
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (9091 )),
181
+ ),
182
+ }, {
183
+ Operation : "add" ,
184
+ Path : "/spec/template/spec/network/cni/cniIngressRules/5" ,
185
+ ValueMatcher : gomega .SatisfyAll (
186
+ gomega .HaveKeyWithValue ("description" , "typha metrics (calico)" ),
187
+ gomega .HaveKeyWithValue (
188
+ "protocol" ,
189
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
190
+ ),
191
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (9093 )),
192
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (9093 )),
193
+ ),
194
+ }},
195
+ },
196
+ capitest.PatchTestDef {
197
+ Name : "provider set with AWSClusterTemplate conflicting pre-existing rules" ,
198
+ Vars : []runtimehooksv1.Variable {
199
+ capitest .VariableWithValue (
200
+ variableName ,
201
+ v1alpha1.CNI {
202
+ Provider : v1alpha1 .CNIProviderCalico ,
203
+ },
204
+ variablePath ... ,
205
+ ),
206
+ },
207
+ RequestItem : request .NewAWSClusterTemplateRequestItem (
208
+ "1234" ,
209
+ capav1.AWSClusterTemplateSpec {
210
+ Template : capav1.AWSClusterTemplateResource {
211
+ Spec : capav1.AWSClusterSpec {
212
+ NetworkSpec : capav1.NetworkSpec {
213
+ CNI : & capav1.CNISpec {
214
+ CNIIngressRules : []capav1.CNIIngressRule {{
215
+ Description : "typha (calico)" ,
216
+ Protocol : capav1 .SecurityGroupProtocolTCP ,
217
+ FromPort : 5473 ,
218
+ ToPort : 5473 ,
219
+ }},
220
+ },
221
+ },
222
+ },
223
+ },
224
+ },
225
+ ),
226
+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
227
+ Operation : "add" ,
228
+ Path : "/spec/template/spec/network/cni/cniIngressRules/1" ,
229
+ ValueMatcher : gomega .SatisfyAll (
230
+ gomega .HaveKeyWithValue ("description" , "bgp (calico)" ),
231
+ gomega .HaveKeyWithValue (
232
+ "protocol" ,
233
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
234
+ ),
235
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (179 )),
236
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (179 )),
237
+ ),
238
+ }, {
239
+ Operation : "add" ,
240
+ Path : "/spec/template/spec/network/cni/cniIngressRules/2" ,
241
+ ValueMatcher : gomega .SatisfyAll (
242
+ gomega .HaveKeyWithValue ("description" , "IP-in-IP (calico)" ),
243
+ gomega .HaveKeyWithValue (
244
+ "protocol" ,
245
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolIPinIP ),
246
+ ),
247
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (- 1 )),
248
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (65535 )),
249
+ ),
250
+ }, {
251
+ Operation : "add" ,
252
+ Path : "/spec/template/spec/network/cni/cniIngressRules/3" ,
253
+ ValueMatcher : gomega .SatisfyAll (
254
+ gomega .HaveKeyWithValue ("description" , "node metrics (calico)" ),
255
+ gomega .HaveKeyWithValue (
256
+ "protocol" ,
257
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
258
+ ),
259
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (9091 )),
260
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (9091 )),
261
+ ),
262
+ }, {
263
+ Operation : "add" ,
264
+ Path : "/spec/template/spec/network/cni/cniIngressRules/4" ,
265
+ ValueMatcher : gomega .SatisfyAll (
266
+ gomega .HaveKeyWithValue ("description" , "typha metrics (calico)" ),
267
+ gomega .HaveKeyWithValue (
268
+ "protocol" ,
269
+ gomega .BeEquivalentTo (capav1 .SecurityGroupProtocolTCP ),
270
+ ),
271
+ gomega .HaveKeyWithValue ("fromPort" , gomega .BeEquivalentTo (9093 )),
272
+ gomega .HaveKeyWithValue ("toPort" , gomega .BeEquivalentTo (9093 )),
273
+ ),
274
+ }},
275
+ },
104
276
)
105
277
}
0 commit comments