@@ -219,7 +219,12 @@ func SubTestWithFallback(_ *TestDiscoveryDI) test.GomegaSubTestFunc {
219219 opt .FallbackHostMappings = []dnssd.HostMapping {
220220 {
221221 ServiceRegex : regexp .MustCompilePOSIX (ServiceName2 ),
222- Hosts : []string {"inst-1.{{.ServiceName}}.test.mock:9999" , "inst-2.{{.ServiceName}}.test.mock:8888" },
222+ Hosts : []string {
223+ "inst-1.{{.ServiceName}}.test.mock:9999" ,
224+ "inst-2.{{.ServiceName}}.test.mock" ,
225+ "http://inst-3.{{.ServiceName}}.test.mock:9999" ,
226+ "https://inst-4.{{.ServiceName}}.test.mock" ,
227+ },
223228 },
224229 {
225230 ServiceRegex : regexp .MustCompilePOSIX (`.+` ),
@@ -236,23 +241,41 @@ func SubTestWithFallback(_ *TestDiscoveryDI) test.GomegaSubTestFunc {
236241 // via service
237242 svc := instancer .Service ()
238243 g .Expect (svc ).ToNot (BeNil (), "instancer should return non-nil service" )
239- g .Expect (svc .Insts ).To (HaveLen (2 ), "instancer should return services with fallback instances" )
244+ g .Expect (svc .Insts ).To (HaveLen (4 ), "instancer should return services with fallback instances" )
240245
241246 // without additional selector
242247 TryInstancerWithMatcher (g , instancer , nil , []* MockedService {
243248 {
244- AlternativeID : "inst-1." + ServiceName2 + ".test.mock:9999" ,
249+ AlternativeID : "inst-1." + ServiceName2 + ".test.mock:9999" ,
245250 AlternativeAddr : "inst-1." + ServiceName2 + ".test.mock" ,
246- Name : ServiceName2 ,
247- Port : 9999 ,
248- Healthy : true ,
251+ Name : ServiceName2 ,
252+ Port : 9999 ,
253+ Healthy : true ,
249254 },
250255 {
251- AlternativeID : "inst-2." + ServiceName2 + ".test.mock:8888 " ,
256+ AlternativeID : "inst-2." + ServiceName2 + ".test.mock" ,
252257 AlternativeAddr : "inst-2." + ServiceName2 + ".test.mock" ,
253- Name : ServiceName2 ,
254- Port : 8888 ,
255- Healthy : true ,
258+ Name : ServiceName2 ,
259+ Port : 0 ,
260+ Healthy : true ,
261+ },
262+ {
263+ AlternativeID : "http://inst-3." + ServiceName2 + ".test.mock:9999" ,
264+ AlternativeAddr : "inst-3." + ServiceName2 + ".test.mock" ,
265+ Name : ServiceName2 ,
266+ Port : 9999 ,
267+ Healthy : true ,
268+ AlternativeTags : []string {"insecure=true" , "secure=false" },
269+ AlternativeMeta : map [string ]string {"scheme" : "http" },
270+ },
271+ {
272+ AlternativeID : "https://inst-4." + ServiceName2 + ".test.mock" ,
273+ AlternativeAddr : "inst-4." + ServiceName2 + ".test.mock" ,
274+ Name : ServiceName2 ,
275+ Port : 0 ,
276+ Healthy : true ,
277+ AlternativeTags : []string {"insecure=false" , "secure=true" },
278+ AlternativeMeta : map [string ]string {"scheme" : "https" },
256279 },
257280 })
258281 //with additional selector
@@ -271,11 +294,11 @@ func SubTestWithFallback(_ *TestDiscoveryDI) test.GomegaSubTestFunc {
271294 // without additional selector
272295 TryInstancerWithMatcher (g , instancer , nil , []* MockedService {
273296 {
274- AlternativeID : "unknown-service.test.mock:0 " ,
297+ AlternativeID : "unknown-service.test.mock" ,
275298 AlternativeAddr : "unknown-service.test.mock" ,
276- Name : "unknown-service" ,
277- Port : 0 ,
278- Healthy : true ,
299+ Name : "unknown-service" ,
300+ Port : 0 ,
301+ Healthy : true ,
279302 },
280303 })
281304 //with additional selector
@@ -332,7 +355,9 @@ type MockedService struct {
332355 Name string
333356 Port int
334357 Tags []string
358+ AlternativeTags []string // only used for assertion
335359 Meta map [string ]string
360+ AlternativeMeta map [string ]string // only used for assertion
336361 Healthy bool
337362}
338363
@@ -372,6 +397,12 @@ func TryInstancerWithMatcher(g *gomega.WithT, instancer discovery.Instancer, mat
372397 g .Expect (inst .Service ).To (Equal (svc .Name ), "instance with ID [%s] should have correct %s" , expectedID , "Service" )
373398 g .Expect (inst .Address ).To (Equal (expectedAddr ), "instance with ID [%s] should have correct %s" , expectedID , "Address" )
374399 g .Expect (inst .Port ).To (Equal (svc .Port ), "instance with ID [%s] should have correct %s" , expectedID , "Port" )
400+ if len (svc .AlternativeTags ) > 0 {
401+ g .Expect (inst .Tags ).To (Equal (svc .AlternativeTags ), "instance with ID [%s] should have correct %s" , expectedID , "Tags" )
402+ }
403+ if len (svc .AlternativeMeta ) > 0 {
404+ g .Expect (inst .Meta ).To (Equal (svc .AlternativeMeta ), "instance with ID [%s] should have correct %s" , expectedID , "Meta" )
405+ }
375406 found = true
376407 }
377408 g .Expect (found ).To (BeTrue (), "instance with ID [%s] should exists" , expectedID )
0 commit comments