diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd6eae05..6c401f03 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - ruby-version: [2.5, 2.6, 2.7, 3.0] + ruby-version: [2.5, 2.6, 2.7, 3.0, jruby-9.2, jruby-9.3] steps: - uses: actions/checkout@v2 diff --git a/test/memcached_mock.rb b/test/memcached_mock.rb index c9c92c71..7d479a28 100644 --- a/test/memcached_mock.rb +++ b/test/memcached_mock.rb @@ -107,7 +107,7 @@ def memcached_ssl_persistent(port = 21397) ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.ca_file = "/tmp/root.crt" ssl_context.ssl_version = :SSLv23 - ssl_context.verify_hostname = true + ssl_context.verify_hostname = true if ssl_context.respond_to?(:verify_hostname) ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER dc = start_and_flush_with_retry(port, "-Z -o ssl_chain_cert=/tmp/memcached.crt -o ssl_key=/tmp/memcached.key", {:ssl_context => ssl_context}) @@ -121,6 +121,7 @@ def memcached_ssl_persistent(port = 21397) root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key root_cert = OpenSSL::X509::Certificate.new root_cert.version = 2 # cf. RFC 5280 - to make it a "v3" certificate + root_cert.serial = 1 root_cert.subject = OpenSSL::X509::Name.parse "/CN=Dalli CA" root_cert.issuer = root_cert.subject # root CA's are "self-signed" root_cert.public_key = root_key.public_key @@ -139,6 +140,7 @@ def memcached_ssl_persistent(port = 21397) key = OpenSSL::PKey::RSA.new 2048 cert = OpenSSL::X509::Certificate.new cert.version = 2 + cert.serial = 2 cert.subject = OpenSSL::X509::Name.parse "/CN=localhost" cert.issuer = root_cert.subject # root CA is the issuer cert.public_key = key.public_key diff --git a/test/test_failover.rb b/test/test_failover.rb index ccef36fb..59d2d9d9 100644 --- a/test/test_failover.rb +++ b/test/test_failover.rb @@ -3,22 +3,26 @@ require_relative "helper" describe "failover" do - describe "timeouts" do - it "not lead to corrupt sockets" do - memcached_persistent do |dc| - value = {test: "123"} - begin - Timeout.timeout 0.01 do - start_time = Time.now - 10_000.times do - dc.set("test_123", value) + # Timeouts on JRuby work differently and aren't firing, meaning we're + # not testing the condition + unless defined? JRUBY_VERSION + describe "timeouts" do + it "not lead to corrupt sockets" do + memcached_persistent do |dc| + value = {test: "123"} + begin + Timeout.timeout 0.01 do + start_time = Time.now + 10_000.times do + dc.set("test_123", value) + end + flunk("Did not timeout in #{Time.now - start_time}") end - flunk("Did not timeout in #{Time.now - start_time}") + rescue Timeout::Error end - rescue Timeout::Error - end - assert_equal(value, dc.get("test_123")) + assert_equal(value, dc.get("test_123")) + end end end end