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

CI: Rework JRuby testing #2282

Merged
merged 34 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a8d0550
CI: test against JRuby v9.4.4.0
fallwith Oct 23, 2023
c2c9110
Async-HTTP: don't test with JRuby, catch errors
fallwith Oct 23, 2023
c66a921
multiverse helpers: relax errors check for JRuby
fallwith Oct 24, 2023
a23b37b
multiverse: additional JRuby relaxation
fallwith Oct 25, 2023
d4abfae
JRuby: permit extras
fallwith Oct 26, 2023
3dd67bb
ignoring test cases: JRuby helper
fallwith Oct 27, 2023
6d23441
test: fix first_call_for usage
fallwith Oct 27, 2023
dfb5adf
JRuby 9.4.4.0 -> 9.4.5.0
fallwith Nov 8, 2023
9d2a075
Merge branch 'dev' into jruby9440
fallwith Nov 8, 2023
bc159eb
JRuby CI: set JAVA_OPTS
fallwith Nov 13, 2023
16e766f
CI: relax 'exactly' to 'at least' for JRuby's sake
fallwith Nov 18, 2023
0c1ca75
JRuby: target Rails 7+ for base unit tests
fallwith Nov 20, 2023
7bcfbfa
JRuby compact WIP
fallwith Nov 20, 2023
1d7cc6e
JRuby WIP
fallwith Nov 20, 2023
9a6319a
use dup instead of a mutex
fallwith Nov 21, 2023
10c91a4
JRuby CI: re-enable multiverse tests
fallwith Nov 21, 2023
e306aab
use retry for JRuby multiverse tests
fallwith Nov 21, 2023
bbe3a1e
use ubuntu 20 for JRuby CI
fallwith Nov 21, 2023
085e302
JRuby CI: run 'bundle exec' directly
fallwith Nov 22, 2023
3d5bee4
JRuby CI: individual suites
fallwith Nov 22, 2023
3aff9f6
JRuby CI: retry individual suites
fallwith Nov 22, 2023
9d2c735
JRUBY and JAVA opts
fallwith Nov 22, 2023
56a2374
JRuby CI: ubuntu 20, 4g
fallwith Nov 22, 2023
7ed7d10
JRuby CI: use --dev
fallwith Nov 22, 2023
3591276
CI JRuby: Ubuntu 22
fallwith Nov 22, 2023
ac9c6a4
CI JRuby: temporarily disable retries
fallwith Nov 22, 2023
404f85e
CI JRuby: drop JRuby version
fallwith Nov 22, 2023
a84f7f8
JRuby CI: serviceless
fallwith Nov 23, 2023
a2cf64b
JRuby CI: bump to v9.4.5.0
fallwith Nov 23, 2023
238a281
JRuby CI: more service removal
fallwith Nov 23, 2023
ec4336a
Merge branch 'dev' into jruby9440
fallwith Nov 23, 2023
3015db8
remove unnecessary :: prefix
fallwith Nov 23, 2023
2f04619
remove retry_command
fallwith Nov 23, 2023
da4b4e4
async-http: use suite_condition to skip JRuby
fallwith Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 17 additions & 89 deletions .github/workflows/ci_jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ on:
workflow_dispatch:

jobs:
unit_tests:
jruby_unit_tests:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- "3306:3306"
strategy:
fail-fast: false
steps:
Expand All @@ -24,9 +16,9 @@ jobs:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag v3.5.0

- name: Install JRuby
uses: ruby/setup-ruby@bc1dd263b68cb5626dbb55d5c89777d79372c484 # tag v1.151.0
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # tag v1.160.0
with:
ruby-version: jruby-9.4.3.0
ruby-version: jruby-9.4.5.0

- name: Bundle
run: bundle install
Expand All @@ -36,85 +28,19 @@ jobs:
with:
timeout_minutes: 30
max_attempts: 2
command: bundle exec rake test:env[norails,rails61,rails60]
command: bundle exec rake test:env[norails,rails61]
fallwith marked this conversation as resolved.
Show resolved Hide resolved
env:
VERBOSE_TEST_OUTPUT: true
DB_PORT: ${{ job.services.mysql.ports[3306] }}
JRUBY_OPTS: --dev --debug

JAVA_OPTS: --add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist
JRUBY_OPTS: --dev

jruby_multiverse:
runs-on: ubuntu-22.04
services:
elasticsearch7:
image: elasticsearch:7.16.2
env:
discovery.type: single-node
ports:
- 9200:9200
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
elasticsearch8:
image: elasticsearch:8.4.2
env:
discovery.type: single-node
xpack.security.enabled: false
ports:
- 9250:9200
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
memcached:
image: memcached:latest
ports:
- 11211:11211
options: >-
--health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:5.0.11
ports:
- 27017:27017
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- "3306:3306"
postgres:
image: postgres:latest
ports:
- 5432:5432
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q check_port_connectivity"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
multiverse: [agent, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest]
suite: [active_support_broadcast_logger, active_support_logger, activemerchant, agent_only, async_http, bare, deferred_instrumentation, grape, high_security, httpclient, httprb, httpx, json, logger, marshalling, rack, resque, roda, roda_agent_disabled, sequel, sinatra, sinatra_agent_disabled, stripe, thread, tilt, typhoeus]

steps:
- name: Configure git
run: 'git config --global init.defaultBranch main'
Expand All @@ -123,22 +49,24 @@ jobs:
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag v3.5.0

- name: Install JRuby
uses: ruby/setup-ruby@bc1dd263b68cb5626dbb55d5c89777d79372c484 # tag v1.151.0
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # tag v1.160.0
with:
ruby-version: jruby-9.4.3.0
ruby-version: jruby-9.4.5.0

- name: Bundle
run: bundle install

