Skip to content

Commit 4325fb9

Browse files
p-mongop
andcommitted
Fix most tests on jruby (#1721)
* outline expectations * try testing via mlaunch to get server to verify client certificates * rename options to ssl_options * set timeout on the dns resolution for good measure * RUBY-2140 add a timeout on socket liveness check * add an actual invalid cert test and skip invalid key test on jruby * reorganize invalid cert/key tests * all rubies fail the same way for certs it seems * try to fix conversation spec failures on jruby * fix step down tests when an arbiter is present in replica set * set auth options to fix the test on jruby w/auth configuration Co-authored-by: Oleg Pudeyev <p@users.noreply.github.com>
1 parent e61a77b commit 4325fb9

File tree

8 files changed

+147
-72
lines changed

8 files changed

+147
-72
lines changed

.evergreen/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,10 @@ buildvariants:
857857
ruby: "jruby-9.2"
858858
mongodb-version: "4.2"
859859
topology: "*"
860-
os: rhel70
860+
os: ubuntu1604
861861
display_name: "${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
862862
tasks:
863-
- name: "test"
863+
- name: "test-mlaunch"
864864

865865
-
866866
matrix_name: "jruby-noauth"
@@ -869,10 +869,10 @@ buildvariants:
869869
ruby: "jruby-9.2"
870870
mongodb-version: "2.6"
871871
topology: "*"
872-
os: rhel70
872+
os: ubuntu1604
873873
display_name: "${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
874874
tasks:
875-
- name: "test"
875+
- name: "test-mlaunch"
876876

877877
-
878878
matrix_name: "zlib-auth"

lib/mongo/socket.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ class Socket
6363
def alive?
6464
sock_arr = [ @socket ]
6565
if Kernel::select(sock_arr, nil, sock_arr, 0)
66-
eof?
66+
# The eof? call is supposed to return immediately since select
67+
# indicated the socket is readable. However, if @socket is an SSL
68+
# socket, eof? can block anyway - see RUBY-2140.
69+
begin
70+
Timeout.timeout(0.1) do
71+
eof?
72+
end
73+
rescue ::Timeout::Error
74+
true
75+
end
6776
else
6877
true
6978
end

spec/integration/retryable_errors_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
end
2525

2626
after do
27-
ClusterTools.instance.direct_client_for_each_server do |client|
27+
ClusterTools.instance.direct_client_for_each_data_bearing_server do |client|
2828
client.use(:admin).database.command(clear_fail_point_command)
2929
end
3030
end
@@ -62,7 +62,7 @@
6262
server.monitor.stop!
6363
end
6464

65-
ClusterTools.instance.direct_client_for_each_server do |client|
65+
ClusterTools.instance.direct_client_for_each_data_bearing_server do |client|
6666
client.use(:admin).database.command(fail_point_command)
6767
end
6868
end

spec/mongo/auth/scram/conversation_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
end
3636

3737
describe '#start' do
38+
# Test uses global assertions
39+
clean_slate
3840

3941
let(:query) do
4042
conversation.start(nil)

spec/mongo/collection_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@
278278
require_topology :replica_set
279279

280280
let(:client_options) do
281-
{
281+
SpecConfig.instance.auth_options.merge(
282282
read: { mode: :primary_preferred },
283-
}
283+
)
284284
end
285285

286286
let(:subscriber) { EventSubscriber.new }

0 commit comments

Comments
 (0)