Skip to content

Commit bf88571

Browse files
committed
Add jruby_100? method
1 parent ee502a6 commit bf88571

File tree

10 files changed

+30
-25
lines changed

10 files changed

+30
-25
lines changed

spec/datadog/appsec/contrib/rack/integration_test_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@
504504
expect(span).to have_tag('_dd.rc.boot.time')
505505
expect(span.get_tag('_dd.rc.boot.time')).to be_a Float
506506
# TODO: JRuby 10.0 - Remove this skip after investigation.
507-
expect(span).to have_tag('_dd.rc.boot.timeout') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
508-
expect(span.get_tag('_dd.rc.boot.timeout')).to eq 'true' unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
509-
expect(span).to_not have_tag('_dd.rc.boot.ready') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
507+
expect(span).to have_tag('_dd.rc.boot.timeout') unless PlatformHelpers.jruby_100?
508+
expect(span.get_tag('_dd.rc.boot.timeout')).to eq 'true' unless PlatformHelpers.jruby_100?
509+
expect(span).to_not have_tag('_dd.rc.boot.ready') unless PlatformHelpers.jruby_100?
510510
expect(span).to be_root_span
511511
end
512512

@@ -517,7 +517,7 @@
517517
expect(span.get_tag('_dd.rc.client_id')).to eq remote_client_id
518518
expect(span).to have_tag('_dd.rc.status')
519519
# TODO: JRuby 10.0 - Remove this skip after investigation.
520-
expect(span.get_tag('_dd.rc.status')).to eq 'disconnected' unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
520+
expect(span.get_tag('_dd.rc.status')).to eq 'disconnected' unless PlatformHelpers.jruby_100?
521521
end
522522

523523
context 'without tracing' do
@@ -555,7 +555,7 @@
555555
expect(last_span.get_tag('_dd.rc.client_id')).to eq remote_client_id
556556
expect(last_span).to have_tag('_dd.rc.status')
557557
# TODO: JRuby 10.0 - Remove this skip after investigation.
558-
expect(last_span.get_tag('_dd.rc.status')).to eq 'disconnected' unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
558+
expect(last_span.get_tag('_dd.rc.status')).to eq 'disconnected' unless PlatformHelpers.jruby_100?
559559
end
560560

561561
context 'without tracing' do

spec/datadog/appsec/contrib/sinatra/integration_test_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
require 'datadog/appsec'
1717

1818
# TODO: JRuby 10.0 - Remove this skip after investigation.
19-
RSpec.describe 'Sinatra integration tests', skip: RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0') do
19+
RSpec.describe 'Sinatra integration tests', skip: PlatformHelpers.jruby_100? do
2020
include Rack::Test::Methods
2121

2222
let(:sorted_spans) do

spec/datadog/appsec/contrib/sinatra/schema_extraction_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require 'datadog/appsec'
1111

1212
# TODO: JRuby 10.0 - Remove this skip after investigation.
13-
RSpec.describe 'Schema extraction for API security in Sinatra', skip: RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0') do
13+
RSpec.describe 'Schema extraction for API security in Sinatra', skip: PlatformHelpers.jruby_100? do
1414
include Rack::Test::Methods
1515

1616
before do

spec/datadog/core/remote/component_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
context('shorter than lift') do
328328
it 'unblocks on timeout' do
329329
# TODO: JRuby 10.0 - Remove this skip after investigation.
330-
skip('Test failing for JRuby 10.0') if RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0')
330+
skip('Test failing for JRuby 10.0') if PlatformHelpers.jruby_100?
331331

332332
record << :one
333333
expect(barrier.wait_once(timeout)).to eq :timeout
@@ -358,7 +358,7 @@
358358

359359
it 'prefers the local timeout' do
360360
# TODO: JRuby 10.0 - Remove this skip after investigation.
361-
skip('Test failing for JRuby 10.0') if RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0')
361+
skip('Test failing for JRuby 10.0') if PlatformHelpers.jruby_100?
362362

363363
record << :one
364364
expect(barrier.wait_once(timeout)).to eq :timeout
@@ -376,7 +376,7 @@
376376

377377
it "unblocks on timeout with" do
378378
# TODO: JRuby 10.0 - Remove this skip after investigation.
379-
skip('Test failing for JRuby 10.0') if RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0')
379+
skip('Test failing for JRuby 10.0') if PlatformHelpers.jruby_100?
380380

381381
record << :one
382382
expect(barrier.wait_once).to eq :timeout

