elasticsearch-transport 7.9.0.pre → 7.11.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +20 -9
- data/lib/elasticsearch/transport/client.rb +143 -49
- data/lib/elasticsearch/transport/transport/connections/connection.rb +4 -3
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/spec/elasticsearch/transport/base_spec.rb +44 -28
- data/spec/elasticsearch/transport/client_spec.rb +373 -103
- data/spec/elasticsearch/transport/meta_header_spec.rb +203 -0
- data/test/unit/connection_test.rb +5 -0
- data/test/unit/transport_manticore_test.rb +11 -11
- metadata +5 -3
@@ -246,7 +246,7 @@ describe Elasticsearch::Transport::Client do
|
|
246
246
|
end
|
247
247
|
|
248
248
|
let(:client) do
|
249
|
-
described_class.new(adapter: :patron)
|
249
|
+
described_class.new(adapter: :patron, enable_meta_header: false)
|
250
250
|
end
|
251
251
|
|
252
252
|
it 'uses Faraday with the adapter' do
|
@@ -260,7 +260,7 @@ describe Elasticsearch::Transport::Client do
|
|
260
260
|
end
|
261
261
|
|
262
262
|
let(:client) do
|
263
|
-
described_class.new(adapter: :typhoeus)
|
263
|
+
described_class.new(adapter: :typhoeus, enable_meta_header: false)
|
264
264
|
end
|
265
265
|
|
266
266
|
it 'uses Faraday with the adapter' do
|
@@ -274,7 +274,7 @@ describe Elasticsearch::Transport::Client do
|
|
274
274
|
end
|
275
275
|
|
276
276
|
let(:client) do
|
277
|
-
described_class.new(
|
277
|
+
described_class.new(adapter: :patron, enable_meta_header: false)
|
278
278
|
end
|
279
279
|
|
280
280
|
it 'uses Faraday with the adapter' do
|
@@ -328,7 +328,11 @@ describe Elasticsearch::Transport::Client do
|
|
328
328
|
context 'when cloud credentials are provided' do
|
329
329
|
|
330
330
|
let(:client) do
|
331
|
-
described_class.new(
|
331
|
+
described_class.new(
|
332
|
+
cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
|
333
|
+
user: 'elastic',
|
334
|
+
password: 'changeme'
|
335
|
+
)
|
332
336
|
end
|
333
337
|
|
334
338
|
let(:hosts) do
|
@@ -340,17 +344,19 @@ describe Elasticsearch::Transport::Client do
|
|
340
344
|
expect(hosts[0][:protocol]).to eq('https')
|
341
345
|
expect(hosts[0][:user]).to eq('elastic')
|
342
346
|
expect(hosts[0][:password]).to eq('changeme')
|
343
|
-
expect(hosts[0][:port]).to eq(
|
347
|
+
expect(hosts[0][:port]).to eq(443)
|
344
348
|
end
|
345
349
|
|
346
350
|
it 'creates the correct full url' do
|
347
|
-
expect(
|
351
|
+
expect(
|
352
|
+
client.transport.__full_url(client.transport.hosts[0])
|
353
|
+
).to eq('https://elastic:changeme@abcd.localhost:443')
|
348
354
|
end
|
349
355
|
|
350
356
|
context 'when a port is specified' do
|
351
357
|
|
352
358
|
let(:client) do
|
353
|
-
described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme', port:
|
359
|
+
described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme', port: 9250)
|
354
360
|
end
|
355
361
|
|
356
362
|
it 'sets the specified port along with the cloud credentials' do
|
@@ -358,18 +364,22 @@ describe Elasticsearch::Transport::Client do
|
|
358
364
|
expect(hosts[0][:protocol]).to eq('https')
|
359
365
|
expect(hosts[0][:user]).to eq('elastic')
|
360
366
|
expect(hosts[0][:password]).to eq('changeme')
|
361
|
-
expect(hosts[0][:port]).to eq(
|
367
|
+
expect(hosts[0][:port]).to eq(9250)
|
362
368
|
end
|
363
369
|
|
364
370
|
it 'creates the correct full url' do
|
365
|
-
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elastic:changeme@abcd.localhost:
|
371
|
+
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elastic:changeme@abcd.localhost:9250')
|
366
372
|
end
|
367
373
|
end
|
368
374
|
|
369
375
|
context 'when the cluster has alternate names' do
|
370
376
|
|
371
377
|
let(:client) do
|
372
|
-
described_class.new(
|
378
|
+
described_class.new(
|
379
|
+
cloud_id: 'myCluster:bG9jYWxob3N0JGFiY2QkZWZnaA==',
|
380
|
+
user: 'elasticfantastic',
|
381
|
+
password: 'tobechanged'
|
382
|
+
)
|
373
383
|
end
|
374
384
|
|
375
385
|
let(:hosts) do
|
@@ -381,124 +391,334 @@ describe Elasticsearch::Transport::Client do
|
|
381
391
|
expect(hosts[0][:protocol]).to eq('https')
|
382
392
|
expect(hosts[0][:user]).to eq('elasticfantastic')
|
383
393
|
expect(hosts[0][:password]).to eq('tobechanged')
|
384
|
-
expect(hosts[0][:port]).to eq(
|
394
|
+
expect(hosts[0][:port]).to eq(443)
|
385
395
|
end
|
386
396
|
|
387
397
|
it 'creates the correct full url' do
|
388
|
-
expect(
|
398
|
+
expect(
|
399
|
+
client.transport.__full_url(client.transport.hosts[0])
|
400
|
+
).to eq('https://elasticfantastic:tobechanged@abcd.localhost:443')
|
389
401
|
end
|
390
|
-
|
391
402
|
end
|
392
|
-
end
|
393
403
|
|
394
|
-
|
404
|
+
context 'when decoded cloud id has a trailing dollar sign' do
|
405
|
+
let(:client) do
|
406
|
+
described_class.new(
|
407
|
+
cloud_id: 'a_cluster:bG9jYWxob3N0JGFiY2Qk',
|
408
|
+
user: 'elasticfantastic',
|
409
|
+
password: 'changeme'
|
410
|
+
)
|
411
|
+
end
|
395
412
|
|
396
|
-
|
413
|
+
let(:hosts) do
|
414
|
+
client.transport.hosts
|
415
|
+
end
|
397
416
|
|
398
|
-
|
399
|
-
'
|
417
|
+
it 'extracts the cloud credentials' do
|
418
|
+
expect(hosts[0][:host]).to eq('abcd.localhost')
|
419
|
+
expect(hosts[0][:protocol]).to eq('https')
|
420
|
+
expect(hosts[0][:user]).to eq('elasticfantastic')
|
421
|
+
expect(hosts[0][:password]).to eq('changeme')
|
422
|
+
expect(hosts[0][:port]).to eq(443)
|
400
423
|
end
|
401
424
|
|
402
|
-
it '
|
403
|
-
expect(
|
404
|
-
|
405
|
-
|
425
|
+
it 'creates the correct full url' do
|
426
|
+
expect(
|
427
|
+
client.transport.__full_url(client.transport.hosts[0])
|
428
|
+
).to eq('https://elasticfantastic:changeme@abcd.localhost:443')
|
406
429
|
end
|
430
|
+
end
|
407
431
|
|
408
|
-
|
432
|
+
context 'when the cloud host provides a port' do
|
433
|
+
let(:client) do
|
434
|
+
described_class.new(
|
435
|
+
cloud_id: 'name:ZWxhc3RpY19zZXJ2ZXI6OTI0MyRlbGFzdGljX2lk',
|
436
|
+
user: 'elastic',
|
437
|
+
password: 'changeme'
|
438
|
+
)
|
439
|
+
end
|
409
440
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
example.run
|
414
|
-
Faraday.ignore_env_proxy = original_setting
|
415
|
-
end
|
441
|
+
let(:hosts) do
|
442
|
+
client.transport.hosts
|
443
|
+
end
|
416
444
|
|
417
|
-
|
418
|
-
|
419
|
-
|
445
|
+
it 'creates the correct full url' do
|
446
|
+
expect(hosts[0][:host]).to eq('elastic_id.elastic_server')
|
447
|
+
expect(hosts[0][:protocol]).to eq('https')
|
448
|
+
expect(hosts[0][:user]).to eq('elastic')
|
449
|
+
expect(hosts[0][:password]).to eq('changeme')
|
450
|
+
expect(hosts[0][:port]).to eq(9243)
|
451
|
+
end
|
452
|
+
end
|
420
453
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
454
|
+
context 'when the cloud host provides a port and the port is also specified' do
|
455
|
+
let(:client) do
|
456
|
+
described_class.new(
|
457
|
+
cloud_id: 'name:ZWxhc3RpY19zZXJ2ZXI6OTI0MyRlbGFzdGljX2lk',
|
458
|
+
user: 'elastic',
|
459
|
+
password: 'changeme',
|
460
|
+
port: 9200
|
461
|
+
)
|
462
|
+
end
|
426
463
|
|
427
|
-
|
428
|
-
|
429
|
-
end
|
464
|
+
let(:hosts) do
|
465
|
+
client.transport.hosts
|
430
466
|
end
|
431
467
|
|
432
|
-
|
468
|
+
it 'creates the correct full url' do
|
469
|
+
expect(hosts[0][:host]).to eq('elastic_id.elastic_server')
|
470
|
+
expect(hosts[0][:protocol]).to eq('https')
|
471
|
+
expect(hosts[0][:user]).to eq('elastic')
|
472
|
+
expect(hosts[0][:password]).to eq('changeme')
|
473
|
+
expect(hosts[0][:port]).to eq(9243)
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
433
477
|
|
434
|
-
|
435
|
-
'https://myhost:8080/api'
|
436
|
-
end
|
478
|
+
shared_examples_for 'a client that extracts hosts' do
|
437
479
|
|
438
|
-
|
439
|
-
expect(hosts[0][:host]).to eq('myhost')
|
440
|
-
expect(hosts[0][:scheme]).to eq('https')
|
441
|
-
expect(hosts[0][:path]).to eq('/api')
|
442
|
-
expect(hosts[0][:port]).to be(8080)
|
443
|
-
end
|
444
|
-
end
|
480
|
+
context 'when the host is a String' do
|
445
481
|
|
446
|
-
context 'when a
|
482
|
+
context 'when there is a protocol specified' do
|
447
483
|
|
448
|
-
|
449
|
-
'https://myhost:8080'
|
450
|
-
end
|
484
|
+
context 'when credentials are specified \'http://USERNAME:PASSWORD@myhost:8080\'' do
|
451
485
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
486
|
+
let(:host) do
|
487
|
+
'http://USERNAME:PASSWORD@myhost:8080'
|
488
|
+
end
|
489
|
+
|
490
|
+
it 'extracts the credentials' do
|
491
|
+
expect(hosts[0][:user]).to eq('USERNAME')
|
492
|
+
expect(hosts[0][:password]).to eq('PASSWORD')
|
493
|
+
end
|
494
|
+
|
495
|
+
it 'extracts the host' do
|
496
|
+
expect(hosts[0][:host]).to eq('myhost')
|
497
|
+
end
|
498
|
+
|
499
|
+
it 'extracts the port' do
|
500
|
+
expect(hosts[0][:port]).to be(8080)
|
501
|
+
end
|
456
502
|
end
|
457
|
-
end
|
458
503
|
|
459
|
-
|
504
|
+
context 'when there is a trailing slash \'http://myhost/\'' do
|
460
505
|
|
461
|
-
|
462
|
-
|
506
|
+
let(:host) do
|
507
|
+
'http://myhost/'
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'extracts the host' do
|
511
|
+
expect(hosts[0][:host]).to eq('myhost')
|
512
|
+
expect(hosts[0][:scheme]).to eq('http')
|
513
|
+
expect(hosts[0][:path]).to eq('')
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'extracts the scheme' do
|
517
|
+
expect(hosts[0][:scheme]).to eq('http')
|
518
|
+
end
|
519
|
+
|
520
|
+
it 'extracts the path' do
|
521
|
+
expect(hosts[0][:path]).to eq('')
|
522
|
+
end
|
463
523
|
end
|
464
524
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
525
|
+
context 'when there is a trailing slash with a path \'http://myhost/foo/bar/\'' do
|
526
|
+
|
527
|
+
let(:host) do
|
528
|
+
'http://myhost/foo/bar/'
|
529
|
+
end
|
530
|
+
|
531
|
+
it 'extracts the host' do
|
532
|
+
expect(hosts[0][:host]).to eq('myhost')
|
533
|
+
expect(hosts[0][:scheme]).to eq('http')
|
534
|
+
expect(hosts[0][:path]).to eq('/foo/bar')
|
535
|
+
end
|
471
536
|
end
|
472
|
-
end
|
473
537
|
|
474
|
-
|
538
|
+
context 'when the protocol is http' do
|
475
539
|
|
476
|
-
|
477
|
-
|
540
|
+
context 'when there is no port specified \'http://myhost\'' do
|
541
|
+
|
542
|
+
let(:host) do
|
543
|
+
'http://myhost'
|
544
|
+
end
|
545
|
+
|
546
|
+
it 'extracts the host' do
|
547
|
+
expect(hosts[0][:host]).to eq('myhost')
|
548
|
+
end
|
549
|
+
|
550
|
+
it 'extracts the protocol' do
|
551
|
+
expect(hosts[0][:protocol]).to eq('http')
|
552
|
+
end
|
553
|
+
|
554
|
+
it 'defaults to port 9200' do
|
555
|
+
expect(hosts[0][:port]).to be(9200)
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
context 'when there is a port specified \'http://myhost:7101\'' do
|
560
|
+
|
561
|
+
let(:host) do
|
562
|
+
'http://myhost:7101'
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'extracts the host' do
|
566
|
+
expect(hosts[0][:host]).to eq('myhost')
|
567
|
+
end
|
568
|
+
|
569
|
+
it 'extracts the protocol' do
|
570
|
+
expect(hosts[0][:protocol]).to eq('http')
|
571
|
+
end
|
572
|
+
|
573
|
+
it 'extracts the port' do
|
574
|
+
expect(hosts[0][:port]).to be(7101)
|
575
|
+
end
|
576
|
+
|
577
|
+
context 'when there is a path specified \'http://myhost:7101/api\'' do
|
578
|
+
|
579
|
+
let(:host) do
|
580
|
+
'http://myhost:7101/api'
|
581
|
+
end
|
582
|
+
|
583
|
+
it 'sets the path' do
|
584
|
+
expect(hosts[0][:host]).to eq('myhost')
|
585
|
+
expect(hosts[0][:protocol]).to eq('http')
|
586
|
+
expect(hosts[0][:path]).to eq('/api')
|
587
|
+
expect(hosts[0][:port]).to be(7101)
|
588
|
+
end
|
589
|
+
|
590
|
+
it 'extracts the host' do
|
591
|
+
expect(hosts[0][:host]).to eq('myhost')
|
592
|
+
end
|
593
|
+
|
594
|
+
it 'extracts the protocol' do
|
595
|
+
expect(hosts[0][:protocol]).to eq('http')
|
596
|
+
end
|
597
|
+
|
598
|
+
it 'extracts the port' do
|
599
|
+
expect(hosts[0][:port]).to be(7101)
|
600
|
+
end
|
601
|
+
|
602
|
+
it 'extracts the path' do
|
603
|
+
expect(hosts[0][:path]).to eq('/api')
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|
478
607
|
end
|
479
608
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
609
|
+
context 'when the protocol is https' do
|
610
|
+
|
611
|
+
context 'when there is no port specified \'https://myhost\'' do
|
612
|
+
|
613
|
+
let(:host) do
|
614
|
+
'https://myhost'
|
615
|
+
end
|
616
|
+
|
617
|
+
it 'extracts the host' do
|
618
|
+
expect(hosts[0][:host]).to eq('myhost')
|
619
|
+
end
|
620
|
+
|
621
|
+
it 'extracts the protocol' do
|
622
|
+
expect(hosts[0][:protocol]).to eq('https')
|
623
|
+
end
|
624
|
+
|
625
|
+
it 'defaults to port 443' do
|
626
|
+
expect(hosts[0][:port]).to be(443)
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
context 'when there is a port specified \'https://myhost:7101\'' do
|
631
|
+
|
632
|
+
let(:host) do
|
633
|
+
'https://myhost:7101'
|
634
|
+
end
|
635
|
+
|
636
|
+
it 'extracts the host' do
|
637
|
+
expect(hosts[0][:host]).to eq('myhost')
|
638
|
+
end
|
639
|
+
|
640
|
+
it 'extracts the protocol' do
|
641
|
+
expect(hosts[0][:protocol]).to eq('https')
|
642
|
+
end
|
643
|
+
|
644
|
+
it 'extracts the port' do
|
645
|
+
expect(hosts[0][:port]).to be(7101)
|
646
|
+
end
|
647
|
+
|
648
|
+
context 'when there is a path specified \'https://myhost:7101/api\'' do
|
649
|
+
|
650
|
+
let(:host) do
|
651
|
+
'https://myhost:7101/api'
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'extracts the host' do
|
655
|
+
expect(hosts[0][:host]).to eq('myhost')
|
656
|
+
end
|
657
|
+
|
658
|
+
it 'extracts the protocol' do
|
659
|
+
expect(hosts[0][:protocol]).to eq('https')
|
660
|
+
end
|
661
|
+
|
662
|
+
it 'extracts the port' do
|
663
|
+
expect(hosts[0][:port]).to be(7101)
|
664
|
+
end
|
665
|
+
|
666
|
+
it 'extracts the path' do
|
667
|
+
expect(hosts[0][:path]).to eq('/api')
|
668
|
+
end
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
context 'when IPv6 format is used' do
|
673
|
+
|
674
|
+
around do |example|
|
675
|
+
original_setting = Faraday.ignore_env_proxy
|
676
|
+
Faraday.ignore_env_proxy = true
|
677
|
+
example.run
|
678
|
+
Faraday.ignore_env_proxy = original_setting
|
679
|
+
end
|
680
|
+
|
681
|
+
let(:host) do
|
682
|
+
'https://[2090:db8:85a3:9811::1f]:8080'
|
683
|
+
end
|
684
|
+
|
685
|
+
it 'extracts the host' do
|
686
|
+
expect(hosts[0][:host]).to eq('[2090:db8:85a3:9811::1f]')
|
687
|
+
end
|
688
|
+
|
689
|
+
it 'extracts the protocol' do
|
690
|
+
expect(hosts[0][:protocol]).to eq('https')
|
691
|
+
end
|
692
|
+
|
693
|
+
it 'extracts the port' do
|
694
|
+
expect(hosts[0][:port]).to be(8080)
|
695
|
+
end
|
696
|
+
|
697
|
+
it 'creates the correct full url' do
|
698
|
+
expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://[2090:db8:85a3:9811::1f]:8080')
|
699
|
+
end
|
700
|
+
end
|
484
701
|
end
|
485
702
|
end
|
486
703
|
|
487
|
-
context 'when
|
704
|
+
context 'when no protocol is specified \'myhost\'' do
|
488
705
|
|
489
706
|
let(:host) do
|
490
|
-
'
|
707
|
+
'myhost'
|
491
708
|
end
|
492
709
|
|
493
|
-
it '
|
710
|
+
it 'defaults to http' do
|
494
711
|
expect(hosts[0][:host]).to eq('myhost')
|
495
|
-
expect(hosts[0][:
|
496
|
-
|
712
|
+
expect(hosts[0][:protocol]).to eq('http')
|
713
|
+
end
|
714
|
+
|
715
|
+
it 'uses port 9200' do
|
716
|
+
expect(hosts[0][:port]).to be(9200)
|
497
717
|
end
|
498
718
|
end
|
499
719
|
end
|
500
720
|
|
501
|
-
context 'when the
|
721
|
+
context 'when the host is a Hash' do
|
502
722
|
|
503
723
|
let(:host) do
|
504
724
|
{ :host => 'myhost', :scheme => 'https' }
|
@@ -506,7 +726,13 @@ describe Elasticsearch::Transport::Client do
|
|
506
726
|
|
507
727
|
it 'extracts the host' do
|
508
728
|
expect(hosts[0][:host]).to eq('myhost')
|
509
|
-
|
729
|
+
end
|
730
|
+
|
731
|
+
it 'extracts the protocol' do
|
732
|
+
expect(hosts[0][:protocol]).to eq('https')
|
733
|
+
end
|
734
|
+
|
735
|
+
it 'extracts the port' do
|
510
736
|
expect(hosts[0][:port]).to be(9200)
|
511
737
|
end
|
512
738
|
|
@@ -565,7 +791,13 @@ describe Elasticsearch::Transport::Client do
|
|
565
791
|
|
566
792
|
it 'extracts the host' do
|
567
793
|
expect(hosts[0][:host]).to eq('myhost')
|
794
|
+
end
|
795
|
+
|
796
|
+
it 'extracts the protocol' do
|
568
797
|
expect(hosts[0][:scheme]).to eq('https')
|
798
|
+
end
|
799
|
+
|
800
|
+
it 'converts the port to an integer' do
|
569
801
|
expect(hosts[0][:port]).to be(443)
|
570
802
|
end
|
571
803
|
end
|
@@ -578,7 +810,13 @@ describe Elasticsearch::Transport::Client do
|
|
578
810
|
|
579
811
|
it 'extracts the host' do
|
580
812
|
expect(hosts[0][:host]).to eq('myhost')
|
813
|
+
end
|
814
|
+
|
815
|
+
it 'extracts the protocol' do
|
581
816
|
expect(hosts[0][:scheme]).to eq('https')
|
817
|
+
end
|
818
|
+
|
819
|
+
it 'extracts port as an integer' do
|
582
820
|
expect(hosts[0][:port]).to be(443)
|
583
821
|
end
|
584
822
|
end
|
@@ -592,7 +830,13 @@ describe Elasticsearch::Transport::Client do
|
|
592
830
|
|
593
831
|
it 'extracts the host' do
|
594
832
|
expect(hosts[0][:host]).to eq('myhost')
|
833
|
+
end
|
834
|
+
|
835
|
+
it 'extracts the protocol' do
|
595
836
|
expect(hosts[0][:scheme]).to eq('https')
|
837
|
+
end
|
838
|
+
|
839
|
+
it 'converts the port to an integer' do
|
596
840
|
expect(hosts[0][:port]).to be(9200)
|
597
841
|
end
|
598
842
|
|
@@ -604,7 +848,13 @@ describe Elasticsearch::Transport::Client do
|
|
604
848
|
|
605
849
|
it 'extracts the host' do
|
606
850
|
expect(hosts[0][:host]).to eq('myhost')
|
851
|
+
end
|
852
|
+
|
853
|
+
it 'extracts the protocol' do
|
607
854
|
expect(hosts[0][:scheme]).to eq('https')
|
855
|
+
end
|
856
|
+
|
857
|
+
it 'converts the port to an integer' do
|
608
858
|
expect(hosts[0][:port]).to be(443)
|
609
859
|
end
|
610
860
|
end
|
@@ -617,7 +867,13 @@ describe Elasticsearch::Transport::Client do
|
|
617
867
|
|
618
868
|
it 'extracts the host' do
|
619
869
|
expect(hosts[0][:host]).to eq('myhost')
|
870
|
+
end
|
871
|
+
|
872
|
+
it 'extracts the protocol' do
|
620
873
|
expect(hosts[0][:scheme]).to eq('https')
|
874
|
+
end
|
875
|
+
|
876
|
+
it 'extracts port as an integer' do
|
621
877
|
expect(hosts[0][:port]).to be(443)
|
622
878
|
end
|
623
879
|
end
|
@@ -633,7 +889,13 @@ describe Elasticsearch::Transport::Client do
|
|
633
889
|
|
634
890
|
it 'extracts the host' do
|
635
891
|
expect(hosts[0][:host]).to eq('myhost')
|
892
|
+
end
|
893
|
+
|
894
|
+
it 'extracts the protocol' do
|
636
895
|
expect(hosts[0][:protocol]).to eq('http')
|
896
|
+
end
|
897
|
+
|
898
|
+
it 'defaults to port 9200' do
|
637
899
|
expect(hosts[0][:port]).to be(9200)
|
638
900
|
end
|
639
901
|
end
|
@@ -646,20 +908,13 @@ describe Elasticsearch::Transport::Client do
|
|
646
908
|
|
647
909
|
it 'extracts the host' do
|
648
910
|
expect(hosts[0][:host]).to eq('myhost')
|
649
|
-
expect(hosts[0][:protocol]).to eq('http')
|
650
|
-
expect(hosts[0][:port]).to be(9200)
|
651
911
|
end
|
652
|
-
end
|
653
|
-
|
654
|
-
context 'when there is one host with a protocol and no port' do
|
655
912
|
|
656
|
-
|
657
|
-
['http
|
913
|
+
it 'extracts the protocol' do
|
914
|
+
expect(hosts[0][:scheme]).to eq('http')
|
658
915
|
end
|
659
916
|
|
660
|
-
it '
|
661
|
-
expect(hosts[0][:host]).to eq('myhost')
|
662
|
-
expect(hosts[0][:protocol]).to eq('http')
|
917
|
+
it 'defaults to port 9200' do
|
663
918
|
expect(hosts[0][:port]).to be(9200)
|
664
919
|
end
|
665
920
|
end
|
@@ -684,7 +939,7 @@ describe Elasticsearch::Transport::Client do
|
|
684
939
|
end
|
685
940
|
end
|
686
941
|
|
687
|
-
context 'when there is one host with a
|
942
|
+
context 'when there is one host with a protocol and no port' do
|
688
943
|
|
689
944
|
let(:host) do
|
690
945
|
['https://myhost']
|
@@ -692,12 +947,18 @@ describe Elasticsearch::Transport::Client do
|
|
692
947
|
|
693
948
|
it 'extracts the host' do
|
694
949
|
expect(hosts[0][:host]).to eq('myhost')
|
695
|
-
|
696
|
-
|
950
|
+
end
|
951
|
+
|
952
|
+
it 'extracts the protocol' do
|
953
|
+
expect(hosts[0][:scheme]).to eq('https')
|
954
|
+
end
|
955
|
+
|
956
|
+
it 'defaults to port 443' do
|
957
|
+
expect(hosts[0][:port]).to be(443)
|
697
958
|
end
|
698
959
|
end
|
699
960
|
|
700
|
-
context 'when there is one host with a
|
961
|
+
context 'when there is one host with a protocol, path, and no port' do
|
701
962
|
|
702
963
|
let(:host) do
|
703
964
|
['http://myhost/foo/bar']
|
@@ -705,9 +966,18 @@ describe Elasticsearch::Transport::Client do
|
|
705
966
|
|
706
967
|
it 'extracts the host' do
|
707
968
|
expect(hosts[0][:host]).to eq('myhost')
|
708
|
-
|
969
|
+
end
|
970
|
+
|
971
|
+
it 'extracts the protocol' do
|
972
|
+
expect(hosts[0][:scheme]).to eq('http')
|
973
|
+
end
|
974
|
+
|
975
|
+
it 'defaults to port 9200' do
|
709
976
|
expect(hosts[0][:port]).to be(9200)
|
710
|
-
|
977
|
+
end
|
978
|
+
|
979
|
+
it 'extracts the path' do
|
980
|
+
expect(hosts[0][:path]).to eq('/foo/bar')
|
711
981
|
end
|
712
982
|
end
|
713
983
|
|
@@ -717,7 +987,7 @@ describe Elasticsearch::Transport::Client do
|
|
717
987
|
['host1', 'host2']
|
718
988
|
end
|
719
989
|
|
720
|
-
it 'extracts the
|
990
|
+
it 'extracts the hosts' do
|
721
991
|
expect(hosts[0][:host]).to eq('host1')
|
722
992
|
expect(hosts[0][:protocol]).to eq('http')
|
723
993
|
expect(hosts[0][:port]).to be(9200)
|
@@ -733,7 +1003,7 @@ describe Elasticsearch::Transport::Client do
|
|
733
1003
|
['host1:1000', 'host2:2000']
|
734
1004
|
end
|
735
1005
|
|
736
|
-
it 'extracts the
|
1006
|
+
it 'extracts the hosts' do
|
737
1007
|
expect(hosts[0][:host]).to eq('host1')
|
738
1008
|
expect(hosts[0][:protocol]).to eq('http')
|
739
1009
|
expect(hosts[0][:port]).to be(1000)
|
@@ -1414,7 +1684,7 @@ describe Elasticsearch::Transport::Client do
|
|
1414
1684
|
context 'when using the HTTPClient adapter' do
|
1415
1685
|
|
1416
1686
|
let(:client) do
|
1417
|
-
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :httpclient)
|
1687
|
+
described_class.new(hosts: ELASTICSEARCH_HOSTS, compression: true, adapter: :httpclient, enable_meta_header: false)
|
1418
1688
|
end
|
1419
1689
|
|
1420
1690
|
it 'compresses the request and decompresses the response' do
|