@@ -45,20 +45,32 @@ func TestServiceDiscoveryClient_ListServices_HappyCase(t *testing.T) {
45
45
{
46
46
InstanceId : aws .String (test .EndptId1 ),
47
47
Attributes : map [string ]string {
48
- model .Ipv4Attr : test .EndptIp1 ,
49
- model .PortAttr : test .EndptPortStr1 ,
48
+ model .EndpointIpv4Attr : test .EndptIp1 ,
49
+ model .EndpointPortAttr : test .PortStr1 ,
50
+ model .EndpointPortNameAttr : test .PortName1 ,
51
+ model .EndpointProtocolAttr : test .Protocol1 ,
52
+ model .ServicePortNameAttr : test .PortName1 ,
53
+ model .ServicePortAttr : test .ServicePortStr1 ,
54
+ model .ServiceProtocolAttr : test .Protocol1 ,
55
+ model .ServiceTargetPortAttr : test .PortStr1 ,
50
56
},
51
57
},
52
58
{
53
59
InstanceId : aws .String (test .EndptId2 ),
54
60
Attributes : map [string ]string {
55
- model .Ipv4Attr : test .EndptIp2 ,
56
- model .PortAttr : test .EndptPortStr2 ,
61
+ model .EndpointIpv4Attr : test .EndptIp2 ,
62
+ model .EndpointPortAttr : test .PortStr2 ,
63
+ model .EndpointPortNameAttr : test .PortName2 ,
64
+ model .EndpointProtocolAttr : test .Protocol2 ,
65
+ model .ServicePortNameAttr : test .PortName2 ,
66
+ model .ServicePortAttr : test .ServicePortStr2 ,
67
+ model .ServiceProtocolAttr : test .Protocol2 ,
68
+ model .ServiceTargetPortAttr : test .PortStr2 ,
57
69
},
58
70
},
59
71
}, nil )
60
72
tc .mockCache .EXPECT ().CacheEndpoints (test .NsName , test .SvcName ,
61
- []* model.Endpoint {test .GetTestEndpoint (), test .GetTestEndpoint2 ()})
73
+ []* model.Endpoint {test .GetTestEndpoint1 (), test .GetTestEndpoint2 ()})
62
74
63
75
svcs , err := tc .client .ListServices (context .TODO (), test .NsName )
64
76
assert .Equal (t , []* model.Service {test .GetTestService ()}, svcs )
@@ -76,7 +88,7 @@ func TestServiceDiscoveryClient_ListServices_HappyCaseCachedResults(t *testing.T
76
88
tc .mockCache .EXPECT ().CacheServiceId (test .NsName , test .SvcName , test .SvcId )
77
89
78
90
tc .mockCache .EXPECT ().GetEndpoints (test .NsName , test .SvcName ).
79
- Return ([]* model.Endpoint {test .GetTestEndpoint (), test .GetTestEndpoint2 ()}, true )
91
+ Return ([]* model.Endpoint {test .GetTestEndpoint1 (), test .GetTestEndpoint2 ()}, true )
80
92
81
93
svcs , err := tc .client .ListServices (context .TODO (), test .NsName )
82
94
assert .Equal (t , []* model.Service {test .GetTestService ()}, svcs )
@@ -283,20 +295,32 @@ func TestServiceDiscoveryClient_GetService_HappyCase(t *testing.T) {
283
295
{
284
296
InstanceId : aws .String (test .EndptId1 ),
285
297
Attributes : map [string ]string {
286
- model .Ipv4Attr : test .EndptIp1 ,
287
- model .PortAttr : test .EndptPortStr1 ,
298
+ model .EndpointIpv4Attr : test .EndptIp1 ,
299
+ model .EndpointPortAttr : test .PortStr1 ,
300
+ model .EndpointPortNameAttr : test .PortName1 ,
301
+ model .EndpointProtocolAttr : test .Protocol1 ,
302
+ model .ServicePortNameAttr : test .PortName1 ,
303
+ model .ServicePortAttr : test .ServicePortStr1 ,
304
+ model .ServiceProtocolAttr : test .Protocol1 ,
305
+ model .ServiceTargetPortAttr : test .PortStr1 ,
288
306
},
289
307
},
290
308
{
291
309
InstanceId : aws .String (test .EndptId2 ),
292
310
Attributes : map [string ]string {
293
- model .Ipv4Attr : test .EndptIp2 ,
294
- model .PortAttr : test .EndptPortStr2 ,
311
+ model .EndpointIpv4Attr : test .EndptIp2 ,
312
+ model .EndpointPortAttr : test .PortStr2 ,
313
+ model .EndpointPortNameAttr : test .PortName2 ,
314
+ model .EndpointProtocolAttr : test .Protocol2 ,
315
+ model .ServicePortNameAttr : test .PortName2 ,
316
+ model .ServicePortAttr : test .ServicePortStr2 ,
317
+ model .ServiceProtocolAttr : test .Protocol2 ,
318
+ model .ServiceTargetPortAttr : test .PortStr2 ,
295
319
},
296
320
},
297
321
}, nil )
298
322
tc .mockCache .EXPECT ().CacheEndpoints (test .NsName , test .SvcName ,
299
- []* model.Endpoint {test .GetTestEndpoint (), test .GetTestEndpoint2 ()})
323
+ []* model.Endpoint {test .GetTestEndpoint1 (), test .GetTestEndpoint2 ()})
300
324
301
325
svc , err := tc .client .GetService (context .TODO (), test .NsName , test .SvcName )
302
326
assert .Nil (t , err )
@@ -308,7 +332,7 @@ func TestServiceDiscoveryClient_GetService_CachedValues(t *testing.T) {
308
332
defer tc .close ()
309
333
310
334
tc .mockCache .EXPECT ().GetEndpoints (test .NsName , test .SvcName ).
311
- Return ([]* model.Endpoint {test .GetTestEndpoint (), test .GetTestEndpoint2 ()}, true )
335
+ Return ([]* model.Endpoint {test .GetTestEndpoint1 (), test .GetTestEndpoint2 ()}, true )
312
336
313
337
svc , err := tc .client .GetService (context .TODO (), test .NsName , test .SvcName )
314
338
assert .Nil (t , err )
@@ -321,8 +345,26 @@ func TestServiceDiscoveryClient_RegisterEndpoints(t *testing.T) {
321
345
322
346
tc .mockCache .EXPECT ().GetServiceId (test .NsName , test .SvcName ).Return (test .SvcId , true )
323
347
324
- attrs1 := map [string ]string {"AWS_INSTANCE_IPV4" : test .EndptIp1 , "AWS_INSTANCE_PORT" : test .EndptPortStr1 }
325
- attrs2 := map [string ]string {"AWS_INSTANCE_IPV4" : test .EndptIp2 , "AWS_INSTANCE_PORT" : test .EndptPortStr2 }
348
+ attrs1 := map [string ]string {
349
+ model .EndpointIpv4Attr : test .EndptIp1 ,
350
+ model .EndpointPortAttr : test .PortStr1 ,
351
+ model .EndpointPortNameAttr : test .PortName1 ,
352
+ model .EndpointProtocolAttr : test .Protocol1 ,
353
+ model .ServicePortNameAttr : test .PortName1 ,
354
+ model .ServicePortAttr : test .ServicePortStr1 ,
355
+ model .ServiceProtocolAttr : test .Protocol1 ,
356
+ model .ServiceTargetPortAttr : test .PortStr1 ,
357
+ }
358
+ attrs2 := map [string ]string {
359
+ model .EndpointIpv4Attr : test .EndptIp2 ,
360
+ model .EndpointPortAttr : test .PortStr2 ,
361
+ model .EndpointPortNameAttr : test .PortName2 ,
362
+ model .EndpointProtocolAttr : test .Protocol2 ,
363
+ model .ServicePortNameAttr : test .PortName2 ,
364
+ model .ServicePortAttr : test .ServicePortStr2 ,
365
+ model .ServiceProtocolAttr : test .Protocol2 ,
366
+ model .ServiceTargetPortAttr : test .PortStr2 ,
367
+ }
326
368
327
369
tc .mockApi .EXPECT ().RegisterInstance (context .TODO (), test .SvcId , test .EndptId1 , attrs1 ).
328
370
Return (test .OpId1 , nil )
@@ -336,18 +378,7 @@ func TestServiceDiscoveryClient_RegisterEndpoints(t *testing.T) {
336
378
tc .mockCache .EXPECT ().EvictEndpoints (test .NsName , test .SvcName )
337
379
338
380
err := tc .client .RegisterEndpoints (context .TODO (), test .NsName , test .SvcName ,
339
- []* model.Endpoint {
340
- {
341
- Id : test .EndptId1 ,
342
- IP : test .EndptIp1 ,
343
- Port : test .EndptPort1 ,
344
- },
345
- {
346
- Id : test .EndptId2 ,
347
- IP : test .EndptIp2 ,
348
- Port : test .EndptPort2 ,
349
- },
350
- })
381
+ []* model.Endpoint {test .GetTestEndpoint1 (), test .GetTestEndpoint2 ()})
351
382
352
383
assert .Nil (t , err )
353
384
}
0 commit comments