[CIVIS-10061] Fix Knapsack Pro integration #180
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #147
This PR fixes the following issues with our current Knapsack Pro support:
Dropping tests because of missing test session
When running
knapsack_pro:rspec:queue
command,Datadog.configure
block gets called whenrails_helper
is required which in this case happens afterKnapsackPro::Extensions::RSpecExtension.setup!
had been run.To fix this, we check whether
RSpec::Core::Runner
was already instrumented by knapsack: if yes, we instrumentRSpec::Core::Runner
directly. If not, we hook intoKnapsackPro::Extensions::RSpecExtension
to instrument the runner after knapsack injects its methods:Noise from knapsack_pro:rspec_test_example_detector test command
We noticed that in many cases when using knapsack, we got a lot more test runs than there are unique tests; additional test runs all have very short duration and are part of
knapsack_pro:rspec_test_example_detector
.It turned out, that we trace rspec session that is running with
--dry-run
: test example detector from knapsack uses dry run to generate a report with all rspec examples.This issue is fixed by never tracing rspec tests when dry run is enabled:
How to test the change?
Unit tests are provided and additionally tested with Github Actions: https://github.com/DataDog/rails-app-with-knapsack_pro/actions/workflows/main.yaml
The test runs arrived correctly:
There are no additional test runs from
rspec_test_example_detector
- the number of tests is equal to the number of test runs (51 vs 51)