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

Fix leaky db test #3765

Merged
merged 1 commit into from
Jul 8, 2024
Merged

Fix leaky db test #3765

merged 1 commit into from
Jul 8, 2024

Conversation

TonyCTHsu
Copy link
Contributor

What does this PR do?

Fix leaky db tests

Failures:

  1) Rails database on record creation with instantiation support is expected to eq 1
     Failure/Error: expect(span.get_tag('active_record.instantiation.record_count')).to eq(1)
     
       expected: 1
            got: 34.0
     
       (compared using ==)
     # ./spec/datadog/tracing/contrib/rails/database_spec.rb:89:in `block in <main>'
     # ./spec/datadog/tracing/contrib/rails/support/log_configuration.rb:6:in `block in <main>'
     # ./spec/datadog/tracing/contrib/support/tracer_helpers.rb:96:in `block in TracerHelpers'
     # ./spec/spec_helper.rb:230:in `block in <main>'
     # ./spec/spec_helper.rb:115:in `block in <main>'
     # /usr/local/bundle/gems/webmock-3.23.1/lib/webmock/rspec.rb:39:in `block in <main>'
     # /usr/local/bundle/gems/rspec-wait-0.0.10/lib/rspec/wait.rb:47:in `block in <main>'

Finished in 3 minutes 9.6 seconds (files took 6.69 seconds to load)
269 examples, 1 failure, 8 pending

Failed examples:

rspec ./spec/datadog/tracing/contrib/rails/database_spec.rb:79 # Rails database on record creation with instantiation support is expected to eq 1

How to reproduce

In Jruby 9.4 environment

echo "--seed 43133" >> .rspec
bundle exec appraisal jruby-9.4-relational_db rake spec:active_record
bundle exec appraisal jruby-9.4-rails61-mysql2 rake spec:rails

After the spec task for active record, the db is polluted with records

=>
[#<Article:0x48306567 id: 1, title: "test", created_at: 2024-07-08 12:02:35 UTC, updated_at: 2024-07-08 12:02:35 UTC>,
 #<Article:0x3a4181ba id: 2, title: "test", created_at: 2024-07-08 12:02:35 UTC, updated_at: 2024-07-08 12:02:35 UTC>,
 #<Article:0x41185195 id: 3, title: "test", created_at: 2024-07-08 12:02:35 UTC, updated_at: 2024-07-08 12:02:35 UTC>,
 #<Article:0x1d5e0621 id: 4, title: "test", created_at: 2024-07-08 12:02:35 UTC, updated_at: 2024-07-08 12:02:35 UTC>,
 #<Article:0x4823f3b8 id: 5, title: "test", created_at: 2024-07-08 12:02:35 UTC, updated_at: 2024-07-08 12:02:35 UTC>,
 #<Article:0x53425450 id: 6, title: "test", created_at: 2024-07-08 12:02:36 UTC, updated_at: 2024-07-08 12:02:36 UTC>,
 #<Article:0x1aa21319 id: 7, title: "test", created_at: 2024-07-08 12:02:36 UTC, updated_at: 2024-07-08 12:02:36 UTC>,
 #<Article:0x4149067d id: 8, title: "test", created_at: 2024-07-08 12:02:36 UTC, updated_at: 2024-07-08 12:02:36 UTC>,
 #<Article:0x48860fb8 id: 9, title: "test", created_at: 2024-07-08 12:02:36 UTC, updated_at: 2024-07-08 12:02:36 UTC>,

@TonyCTHsu TonyCTHsu added the dev/testing Involves testing processes (e.g. RSpec) label Jul 8, 2024
@TonyCTHsu TonyCTHsu added this to the 2.2.0 milestone Jul 8, 2024
@TonyCTHsu TonyCTHsu self-assigned this Jul 8, 2024
@TonyCTHsu TonyCTHsu requested a review from a team as a code owner July 8, 2024 12:16
@TonyCTHsu TonyCTHsu enabled auto-merge July 8, 2024 12:19
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.91%. Comparing base (6e1050a) to head (c3d0d18).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3765      +/-   ##
==========================================
- Coverage   97.91%   97.91%   -0.01%     
==========================================
  Files        1241     1241              
  Lines       74714    74716       +2     
  Branches     3605     3605              
==========================================
+ Hits        73157    73158       +1     
- Misses       1557     1558       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TonyCTHsu TonyCTHsu merged commit 89e5d0a into master Jul 8, 2024
171 checks passed
@TonyCTHsu TonyCTHsu deleted the tonycthsu/fix-leaky-spec branch July 8, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/testing Involves testing processes (e.g. RSpec)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants