@@ -336,6 +336,59 @@ var _ = Describe("Environment test", func() {
336
336
Expect (errWrong ).To (HaveOccurred ())
337
337
})
338
338
339
+ It ("Multi Uris/Multi with some not reachable end-points " , func () {
340
+ // To connect the client is enough to have one valid endpoint
341
+ // even the other endpoints are not reachable
342
+ // https://github.com/rabbitmq/rabbitmq-stream-go-client/issues/309
343
+
344
+ env , err := NewEnvironment (NewEnvironmentOptions ().
345
+ SetUris ([]string {
346
+ "rabbitmq-stream://guest:guest@localhost:5552/%2f" ,
347
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
348
+ }))
349
+ Expect (err ).NotTo (HaveOccurred ())
350
+ Expect (env .Close ()).NotTo (HaveOccurred ())
351
+
352
+ env , err = NewEnvironment (NewEnvironmentOptions ().
353
+ SetUris ([]string {
354
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
355
+ "rabbitmq-stream://guest:guest@localhost:5552/%2f" ,
356
+ }))
357
+ Expect (err ).NotTo (HaveOccurred ())
358
+ Expect (env .Close ()).NotTo (HaveOccurred ())
359
+
360
+ env , err = NewEnvironment (NewEnvironmentOptions ().
361
+ SetUris ([]string {
362
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
363
+ "rabbitmq-stream://guest:guest@localhost:5552/%2f" ,
364
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
365
+ }))
366
+ Expect (err ).NotTo (HaveOccurred ())
367
+ Expect (env .Close ()).NotTo (HaveOccurred ())
368
+
369
+ env , err = NewEnvironment (NewEnvironmentOptions ().
370
+ SetUris ([]string {
371
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
372
+ "rabbitmq-stream://guest:guest@localhost:5552/%2f" ,
373
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
374
+ "rabbitmq-stream://guest:guest@localhost:5552/%2f" ,
375
+ }))
376
+ Expect (err ).NotTo (HaveOccurred ())
377
+ Expect (env .Close ()).NotTo (HaveOccurred ())
378
+
379
+ // in this case all the endpoints are not reachable
380
+ // so it will fail
381
+ _ , err = NewEnvironment (NewEnvironmentOptions ().
382
+ SetUris ([]string {
383
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
384
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
385
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
386
+ "rabbitmq-stream://guest:guest@wrong:5552/%2f" ,
387
+ }))
388
+ Expect (err ).To (HaveOccurred ())
389
+
390
+ })
391
+
339
392
It ("Fail TLS connection" , func () {
340
393
_ , err := NewEnvironment (NewEnvironmentOptions ().
341
394
SetTLSConfig (& tls.Config {InsecureSkipVerify : true }).
0 commit comments