Improve flaky Projects API specs
What does this MR do and why?
Improve flaky Projects API specs. See failures 1-3 in https://gitlab.com/gitlab-org/gitlab/-/jobs/3654543070#L1990 or log snippet below.
Screenshots or screen recordings
Failures:
1) API::Projects POST /projects when importing with mirror attributes creates new project with pull mirroring set up
Failure/Error:
expect(Project.first).to have_attributes(
mirror: true,
import_url: import_url,
mirror_user_id: user.id,
mirror_trigger_builds: true
)
expected #<Project id:85 user97/project76>> to have attributes {:import_url => "http://example2.test", :mirror => true, :mirror_trigger_builds => true, :mirror_user_id => 118} but had attributes {:import_url => nil, :mirror => false, :mirror_trigger_builds => false, :mirror_user_id => nil}
Diff:
@@ -1,5 +1,5 @@
-:import_url => "http://example2.test",
-:mirror => true,
-:mirror_trigger_builds => true,
-:mirror_user_id => 118,
+:import_url => nil,
+:mirror => false,
+:mirror_trigger_builds => false,
+:mirror_user_id => nil,
# ./ee/spec/requests/api/projects_spec.rb:667:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:512:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:504:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:500:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:500:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:239:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/support/flaky_tests.rb:27: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)>'
2) API::Projects POST /projects when importing with mirror attributes creates project without mirror settings when repository mirroring feature is disabled
Failure/Error:
expect(Project.first).to have_attributes(
mirror: false,
import_url: import_url,
mirror_user_id: nil,
mirror_trigger_builds: false
)
expected #<Project id:89 user99/project78>> to have attributes {:import_url => "http://example4.test", :mirror => false, :mirror_trigger_builds => false, :mirror_user_id => nil} but had attributes {:import_url => nil, :mirror => false, :mirror_trigger_builds => false, :mirror_user_id => nil}
Diff:
@@ -1,4 +1,4 @@
-:import_url => "http://example4.test",
+:import_url => nil,
:mirror => false,
:mirror_trigger_builds => false,
:mirror_user_id => nil,
# ./ee/spec/requests/api/projects_spec.rb:682:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:512:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:504:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:500:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:500:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:239:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/support/flaky_tests.rb:27: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)>'
3) API::Projects POST /projects when importing with mirror attributes when pull mirroring is not available creates project with mirror settings
Failure/Error:
expect(Project.first).to have_attributes(
mirror: true,
import_url: import_url,
mirror_user_id: admin.id,
mirror_trigger_builds: true
)
expected #<Project id:95 user103/project81>> to have attributes {:import_url => "http://example7.test", :mirror => true, :mirror_trigger_builds => true, :mirror_user_id => 125} but had attributes {:import_url => nil, :mirror => false, :mirror_trigger_builds => false, :mirror_user_id => nil}
Diff:
@@ -1,5 +1,5 @@
-:import_url => "http://example7.test",
-:mirror => true,
-:mirror_trigger_builds => true,
-:mirror_user_id => 125,
+:import_url => nil,
+:mirror => false,
+:mirror_trigger_builds => false,
+:mirror_user_id => nil,
# ./ee/spec/requests/api/projects_spec.rb:708:in `block (5 levels) in <top (required)>'
# ./spec/spec_helper.rb:512:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:504:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:500:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:500:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:239:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/support/flaky_tests.rb:27: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)>'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Alishan Ladhani