spec/datadog/tracing/contrib/grape/tracer_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
.to eq('endpoint_run')
313313
expect(span.get_tag('http.status_code')).to eq('405')
314314
# TODO: JRuby 10.0 - Remove this skip after investigation.
315-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
315+
unless PlatformHelpers.jruby_100?
316316
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
317317
.to eq('/base/hard_failure')
318318
end
@@ -445,7 +445,7 @@
445445
.to eq('endpoint_run')
446446
expect(span.get_tag('http.status_code')).to eq('405')
447447
# TODO: JRuby 10.0 - Remove this skip after investigation.
448-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
448+
unless PlatformHelpers.jruby_100?
449449
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
450450
.to eq('/base/soft_failure')
451451
end
@@ -466,7 +466,7 @@
466466
.to eq('endpoint_run')
467467
expect(span.get_tag('http.status_code')).to eq('405')
468468
# TODO: JRuby 10.0 - Remove this skip after investigation.
469-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
469+
unless PlatformHelpers.jruby_100?
470470
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
471471
.to eq('/base/soft_failure')
472472
end
@@ -488,7 +488,7 @@
488488
.to eq('endpoint_run')
489489
expect(span.get_tag('http.status_code')).to eq('405')
490490
# TODO: JRuby 10.0 - Remove this skip after investigation.
491-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
491+
unless PlatformHelpers.jruby_100?
492492
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
493493
.to eq('/base/soft_failure')
494494
end
@@ -510,7 +510,7 @@
510510
.to eq('endpoint_run')
511511
expect(span.get_tag('http.status_code')).to eq('405')
512512
# TODO: JRuby 10.0 - Remove this skip after investigation.
513-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
513+
unless PlatformHelpers.jruby_100?
514514
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
515515
.to eq('/base/soft_failure')
516516
end
@@ -532,7 +532,7 @@
532532
.to eq('endpoint_run')
533533
expect(span.get_tag('http.status_code')).to eq('405')
534534
# TODO: JRuby 10.0 - Remove this skip after investigation.
535-
unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
535+
unless PlatformHelpers.jruby_100?
536536
expect(trace.send(:meta).fetch(Datadog::Tracing::Metadata::Ext::HTTP::TAG_ROUTE))
537537
.to eq('/base/soft_failure')
538538
end

spec/datadog/tracing/contrib/rack/integration_test_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@
238238
expect(span).to have_tag('_dd.rc.boot.time')
239239
expect(span.get_tag('_dd.rc.boot.time')).to be_a Float
240240
# TODO: JRuby 10.0 - Remove this skip after investigation.
241-
expect(span).to have_tag('_dd.rc.boot.timeout') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
242-
expect(span.get_tag('_dd.rc.boot.timeout')).to eq 'true' unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
243-
expect(span).to_not have_tag('_dd.rc.boot.ready') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
241+
expect(span).to have_tag('_dd.rc.boot.timeout') unless PlatformHelpers.jruby_100?
242+
expect(span.get_tag('_dd.rc.boot.timeout')).to eq 'true' unless PlatformHelpers.jruby_100?
243+
expect(span).to_not have_tag('_dd.rc.boot.ready') unless PlatformHelpers.jruby_100?
244244
expect(span).to be_root_span
245245
end
246246

@@ -266,8 +266,8 @@
266266
expect(response).to be_ok
267267
expect(spans).to have(2).items
268268
# TODO: JRuby 10.0 - Remove this skip after investigation.
269-
expect(last_span).to_not have_tag('_dd.rc.boot.time') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
270-
expect(last_span).to_not have_tag('_dd.rc.boot.ready') unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
269+
expect(last_span).to_not have_tag('_dd.rc.boot.time') unless PlatformHelpers.jruby_100?
270+
expect(last_span).to_not have_tag('_dd.rc.boot.ready') unless PlatformHelpers.jruby_100?
271271
expect(last_span).to_not have_tag('_dd.rc.boot.timeout')
272272
expect(last_span).to be_root_span
273273
end
@@ -279,7 +279,7 @@
279279
expect(last_span.get_tag('_dd.rc.client_id')).to eq remote_client_id
280280
expect(last_span).to have_tag('_dd.rc.status')
281281
# TODO: JRuby 10.0 - Remove this skip after investigation.
282-
expect(last_span.get_tag('_dd.rc.status')).to eq 'disconnected' unless RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0')
282+
expect(last_span.get_tag('_dd.rc.status')).to eq 'disconnected' unless PlatformHelpers.jruby_100?
283283
end
284284
end
285285

spec/datadog/tracing/contrib/shoryuken/tracer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def perform(sqs_msg, body)
184184

185185
it do
186186
# TODO: JRuby 10.0 - Remove this skip after investigation.
187-
skip 'Test failing for JRuby 10.0 due to missing OpenStruct' if RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0')
187+
skip 'Test failing for JRuby 10.0 due to missing OpenStruct' if PlatformHelpers.jruby_100?
188188
expect { perform_async }.to_not raise_error
189189
# TODO: These expectations do not work because Shoryuken doesn't run middleware in tests
190190
# https://github.com/phstc/shoryuken/issues/541

spec/datadog/tracing/contrib/sinatra/multi_app_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
require 'datadog/tracing/contrib/sinatra/tracer'
88

99
# TODO: JRuby 10.0 - Remove this skip after investigation.
10-
RSpec.describe 'Sinatra instrumentation for multi-apps', skip: RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0') do
10+
RSpec.describe 'Sinatra instrumentation for multi-apps', skip: PlatformHelpers.jruby_100? do
1111
include Rack::Test::Methods
1212

1313
let(:options) { {} }

spec/datadog/tracing/contrib/sinatra/tracer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
require_relative '../support/http'
1616

1717
# TODO: JRuby 10.0 - Remove this skip after investigation.
18-
RSpec.describe 'Sinatra instrumentation', skip: RUBY_PLATFORM == 'java' && RUBY_ENGINE_VERSION.start_with?('10.0') do
18+
RSpec.describe 'Sinatra instrumentation', skip: PlatformHelpers.jruby_100? do
1919
include Rack::Test::Methods
2020

2121
subject(:response) { get url }

spec/support/platform_helpers.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def jruby?
1818
RUBY_ENGINE == 'jruby'
1919
end
2020

21+
# After we resolve all "# TODO: JRuby 10.0 - " comments, remove this method and update docs/Compatibility.md
22+
def jruby_100?
23+
RUBY_ENGINE == 'jruby' && RUBY_ENGINE_VERSION.start_with?('10.0')
24+
end
25+
2126
def truffleruby?
2227
RUBY_ENGINE == 'truffleruby'
2328
end

0 commit comments

Comments
 (0)