Skip to content

Commit

Permalink
Merge pull request #797 from petergoldstein/spike/add_jruby_to_ci
Browse files Browse the repository at this point in the history
Add JRuby to CI
  • Loading branch information
petergoldstein committed Oct 14, 2021
2 parents 7d1d34e + 6e500dc commit 0e32aa3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/memcached_mock.rb
Expand Up @@ -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})
Expand All @@ -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
Expand All @@ -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
Expand Down
30 changes: 17 additions & 13 deletions test/test_failover.rb
Expand Up @@ -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
Expand Down

0 comments on commit 0e32aa3

Please sign in to comment.