Skip to content

Commit b630188

Browse files
p-mongop
authored andcommitted
Create client without monitoring to avoid warnings when network is flaky in CI (#1280)
1 parent 6d0ec6a commit b630188

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

spec/mongo/uri/srv_protocol_spec.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
ClientRegistry.instance.close_all_clients
1313
end
1414

15+
let(:client) do
16+
new_local_client(string, monitoring_io: false)
17+
end
18+
1519
describe 'invalid uris' do
1620

1721
context 'when there is more than one hostname' do
@@ -353,7 +357,7 @@
353357
end
354358

355359
it 'sets the options on a client created with the uri' do
356-
expect(new_local_client(string).options[:write]).to eq(concern)
360+
expect(client.options[:write]).to eq(concern)
357361
end
358362
end
359363

@@ -366,7 +370,7 @@
366370
end
367371

368372
it 'sets the options on a client created with the uri' do
369-
expect(new_local_client(string).options[:write]).to eq(concern)
373+
expect(client.options[:write]).to eq(concern)
370374
end
371375
end
372376

@@ -379,7 +383,7 @@
379383
end
380384

381385
it 'sets the options on a client created with the uri' do
382-
expect(new_local_client(string).options[:write]).to eq(concern)
386+
expect(client.options[:write]).to eq(concern)
383387
end
384388
end
385389

@@ -392,7 +396,7 @@
392396
end
393397

394398
it 'sets the options on a client created with the uri' do
395-
expect(new_local_client(string).options[:write]).to eq(concern)
399+
expect(client.options[:write]).to eq(concern)
396400
end
397401
end
398402

@@ -406,7 +410,7 @@
406410
end
407411

408412
it 'sets the options on a client created with the uri' do
409-
expect(new_local_client(string).options[:write]).to eq(concern)
413+
expect(client.options[:write]).to eq(concern)
410414
end
411415
end
412416
end
@@ -423,7 +427,7 @@
423427
end
424428

425429
it 'sets the options on a client created with the uri' do
426-
expect(new_local_client(string).options[:read]).to eq(read)
430+
expect(client.options[:read]).to eq(read)
427431
end
428432
end
429433

@@ -436,7 +440,7 @@
436440
end
437441

438442
it 'sets the options on a client created with the uri' do
439-
expect(new_local_client(string).options[:read]).to eq(read)
443+
expect(client.options[:read]).to eq(read)
440444
end
441445
end
442446

@@ -449,7 +453,7 @@
449453
end
450454

451455
it 'sets the options on a client created with the uri' do
452-
expect(new_local_client(string).options[:read]).to eq(read)
456+
expect(client.options[:read]).to eq(read)
453457
end
454458
end
455459

@@ -462,7 +466,7 @@
462466
end
463467

464468
it 'sets the options on a client created with the uri' do
465-
expect(new_local_client(string).options[:read]).to eq(read)
469+
expect(client.options[:read]).to eq(read)
466470
end
467471
end
468472

@@ -475,7 +479,7 @@
475479
end
476480

477481
it 'sets the options on a client created with the uri' do
478-
expect(new_local_client(string).options[:read]).to eq(read)
482+
expect(client.options[:read]).to eq(read)
479483
end
480484
end
481485
end
@@ -496,7 +500,7 @@
496500
end
497501

498502
it 'sets the options on a client created with the uri' do
499-
expect(new_local_client(string).options[:read]).to eq(read)
503+
expect(client.options[:read]).to eq(read)
500504
end
501505
end
502506

@@ -514,7 +518,7 @@
514518
end
515519

516520
it 'sets the options on a client created with the uri' do
517-
expect(new_local_client(string).options[:read]).to eq(read)
521+
expect(client.options[:read]).to eq(read)
518522
end
519523
end
520524
end
@@ -534,7 +538,7 @@
534538
end
535539

536540
it 'sets the options on a client created with the uri' do
537-
expect(new_local_client(string).options[:read]).to eq(read)
541+
expect(client.options[:read]).to eq(read)
538542
end
539543

540544
context 'when the read preference and max staleness combination is invalid' do
@@ -547,7 +551,7 @@
547551

548552
it 'raises an exception when read preference is accessed on the client' do
549553
expect {
550-
new_local_client(string).server_selector
554+
client.server_selector
551555
}.to raise_exception(Mongo::Error::InvalidServerPreference)
552556
end
553557
end
@@ -559,7 +563,7 @@
559563
end
560564

561565
it 'does not raise an exception until the read preference is used' do
562-
expect(new_local_client(string).read_preference).to eq(BSON::Document.new(mode: :secondary, max_staleness: 89))
566+
expect(client.read_preference).to eq(BSON::Document.new(mode: :secondary, max_staleness: 89))
563567
end
564568
end
565569
end
@@ -574,7 +578,7 @@
574578
end
575579

576580
it 'sets the options on a client created with the uri' do
577-
expect(new_local_client(string).options[:replica_set]).to eq(rs_name)
581+
expect(client.options[:replica_set]).to eq(rs_name)
578582
end
579583
end
580584

@@ -590,7 +594,7 @@
590594
end
591595

592596
it 'sets the options on a client created with the uri' do
593-
expect(new_local_client(string).options[:auth_mech]).to eq(expected)
597+
expect(client.options[:auth_mech]).to eq(expected)
594598
end
595599

596600
it 'is case-insensitive' do
@@ -607,7 +611,7 @@
607611
end
608612

609613
it 'sets the options on a client created with the uri' do
610-
expect(new_local_client(string).options[:auth_mech]).to eq(expected)
614+
expect(client.options[:auth_mech]).to eq(expected)
611615
end
612616

613617
it 'is case-insensitive' do
@@ -624,7 +628,7 @@
624628
end
625629

626630
it 'sets the options on a client created with the uri' do
627-
expect(new_local_client(string).options[:auth_mech]).to eq(expected)
631+
expect(client.options[:auth_mech]).to eq(expected)
628632
end
629633

630634
it 'is case-insensitive' do
@@ -641,7 +645,7 @@
641645
end
642646

643647
it 'sets the options on a client created with the uri' do
644-
expect(new_local_client(string).options[:auth_mech]).to eq(expected)
648+
expect(client.options[:auth_mech]).to eq(expected)
645649
end
646650

647651
it 'is case-insensitive' do
@@ -658,7 +662,7 @@
658662
end
659663

660664
it 'sets the options on a client created with the uri' do
661-
expect(new_local_client(string).options[:auth_mech]).to eq(expected)
665+
expect(client.options[:auth_mech]).to eq(expected)
662666
end
663667

664668
it 'is case-insensitive' do
@@ -686,7 +690,7 @@
686690
end
687691

688692
it 'sets the options on a client created with the uri' do
689-
expect(new_local_client(string).options[:auth_source]).to eq(source)
693+
expect(client.options[:auth_source]).to eq(source)
690694
end
691695
end
692696

@@ -699,7 +703,7 @@
699703
end
700704

701705
it 'sets the options on a client created with the uri' do
702-
expect(new_local_client(string).options[:auth_source]).to eq(expected)
706+
expect(client.options[:auth_source]).to eq(expected)
703707
end
704708
end
705709
end
@@ -719,7 +723,7 @@
719723
end
720724

721725
it 'sets the options on a client created with the uri' do
722-
expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected)
726+
expect(client.options[:auth_mech_properties]).to eq(expected)
723727
end
724728
end
725729

