Skip to content

Commit 885b0fc

Browse files
committed
Test the Mongo integration with the real driver
The subscriber specs fed the monitoring callbacks hand-built doubles, so the integration was never exercised against the driver's real event API. Build real `Mongo::Monitoring::Event` objects instead and drive the started/succeeded/failed callbacks; their constructors don't open a connection, so no MongoDB server is needed. Assert on the recorded event rather than on internal extension calls. This needs the gem, so add a mongo gemfile and build matrix entry and gate the specs on it. [skip changeset]
1 parent 9ffcdb5 commit 885b0fc

6 files changed

Lines changed: 314 additions & 118 deletions

File tree

.github/workflows/ci.yml

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This is a generated file by the `rake build_matrix:github:generate` task.
33
# See `build_matrix.yml` for the build matrix.
44
# Generate this file with `rake build_matrix:github:generate`.
5-
# Generated job count: 207
5+
# Generated job count: 214
66
---
77
name: Ruby gem CI
88
'on':
@@ -321,6 +321,33 @@ jobs:
321321
JRUBY_OPTS: ''
322322
COV: '1'
323323
BUNDLE_GEMFILE: gemfiles/http6.gemfile
324+
ruby_4-0-0__mongo_ubuntu-latest:
325+
name: Ruby 4.0.0 - mongo
326+
needs: ruby_4-0-0_ubuntu-latest
327+
runs-on: ubuntu-latest
328+
steps:
329+
- name: Check out repository
330+
uses: actions/checkout@v4
331+
- name: Install Ruby
332+
uses: ruby/setup-ruby@v1
333+
with:
334+
ruby-version: 4.0.0
335+
bundler-cache: true
336+
- name: Install gem extension
337+
run: "./script/bundler_wrapper exec rake extension:install"
338+
- name: Print extension install report
339+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
340+
file found'"
341+
- name: Print Makefile log file
342+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
343+
found'"
344+
- name: Run tests
345+
run: "./script/bundler_wrapper exec rake test"
346+
env:
347+
RAILS_ENV: test
348+
JRUBY_OPTS: ''
349+
COV: '1'
350+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
324351
ruby_4-0-0__ownership_ubuntu-latest:
325352
name: Ruby 4.0.0 - ownership
326353
needs: ruby_4-0-0_ubuntu-latest
@@ -1135,6 +1162,33 @@ jobs:
11351162
JRUBY_OPTS: ''
11361163
COV: '1'
11371164
BUNDLE_GEMFILE: gemfiles/http6.gemfile
1165+
ruby_3-4-1__mongo_ubuntu-latest:
1166+
name: Ruby 3.4.1 - mongo
1167+
needs: ruby_3-4-1_ubuntu-latest
1168+
runs-on: ubuntu-latest
1169+
steps:
1170+
- name: Check out repository
1171+
uses: actions/checkout@v4
1172+
- name: Install Ruby
1173+
uses: ruby/setup-ruby@v1
1174+
with:
1175+
ruby-version: 3.4.1
1176+
bundler-cache: true
1177+
- name: Install gem extension
1178+
run: "./script/bundler_wrapper exec rake extension:install"
1179+
- name: Print extension install report
1180+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
1181+
file found'"
1182+
- name: Print Makefile log file
1183+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
1184+
found'"
1185+
- name: Run tests
1186+
run: "./script/bundler_wrapper exec rake test"
1187+
env:
1188+
RAILS_ENV: test
1189+
JRUBY_OPTS: ''
1190+
COV: '1'
1191+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
11381192
ruby_3-4-1__ownership_ubuntu-latest:
11391193
name: Ruby 3.4.1 - ownership
11401194
needs: ruby_3-4-1_ubuntu-latest
@@ -2003,6 +2057,33 @@ jobs:
20032057
JRUBY_OPTS: ''
20042058
COV: '1'
20052059
BUNDLE_GEMFILE: gemfiles/http6.gemfile
2060+
ruby_3-3-4__mongo_ubuntu-latest:
2061+
name: Ruby 3.3.4 - mongo
2062+
needs: ruby_3-3-4_ubuntu-latest
2063+
runs-on: ubuntu-latest
2064+
steps:
2065+
- name: Check out repository
2066+
uses: actions/checkout@v4
2067+
- name: Install Ruby
2068+
uses: ruby/setup-ruby@v1
2069+
with:
2070+
ruby-version: 3.3.4
2071+
bundler-cache: true
2072+
- name: Install gem extension
2073+
run: "./script/bundler_wrapper exec rake extension:install"
2074+
- name: Print extension install report
2075+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
2076+
file found'"
2077+
- name: Print Makefile log file
2078+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
2079+
found'"
2080+
- name: Run tests
2081+
run: "./script/bundler_wrapper exec rake test"
2082+
env:
2083+
RAILS_ENV: test
2084+
JRUBY_OPTS: ''
2085+
COV: '1'
2086+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
20062087
ruby_3-3-4__ownership_ubuntu-latest:
20072088
name: Ruby 3.3.4 - ownership
20082089
needs: ruby_3-3-4_ubuntu-latest
@@ -2817,6 +2898,33 @@ jobs:
28172898
JRUBY_OPTS: ''
28182899
COV: '1'
28192900
BUNDLE_GEMFILE: gemfiles/http6.gemfile
2901+
ruby_3-2-5__mongo_ubuntu-latest:
2902+
name: Ruby 3.2.5 - mongo
2903+
needs: ruby_3-2-5_ubuntu-latest
2904+
runs-on: ubuntu-latest
2905+
steps:
2906+
- name: Check out repository
2907+
uses: actions/checkout@v4
2908+
- name: Install Ruby
2909+
uses: ruby/setup-ruby@v1
2910+
with:
2911+
ruby-version: 3.2.5
2912+
bundler-cache: true
2913+
- name: Install gem extension
2914+
run: "./script/bundler_wrapper exec rake extension:install"
2915+
- name: Print extension install report
2916+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
2917+
file found'"
2918+
- name: Print Makefile log file
2919+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
2920+
found'"
2921+
- name: Run tests
2922+
run: "./script/bundler_wrapper exec rake test"
2923+
env:
2924+
RAILS_ENV: test
2925+
JRUBY_OPTS: ''
2926+
COV: '1'
2927+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
28202928
ruby_3-2-5__ownership_ubuntu-latest:
28212929
name: Ruby 3.2.5 - ownership
28222930
needs: ruby_3-2-5_ubuntu-latest
@@ -3604,6 +3712,33 @@ jobs:
36043712
JRUBY_OPTS: ''
36053713
COV: '1'
36063714
BUNDLE_GEMFILE: gemfiles/http5.gemfile
3715+
ruby_3-1-6__mongo_ubuntu-latest:
3716+
name: Ruby 3.1.6 - mongo
3717+
needs: ruby_3-1-6_ubuntu-latest
3718+
runs-on: ubuntu-latest
3719+
steps:
3720+
- name: Check out repository
3721+
uses: actions/checkout@v4
3722+
- name: Install Ruby
3723+
uses: ruby/setup-ruby@v1
3724+
with:
3725+
ruby-version: 3.1.6
3726+
bundler-cache: true
3727+
- name: Install gem extension
3728+
run: "./script/bundler_wrapper exec rake extension:install"
3729+
- name: Print extension install report
3730+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
3731+
file found'"
3732+
- name: Print Makefile log file
3733+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
3734+
found'"
3735+
- name: Run tests
3736+
run: "./script/bundler_wrapper exec rake test"
3737+
env:
3738+
RAILS_ENV: test
3739+
JRUBY_OPTS: ''
3740+
COV: '1'
3741+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
36073742
ruby_3-1-6__ownership_ubuntu-latest:
36083743
name: Ruby 3.1.6 - ownership
36093744
needs: ruby_3-1-6_ubuntu-latest
@@ -4310,6 +4445,33 @@ jobs:
43104445
JRUBY_OPTS: ''
43114446
COV: '1'
43124447
BUNDLE_GEMFILE: gemfiles/http5.gemfile
4448+
ruby_3-0-7__mongo_ubuntu-latest:
4449+
name: Ruby 3.0.7 - mongo
4450+
needs: ruby_3-0-7_ubuntu-latest
4451+
runs-on: ubuntu-latest
4452+
steps:
4453+
- name: Check out repository
4454+
uses: actions/checkout@v4
4455+
- name: Install Ruby
4456+
uses: ruby/setup-ruby@v1
4457+
with:
4458+
ruby-version: 3.0.7
4459+
bundler-cache: true
4460+
- name: Install gem extension
4461+
run: "./script/bundler_wrapper exec rake extension:install"
4462+
- name: Print extension install report
4463+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
4464+
file found'"
4465+
- name: Print Makefile log file
4466+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
4467+
found'"
4468+
- name: Run tests
4469+
run: "./script/bundler_wrapper exec rake test"
4470+
env:
4471+
RAILS_ENV: test
4472+
JRUBY_OPTS: ''
4473+
COV: '1'
4474+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
43134475
ruby_3-0-7__ownership_ubuntu-latest:
43144476
name: Ruby 3.0.7 - ownership
43154477
needs: ruby_3-0-7_ubuntu-latest
@@ -4935,6 +5097,33 @@ jobs:
49355097
JRUBY_OPTS: ''
49365098
COV: '1'
49375099
BUNDLE_GEMFILE: gemfiles/http5.gemfile
5100+
ruby_2-7-8__mongo_ubuntu-latest:
5101+
name: Ruby 2.7.8 - mongo
5102+
needs: ruby_2-7-8_ubuntu-latest
5103+
runs-on: ubuntu-latest
5104+
steps:
5105+
- name: Check out repository
5106+
uses: actions/checkout@v4
5107+
- name: Install Ruby
5108+
uses: ruby/setup-ruby@v1
5109+
with:
5110+
ruby-version: 2.7.8
5111+
bundler-cache: true
5112+
- name: Install gem extension
5113+
run: "./script/bundler_wrapper exec rake extension:install"
5114+
- name: Print extension install report
5115+
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
5116+
file found'"
5117+
- name: Print Makefile log file
5118+
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
5119+
found'"
5120+
- name: Run tests
5121+
run: "./script/bundler_wrapper exec rake test"
5122+
env:
5123+
RAILS_ENV: test
5124+
JRUBY_OPTS: ''
5125+
COV: '1'
5126+
BUNDLE_GEMFILE: gemfiles/mongo.gemfile
49385127
ruby_2-7-8__ownership_ubuntu-latest:
49395128
name: Ruby 2.7.8 - ownership
49405129
needs: ruby_2-7-8_ubuntu-latest

build_matrix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ matrix:
182182
- "3.4.1"
183183
- "3.3.4"
184184
- "3.2.5"
185+
- gem: "mongo"
185186
- gem: "ownership"
186187
- gem: "padrino"
187188
exclude:

gemfiles/mongo.gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
gem "mongo"
4+
5+
gemspec :path => "../"

spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ def subscribe
3131
end
3232
end
3333

34-
context "without mongo ruby driver" do
35-
describe "#dependencies_present?" do
36-
subject { described_class.new.dependencies_present? }
37-
38-
it { is_expected.to be_falsy }
34+
# Only meaningful when the real driver isn't loaded. Under `mongo.gemfile`
35+
# the `Mongo::Monitoring::Global` constant is defined for real, so
36+
# `dependencies_present?` is truthy and this expectation no longer holds.
37+
unless DependencyHelper.mongo_present?
38+
context "without mongo ruby driver" do
39+
describe "#dependencies_present?" do
40+
subject { described_class.new.dependencies_present? }
41+
42+
it { is_expected.to be_falsy }
43+
end
3944
end
4045
end
4146
end

0 commit comments

Comments
 (0)