- name: Run Multiverse Tests
run: ./.github/workflows/scripts/retry_command
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # tag v2.8.3
with:
timeout_minutes: 20
max_attempts: 3
command: "bundle exec rake test:multiverse[${{ matrix.suite }}]"
env:
TEST_CMD: "bundle exec rake test:multiverse[group=${{ matrix.multiverse }}]"
VERBOSE_TEST_OUTPUT: true
RETRY_ATTEMPTS: 5
fallwith marked this conversation as resolved.
Show resolved Hide resolved
SERIALIZE: 1
DB_PORT: ${{ job.services.mysql.ports[3306] }}
JRUBY_OPTS: --dev --debug
JAVA_OPTS: --add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist -Xmx4g -Xms512m
JRUBY_OPTS: --dev

- name: Annotate errors
if: ${{ failure() }}
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/scripts/retry_command

This file was deleted.

2 changes: 1 addition & 1 deletion lib/new_relic/agent/configuration/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def reset_to_defaults
def reset_cache
return new_cache unless defined?(@cache) && @cache

preserved = @cache.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
new_cache
preserved.each { |k, v| @cache[k] = v }

Expand Down
12 changes: 12 additions & 0 deletions test/agent_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1025,3 +1025,15 @@ def defer_testing_to_min_supported_rails(test_file, min_rails_version, supports_
puts "Skipping tests in #{File.basename(test_file)} because Rails >= #{min_rails_version} is unavailable" if ENV['VERBOSE_TEST_OUTPUT']
end
end

def first_call_for(subject)
items = $collector.calls_for(subject)

if defined?(JRUBY_VERSION)
refute_predicate items.size, :zero?, "Expected at least one call for '#{subject}'"
else
assert_equal 1, items.size, "Expected exactly one call for '#{subject}'"
end

items.first
end
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ def test_post_includes_metadata
end

def last_custom_event_post
posts = $collector.calls_for('custom_event_data')

assert_equal(1, posts.size)
posts.first
first_call_for('custom_event_data')
end

def last_posted_events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ def assert_endpoint_received_string(endpoint, string)
agent.send(:transmit_custom_event_data)
agent.send(:transmit_error_event_data)
agent.send(:transmit_span_event_data)
requests = $collector.calls_for(endpoint)
request = first_call_for(endpoint)

assert_equal(1, requests.size)
request = requests.first
request.decode! if request.respond_to?(:decode!)

assert_contains_string(request, string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_request_entity_too_large

# make sure the data gets thrown away after we called collector without crashing
assert_metrics_not_recorded(['Custom/too_big'])
assert_equal(1, $collector.calls_for('metric_data').size)
first_call_for('metric_data')
end

def test_unsupported_media_type
Expand All @@ -35,6 +35,6 @@ def test_unsupported_media_type

# make sure the data gets thrown away after we called collector without crashing
assert_metrics_not_recorded(['Custom/too_big'])
assert_equal(1, $collector.calls_for('metric_data').size)
first_call_for('metric_data')
end
end
10 changes: 4 additions & 6 deletions test/multiverse/suites/agent_only/key_transactions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def test_applied_correct_tt_threshold

NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)

traces = $collector.calls_for('transaction_sample_data')
trace = first_call_for('transaction_sample_data')

assert_equal 1, traces.size
assert_equal(WEB_KEY_TXN, traces[0].metric_name)
assert_equal(WEB_KEY_TXN, trace.metric_name)
end

def test_applied_correct_apdex_t_to_background_key_txn
Expand All @@ -109,9 +108,8 @@ def test_applied_correct_tt_threshold_to_background

NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)

traces = $collector.calls_for('transaction_sample_data')
trace = first_call_for('transaction_sample_data')

assert_equal 1, traces.size
assert_equal(OTHER_KEY_TXN, traces[0].metric_name)
assert_equal(OTHER_KEY_TXN, trace.metric_name)
end
end
10 changes: 4 additions & 6 deletions test/multiverse/suites/agent_only/synthetics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ def app
end

def last_sent_analytics_event
calls = $collector.calls_for(:analytic_event_data)
call = first_call_for(:analytic_event_data)

assert_equal(1, calls.size)
events = calls.first.events
events = call.events

assert_equal(1, events.size)
events.first
end

def last_sent_transaction_trace
calls = $collector.calls_for(:transaction_sample_data)
call = first_call_for(:transaction_sample_data)

assert_equal(1, calls.size)
traces = calls.first.samples
traces = call.samples

assert_equal(1, traces.size)
traces.first
Expand Down
4 changes: 4 additions & 0 deletions test/multiverse/suites/async_http/Envfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

instrumentation_methods :chain, :prepend

suite_condition('async-http needs native C extensions') do
RUBY_PLATFORM != 'java'
end

ASYNC_HTTP_VERSIONS = [
[nil, 2.5],
['0.59.0', 2.5]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def request_and_wait(method, url, headers = nil, body = nil)
internet = Async::HTTP::Internet.new
resp = internet.send(method, url, headers)
@read_resp = resp&.read
rescue Async::TimeoutError, EOFError
ensure
internet&.close
end
Expand Down
5 changes: 2 additions & 3 deletions test/multiverse/suites/resque/instrumentation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ def test_arguments_are_captured_on_transaction_and_span_events_when_enabled
end

def assert_metric_and_call_count(name, expected_call_count)
metric_data = $collector.calls_for('metric_data')
metric_data = first_call_for('metric_data')

assert_equal(1, metric_data.size, 'expected exactly one metric_data post from agent')
metric = metric_data.first.metrics.find { |m| m[0]['name'] == name }
metric = metric_data.metrics.find { |m| m[0]['name'] == name }

assert(metric, "could not find metric named #{name}")

Expand Down
Loading
Loading