Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for httprb 5.0.0 #722

Merged
merged 11 commits into from Sep 9, 2021
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -157,7 +157,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: [2.5.9, 2.6.8, 2.7.4]
ruby-version: [2.5.9, 2.6.8, 2.7.4, 3.0.2]
steps:
- uses: actions/checkout@v2

Expand Down
16 changes: 10 additions & 6 deletions test/multiverse/suites/httprb/Envfile
Expand Up @@ -4,12 +4,14 @@ end

instrumentation_methods :chain, :prepend

# gemfile <<-RB
# gem 'http' # latest version
# gem 'public_suffix', '< 3.0.0' if RUBY_VERSION < "2.1.0"
# gem 'rack'
# #{ruby3_gem_webrick}
# RB
unless RUBY_PLATFORM == 'java'
gemfile <<-RB
gem 'http' # latest version
gem 'public_suffix', '< 3.0.0' if RUBY_VERSION < "2.1.0"
gem 'rack'
#{ruby3_gem_webrick}
RB
end

# NOTE, some versions of HTTP gem implements body with
# String.new("").force_encoding(@encoding) which won't work
Expand All @@ -18,6 +20,7 @@ instrumentation_methods :chain, :prepend

# Either just the gem version or Array of gem version and last and supported Ruby versions
HTTPRB_VERSIONS = [
['5.0.1', 2.5],
['4.4.0', 2.3, 2.6],
['4.3.0', 2.3, 2.6],
['4.2.0', 2.3, 2.6],
Expand All @@ -28,6 +31,7 @@ HTTPRB_VERSIONS = [
HTTPRB_VERSIONS.each do |httprb_version|
if httprb_version.is_a?(Array)
httprb_version, first_supported_ruby_version, last_supported_ruby_version = httprb_version
next if httprb_version =~ /^5.0/ && RUBY_PLATFORM == 'java'
next if last_supported_ruby_version && RUBY_VERSION.to_f > last_supported_ruby_version
next if RUBY_VERSION.to_f < first_supported_ruby_version
end
Expand Down
3 changes: 2 additions & 1 deletion test/multiverse/suites/httprb/httprb_test.rb
Expand Up @@ -69,7 +69,8 @@ def response_instance(headers = {})
status: 200,
version: '1.1',
headers: headers,
body: ''
body: '',
request: HTTP::Request.new(uri: "http://newrelic.com", verb: :get)
}

httprb_resp = is_unsupported_1x? ? HTTP::Response.new(*options.values) : HTTP::Response.new(options)
Expand Down
20 changes: 8 additions & 12 deletions test/new_relic/agent/stats_engine/stats_hash_test.rb
Expand Up @@ -147,18 +147,14 @@ def test_merge_transaction_metrics
assert_equal(1, hash[specs[3]].call_count)
end

# Marshal.load is broken on current versions of Jruby, but it has been reported
# and will be fixed in JRuby 9.1.9.0. This conditional be removed after it's
# released. See: https://github.com/jruby/jruby/issues/4526.
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'jruby' && JRUBY_VERSION >= "9.1.9.0"
def test_marshal_dump
@hash.record(NewRelic::MetricSpec.new('foo'), 1)
@hash.record(NewRelic::MetricSpec.new('bar'), 2)

copy = Marshal.load(Marshal.dump(@hash))
assert_equal(@hash, copy)
assert_equal(@hash.started_at, copy.started_at)
end

def test_marshal_dump
@hash.record(NewRelic::MetricSpec.new('foo'), 1)
@hash.record(NewRelic::MetricSpec.new('bar'), 2)

copy = Marshal.load(Marshal.dump(@hash))
assert_equal(@hash, copy)
assert_equal(@hash.started_at, copy.started_at)
end

# We can only fix up the default proc on Rubies that let us set it
Expand Down