@@ -282,7 +282,7 @@ test('API', t => {
282
282
} )
283
283
284
284
t . test ( 'nodesToHost' , t => {
285
- t . test ( 'publish_address as ip address' , t => {
285
+ t . test ( 'publish_address as ip address (IPv4) ' , t => {
286
286
const pool = new ConnectionPool ( { Connection } )
287
287
const nodes = {
288
288
a1 : {
@@ -324,7 +324,49 @@ test('API', t => {
324
324
t . end ( )
325
325
} )
326
326
327
- t . test ( 'publish_address as host/ip' , t => {
327
+ t . test ( 'publish_address as ip address (IPv6)' , t => {
328
+ const pool = new ConnectionPool ( { Connection } )
329
+ const nodes = {
330
+ a1 : {
331
+ http : {
332
+ publish_address : '[::1]:9200'
333
+ } ,
334
+ roles : [ 'master' , 'data' , 'ingest' ]
335
+ } ,
336
+ a2 : {
337
+ http : {
338
+ publish_address : '[::1]:9201'
339
+ } ,
340
+ roles : [ 'master' , 'data' , 'ingest' ]
341
+ }
342
+ }
343
+
344
+ t . deepEqual ( pool . nodesToHost ( nodes , 'http:' ) , [ {
345
+ url : new URL ( 'http://[::1]:9200' ) ,
346
+ id : 'a1' ,
347
+ roles : {
348
+ master : true ,
349
+ data : true ,
350
+ ingest : true ,
351
+ ml : false
352
+ }
353
+ } , {
354
+ url : new URL ( 'http://[::1]:9201' ) ,
355
+ id : 'a2' ,
356
+ roles : {
357
+ master : true ,
358
+ data : true ,
359
+ ingest : true ,
360
+ ml : false
361
+ }
362
+ } ] )
363
+
364
+ t . strictEqual ( pool . nodesToHost ( nodes , 'http:' ) [ 0 ] . url . host , '[::1]:9200' )
365
+ t . strictEqual ( pool . nodesToHost ( nodes , 'http:' ) [ 1 ] . url . host , '[::1]:9201' )
366
+ t . end ( )
367
+ } )
368
+
369
+ t . test ( 'publish_address as host/ip (IPv4)' , t => {
328
370
const pool = new ConnectionPool ( { Connection } )
329
371
const nodes = {
330
372
a1 : {
@@ -366,6 +408,48 @@ test('API', t => {
366
408
t . end ( )
367
409
} )
368
410
411
+ t . test ( 'publish_address as host/ip (IPv6)' , t => {
412
+ const pool = new ConnectionPool ( { Connection } )
413
+ const nodes = {
414
+ a1 : {
415
+ http : {
416
+ publish_address : 'example.com/[::1]:9200'
417
+ } ,
418
+ roles : [ 'master' , 'data' , 'ingest' ]
419
+ } ,
420
+ a2 : {
421
+ http : {
422
+ publish_address : 'example.com/[::1]:9201'
423
+ } ,
424
+ roles : [ 'master' , 'data' , 'ingest' ]
425
+ }
426
+ }
427
+
428
+ t . deepEqual ( pool . nodesToHost ( nodes , 'http:' ) , [ {
429
+ url : new URL ( 'http://example.com:9200' ) ,
430
+ id : 'a1' ,
431
+ roles : {
432
+ master : true ,
433
+ data : true ,
434
+ ingest : true ,
435
+ ml : false
436
+ }
437
+ } , {
438
+ url : new URL ( 'http://example.com:9201' ) ,
439
+ id : 'a2' ,
440
+ roles : {
441
+ master : true ,
442
+ data : true ,
443
+ ingest : true ,
444
+ ml : false
445
+ }
446
+ } ] )
447
+
448
+ t . strictEqual ( pool . nodesToHost ( nodes , 'http:' ) [ 0 ] . url . host , 'example.com:9200' )
449
+ t . strictEqual ( pool . nodesToHost ( nodes , 'http:' ) [ 1 ] . url . host , 'example.com:9201' )
450
+ t . end ( )
451
+ } )
452
+
369
453
t . test ( 'Should use the configure protocol' , t => {
370
454
const pool = new ConnectionPool ( { Connection } )
371
455
const nodes = {
0 commit comments