Flaky spec: spec/features/projects/work_items/work_item_spec.rb Couldn't find User with 'id'=
Summary
Incidents:
- gitlab-org/quality/engineering-productivity/master-broken-incidents#2862 (closed)
- gitlab-org/quality/engineering-productivity/master-broken-incidents#2883 (closed)
The entire spec has been quarantined via: gitlab-org/quality/engineering-productivity/fast-quarantine!14 (merged)
Steps to reproduce
I find this error hard to reproduce locally. My suspicion is that the failures are related to test data leaking state as a result of using let_it_be
to create test data for specs that are mutating data. See https://docs.gitlab.com/ee/development/testing_guide/flaky_tests.html#state-leak.
My recommendation for resolving is to rewrite the specs by removing all let_it_be
, and switch to let!
or let
which yields a more predictable test state after each spec.
Please refer to Flaky tests documentation to learn more about how to reproduce them.
Proposed Resolution
Please refer to the Resolution guidance to learn more about resolution of broken master.
Once the flaky failure has been fixed on the default branch, open merge requests to cherry-pick the fix to the active stable branches.
Logs
Work item for signed in user shows project issues link in breadcrumbs
Failure/Error: project.add_developer(user)
ActiveRecord::RecordNotFound:
Couldn't find User with 'id'=337
# ./spec/features/projects/work_items/work_item_spec.rb:19:in `block (3 levels) in <top (required)>'
# ./spec/spec_helper.rb:444:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:435:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:431:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:61:in `with_raw_context'
# ./spec/spec_helper.rb:431:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:268:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/support/fast_quarantine.rb:23:in `block (2 levels) in <top (required)>'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
# ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
...
Failed examples:
rspec ./spec/features/projects/work_items/work_item_spec.rb:26 # Work item for signed in user shows project issues link in breadcrumbs
rspec ./spec/features/projects/work_items/work_item_spec.rb:32 # Work item for signed in user uses IID path in breadcrumbs
rspec ./spec/features/projects/work_items/work_item_spec.rb:38 # Work item for signed in user actions dropdown is displayed
rspec ./spec/features/projects/work_items/work_item_spec.rb:42 # Work item for signed in user behaves like work items title successfully shows and changes the title of the work item
rspec ./spec/features/projects/work_items/work_item_spec.rb:43 # Work item for signed in user behaves like work items status successfully shows and changes the status of the work item
rspec ./spec/features/projects/work_items/work_item_spec.rb:45 # Work item for signed in user behaves like work items labels successfully assigns a label
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:1]' # Work item for signed in user behaves like work items comments successfully creates and shows comments
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:2]' # Work item for signed in user behaves like work items comments successfully updates existing comments
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:4]' # Work item for signed in user behaves like work items comments successfully posts comments using shortcut and checks if textarea is blank when reinitiated
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:3:1]' # Work item for signed in user behaves like work items comments for work item note actions signed in user with developer role shows work item note actions
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:5:1]' # Work item for signed in user behaves like work items comments when using quick actions autocompletes quick actions common to all work item types
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:5:2:1]' # Work item for signed in user behaves like work items comments when using quick actions when a widget is enabled autocompletes quick action for the enabled widget
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:8:5:3:1]' # Work item for signed in user behaves like work items comments when using quick actions when a widget is disabled does not autocomplete quick action for the disabled widget
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:9:1]' # Work item for signed in user behaves like work items description shows GFM autocomplete
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:9:2]' # Work item for signed in user behaves like work items description autocompletes available quick actions
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:9:3:1]' # Work item for signed in user behaves like work items description on conflict shows conflict message when description changes
rspec ./spec/features/projects/work_items/work_item_spec.rb:48 # Work item for signed in user behaves like work items milestone searches and sets or removes milestone for the work item
rspec ./spec/features/projects/work_items/work_item_spec.rb:49 # Work item for signed in user behaves like work items notifications displays toast when notification is toggled
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:12:1]' # Work item for signed in user behaves like work items todos adds item to the list
rspec './spec/features/projects/work_items/work_item_spec.rb[1:1:12:2]' # Work item for signed in user behaves like work items todos marks a todo as done