@@ -173,3 +173,85 @@ func TestPortConvert(t *testing.T) {
173
173
})
174
174
}
175
175
}
176
+
177
+ func TestConvertTCPPortsToAci (t * testing.T ) {
178
+ service := types.ServiceConfig {
179
+ Name : "myService" ,
180
+ Ports : []types.ServicePortConfig {
181
+ {
182
+ Protocol : "" ,
183
+ Target : 80 ,
184
+ Published : 80 ,
185
+ },
186
+ {
187
+ Protocol : "tcp" ,
188
+ Target : 90 ,
189
+ Published : 90 ,
190
+ },
191
+ },
192
+ }
193
+ containerPorts , groupPports , _ , err := convertPortsToAci (serviceConfigAciHelper (service ))
194
+ assert .NilError (t , err )
195
+ assert .DeepEqual (t , containerPorts , []containerinstance.ContainerPort {
196
+ {
197
+ Port : to .Int32Ptr (80 ),
198
+ Protocol : containerinstance .ContainerNetworkProtocolTCP ,
199
+ },
200
+ {
201
+ Port : to .Int32Ptr (90 ),
202
+ Protocol : containerinstance .ContainerNetworkProtocolTCP ,
203
+ },
204
+ })
205
+ assert .DeepEqual (t , groupPports , []containerinstance.Port {
206
+ {
207
+ Port : to .Int32Ptr (80 ),
208
+ Protocol : containerinstance .TCP ,
209
+ },
210
+ {
211
+ Port : to .Int32Ptr (90 ),
212
+ Protocol : containerinstance .TCP ,
213
+ },
214
+ })
215
+ }
216
+
217
+ func TestConvertUDPPortsToAci (t * testing.T ) {
218
+ service := types.ServiceConfig {
219
+ Name : "myService" ,
220
+ Ports : []types.ServicePortConfig {
221
+ {
222
+ Protocol : "udp" ,
223
+ Target : 80 ,
224
+ Published : 80 ,
225
+ },
226
+ },
227
+ }
228
+ containerPorts , groupPports , _ , err := convertPortsToAci (serviceConfigAciHelper (service ))
229
+ assert .NilError (t , err )
230
+ assert .DeepEqual (t , containerPorts , []containerinstance.ContainerPort {
231
+ {
232
+ Port : to .Int32Ptr (80 ),
233
+ Protocol : containerinstance .ContainerNetworkProtocolUDP ,
234
+ },
235
+ })
236
+ assert .DeepEqual (t , groupPports , []containerinstance.Port {
237
+ {
238
+ Port : to .Int32Ptr (80 ),
239
+ Protocol : containerinstance .UDP ,
240
+ },
241
+ })
242
+ }
243
+
244
+ func TestConvertErrorOnMappingPorts (t * testing.T ) {
245
+ service := types.ServiceConfig {
246
+ Name : "myService" ,
247
+ Ports : []types.ServicePortConfig {
248
+ {
249
+ Protocol : "" ,
250
+ Target : 80 ,
251
+ Published : 90 ,
252
+ },
253
+ },
254
+ }
255
+ _ , _ , _ , err := convertPortsToAci (serviceConfigAciHelper (service ))
256
+ assert .Error (t , err , "Port mapping is not supported with ACI, cannot map port 90 to 80 for container myService" )
257
+ }
0 commit comments