Conversation
… individual test examples
…s not blow up the code and fallback to []
… examples even though they are not considered as slow test files
…blow up the RSpec integration tests for regular mode instead of silently hide the error
3v0k4
left a comment
There was a problem hiding this comment.
I see that to keep things short you used "split by examples" or split_by_examples. I'd keep it consistent to not add another way of calling it, so: "split by test examples" or split_by_test_examples. If it's a throwaway variable inside a method I'm fine with a shortcut.
Example:
# ok (because if I grepped I would find the split line)
def do
split = Env.split_by_test_examples_enabled?
# ...
end
# not ok
@split
it "split by example"
Could you ping me after you apply the changes to take a second look please?
| def self.rspec_id_path?(path) | ||
| path_with_id_regex = /.+_spec\.rb\[.+\]$/ | ||
|
|
||
| path&.match?(path_with_id_regex) | ||
| end |
There was a problem hiding this comment.
recommendation
Use the same naming:
| def self.rspec_id_path?(path) | |
| path_with_id_regex = /.+_spec\.rb\[.+\]$/ | |
| path&.match?(path_with_id_regex) | |
| end | |
| def self.rspec_id_path?(path) | |
| id_path_regex = /.+_spec\.rb\[.+\]$/ | |
| path&.match?(id_path_regex) | |
| end |
There was a problem hiding this comment.
I don't like that there are multiple callers and given the path&. it seems sometimes path is nil.
When does that happen?
There was a problem hiding this comment.
suggestion
I'd go with re.match?(str) instead of the other way around. It reads better for me.
There was a problem hiding this comment.
I don't like that there are multiple callers and given the path&. it seems sometimes path is nil.
When does that happen?
I don't know. I think it should not happen because a path should always be a string.
The rspec_id_path? method was moved in here from the lib/knapsack_pro/test_case_mergers/rspec_merger.rb, but originally it's definition comes from the API project:
https://github.com/KnapsackPro/knapsack-pro-api/commit/2ebfe5e133957df37be1d69c0ae999d8c7b0a7be/domain/project_domain/test_file/test_file_value.rb#diff-8
| end | ||
|
|
||
| def bind_regular_mode_time_tracker | ||
| return unless KnapsackPro::Config::Env.recording_enabled? |
There was a problem hiding this comment.
KnapsackPro::Config::Env.recording_enabled? is true when you use regular mode only.
There was a problem hiding this comment.
I did a little refactoring because the following methods are a bit confusing:
KnapsackPro::Config::Env.recording_enabled? # is regular mode on
KnapsackPro::Config::Env.queue_recording_enabled? # is queue mode on
I've renamed them to:
KnapsackPro::Config::Env.regular_mode?
KnapsackPro::Config::Env.queue_mode?
| @node_test_file_paths += test_file_paths | ||
|
|
||
| time_tracker = KnapsackPro::Formatters::TimeTrackerFetcher.call | ||
| time_tracker.scheduled_test_file_paths = @node_test_file_paths |
There was a problem hiding this comment.
Each time we set what was there before plus the new batch?
There was a problem hiding this comment.
Yes.
Each time we override the time_tracker.scheduled_test_file_paths with @node_test_file_paths.
The @node_test_file_paths is updated on each batch pulled from the Queue API.
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Rules: file path (path without id) id path (path with id) path (either one)
|
@ArturT I think the following would be clearer in the PR description: ProblemSomeone gives a set of paths to Knapsack Pro using The
It may happen that:
There are two Also, the dashboard shows:
|
No. It's inaccurate.
The If the full test file path (a_spec.rb) is not determined as slow, but the Queue API returns a_spec.rb[1:1] then we measured execution time for the full path a_spec.rb. We expected a_spec.rb[1:1] to be measured. |
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
This reverts commit ed106ed.
|
My point was that the description in this PR is confusing, that's why I tried to simplify it. You may still want to update the description in case someone else gets here and tries to understand what's going on. |
Story
https://trello.com/c/cq5i0WDt
Description
Related to the RSpec split by examples feature.
problem
Someone gives a custom set of paths to the Knapsack Pro using
KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE.There could be paths like
a_spec.rb[1:1]. But thebuild_distributions#lastreturns tests which are not considered slow.a_spec.rbcould be considered fast. We measure execution time for the full patha_spec.rbinstead ofa_spec.rb[1:1].This can lead to misleading data because node 0 could measure
a_spec.rb[1:1]asa_spec.rbtaking 1 minute. But node 1 could measurea_spec.rb[1:2]asa_spec.rbtaking 2 seconds.Now we have two
a_spec.rbpaths with different timings. They are merged on the API side. We may end up with a build witha_spec.rbtaking 2s while, in fact, it took much longer because it was split by examples between 2 nodes. We expect individual test examples to be measured.solution
Individual test examples (
a_spec.rb[1:1],a_spec.rb[1:2]) are measured from now on.Checklist reminder
UNRELEASEDsection of theCHANGELOG.md, including the needed bump (ie, patch, minor, major)lib/knapsack_pro/pure/queue/rspec_pure.rbcontains pure functions that are unit tested.lib/knapsack_pro/extensions/rspec_extension.rbencapsulates calls to RSpec internals and is integration and e2e tested.lib/knapsack_pro/runners/queue/rspec_runner.rbinvokes the pure code and the extension to produce side effects, which are integration and e2e tested.