@@ -307,6 +307,19 @@ func TestAWSSDProvider_Records(t *testing.T) {
307307 }},
308308 },
309309 },
310+ "aaaa-srv" : {
311+ Id : aws .String ("aaaa-srv" ),
312+ Name : aws .String ("service4" ),
313+ Description : aws .String ("owner-id" ),
314+ DnsConfig : & sdtypes.DnsConfig {
315+ NamespaceId : aws .String ("private" ),
316+ RoutingPolicy : sdtypes .RoutingPolicyWeighted ,
317+ DnsRecords : []sdtypes.DnsRecord {{
318+ Type : sdtypes .RecordTypeAaaa ,
319+ TTL : aws .Int64 (100 ),
320+ }},
321+ },
322+ },
310323 },
311324 }
312325
@@ -341,12 +354,21 @@ func TestAWSSDProvider_Records(t *testing.T) {
341354 },
342355 },
343356 },
357+ "aaaa-srv" : {
358+ "0000:0000:0000:0000:abcd:abcd:abcd:abcd" : {
359+ Id : aws .String ("0000:0000:0000:0000:abcd:abcd:abcd:abcd" ),
360+ Attributes : map [string ]string {
361+ sdInstanceAttrIPV6 : "0000:0000:0000:0000:abcd:abcd:abcd:abcd" ,
362+ },
363+ },
364+ },
344365 }
345366
346367 expectedEndpoints := []* endpoint.Endpoint {
347368 {DNSName : "service1.private.com" , Targets : endpoint.Targets {"1.2.3.4" , "1.2.3.5" }, RecordType : endpoint .RecordTypeA , RecordTTL : 100 , Labels : map [string ]string {endpoint .AWSSDDescriptionLabel : "owner-id" }},
348369 {DNSName : "service2.private.com" , Targets : endpoint.Targets {"load-balancer.us-east-1.elb.amazonaws.com" }, RecordType : endpoint .RecordTypeCNAME , RecordTTL : 100 , Labels : map [string ]string {endpoint .AWSSDDescriptionLabel : "owner-id" }},
349370 {DNSName : "service3.private.com" , Targets : endpoint.Targets {"cname.target.com" }, RecordType : endpoint .RecordTypeCNAME , RecordTTL : 80 , Labels : map [string ]string {endpoint .AWSSDDescriptionLabel : "owner-id" }},
371+ {DNSName : "service4.private.com" , Targets : endpoint.Targets {"0000:0000:0000:0000:abcd:abcd:abcd:abcd" }, RecordType : endpoint .RecordTypeAAAA , RecordTTL : 100 , Labels : map [string ]string {endpoint .AWSSDDescriptionLabel : "owner-id" }},
350372 }
351373
352374 api := & AWSSDClientStub {
@@ -557,6 +579,28 @@ func TestAWSSDProvider_CreateService(t *testing.T) {
557579 NamespaceId : aws .String ("private" ),
558580 }
559581
582+ // AAAA type
583+ provider .CreateService (context .Background (), aws .String ("private" ), aws .String ("AAAA-srv" ), & endpoint.Endpoint {
584+ Labels : map [string ]string {
585+ endpoint .AWSSDDescriptionLabel : "AAAA-srv" ,
586+ },
587+ RecordType : endpoint .RecordTypeAAAA ,
588+ RecordTTL : 60 ,
589+ Targets : endpoint.Targets {"::1234:5678:" },
590+ })
591+ expectedServices ["AAAA-srv" ] = & sdtypes.Service {
592+ Name : aws .String ("AAAA-srv" ),
593+ Description : aws .String ("AAAA-srv" ),
594+ DnsConfig : & sdtypes.DnsConfig {
595+ RoutingPolicy : sdtypes .RoutingPolicyMultivalue ,
596+ DnsRecords : []sdtypes.DnsRecord {{
597+ Type : sdtypes .RecordTypeAaaa ,
598+ TTL : aws .Int64 (60 ),
599+ }},
600+ },
601+ NamespaceId : aws .String ("private" ),
602+ }
603+
560604 // CNAME type
561605 provider .CreateService (context .Background (), aws .String ("private" ), aws .String ("CNAME-srv" ), & endpoint.Endpoint {
562606 Labels : map [string ]string {
@@ -768,6 +812,19 @@ func TestAWSSDProvider_RegisterInstance(t *testing.T) {
768812 }},
769813 },
770814 },
815+ "aaaa-srv" : {
816+ Id : aws .String ("aaaa-srv" ),
817+ Name : aws .String ("service4" ),
818+ Description : aws .String ("owner-id" ),
819+ DnsConfig : & sdtypes.DnsConfig {
820+ NamespaceId : aws .String ("private" ),
821+ RoutingPolicy : sdtypes .RoutingPolicyWeighted ,
822+ DnsRecords : []sdtypes.DnsRecord {{
823+ Type : sdtypes .RecordTypeAaaa ,
824+ TTL : aws .Int64 (100 ),
825+ }},
826+ },
827+ },
771828 },
772829 }
773830
@@ -781,7 +838,7 @@ func TestAWSSDProvider_RegisterInstance(t *testing.T) {
781838
782839 expectedInstances := make (map [string ]* sdtypes.Instance )
783840
784- // IP -based instance
841+ // IPv4 -based instance
785842 provider .RegisterInstance (context .Background (), services ["private" ]["a-srv" ], & endpoint.Endpoint {
786843 RecordType : endpoint .RecordTypeA ,
787844 DNSName : "service1.private.com." ,
@@ -849,6 +906,20 @@ func TestAWSSDProvider_RegisterInstance(t *testing.T) {
849906 },
850907 }
851908
909+ // IPv6-based instance
910+ provider .RegisterInstance (context .Background (), services ["private" ]["aaaa-srv" ], & endpoint.Endpoint {
911+ RecordType : endpoint .RecordTypeAAAA ,
912+ DNSName : "service4.private.com." ,
913+ RecordTTL : 300 ,
914+ Targets : endpoint.Targets {"0000:0000:0000:0000:abcd:abcd:abcd:abcd" },
915+ })
916+ expectedInstances ["0000:0000:0000:0000:abcd:abcd:abcd:abcd" ] = & sdtypes.Instance {
917+ Id : aws .String ("0000:0000:0000:0000:abcd:abcd:abcd:abcd" ),
918+ Attributes : map [string ]string {
919+ sdInstanceAttrIPV6 : "0000:0000:0000:0000:abcd:abcd:abcd:abcd" ,
920+ },
921+ }
922+
852923 // validate instances
853924 for _ , srvInst := range api .instances {
854925 for id , inst := range srvInst {
0 commit comments