@@ -735,7 +739,7 @@
735739
end
736740

737741
it 'sets the options on a client created with the uri' do
738-
expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected)
742+
expect(client.options[:auth_mech_properties]).to eq(expected)
739743
end
740744
end
741745

@@ -753,7 +757,7 @@
753757
end
754758

755759
it 'sets the options on a client created with the uri' do
756-
expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected)
760+
expect(client.options[:auth_mech_properties]).to eq(expected)
757761
end
758762
end
759763

@@ -779,7 +783,7 @@
779783
end
780784

781785
it 'sets the options on a client created with the uri' do
782-
expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected)
786+
expect(client.options[:auth_mech_properties]).to eq(expected)
783787
end
784788
end
785789
end
@@ -907,25 +911,21 @@
907911
let(:options) { "appname=srv_test" }
908912

909913
it 'sets the app name on the client' do
910-
expect(new_local_client(string).options[:app_name]).to eq(:srv_test)
914+
expect(client.options[:app_name]).to eq(:srv_test)
911915
end
912916
end
913917

914918
context 'when a supported compressors option is provided' do
915919
let(:options) { "compressors=zlib" }
916920

917921
it 'sets the compressors as an array on the client' do
918-
expect(new_local_client(string).options[:compressors]).to eq(['zlib'])
922+
expect(client.options[:compressors]).to eq(['zlib'])
919923
end
920924
end
921925

922926
context 'when a non-supported compressors option is provided' do
923927
let(:options) { "compressors=snoopy" }
924928

925-
let(:client) do
926-
new_local_client(string)
927-
end
928-
929929
it 'sets no compressors on the client and warns' do
930930
expect(Mongo::Logger.logger).to receive(:warn)
931931
expect(client.options[:compressors]).to be_nil
@@ -936,7 +936,7 @@
936936
let(:options) { "zlibCompressionLevel=6" }
937937

938938
it 'sets the zlib compression level on the client' do
939-
expect(new_local_client(string).options[:zlib_compression_level]).to eq(6)
939+
expect(client.options[:zlib_compression_level]).to eq(6)
940940
end
941941
end
942942
end

0 commit comments

Comments
 (0)