Commit abbaf0db authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '354856-investigate-performance-of-import-project-members' into 'master'

Change import project members API feature category

See merge request gitlab-org/gitlab!82936
parents 3f872027 1fbc9956
......@@ -611,7 +611,8 @@ module API
params do
requires :project_id, type: Integer, desc: 'The ID of the source project to import the members from.'
end
post ":id/import_project_members/:project_id", feature_category: :experimentation_expansion do
post ":id/import_project_members/:project_id", feature_category: :projects do
::Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/355916')
authorize! :admin_project, user_project
source_project = Project.find_by_id(params[:project_id])
......
......@@ -3143,6 +3143,29 @@ RSpec.describe API::Projects do
project2.add_developer(project2_user)
end
it 'records the query', :request_store, :use_sql_query_cache do
post api("/projects/#{project.id}/import_project_members/#{project2.id}", user)
control_project = create(:project)
control_project.add_maintainer(user)
control_project.add_developer(create(:user))
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
post api("/projects/#{project.id}/import_project_members/#{control_project.id}", user)
end
measure_project = create(:project)
measure_project.add_maintainer(user)
measure_project.add_developer(create(:user))
measure_project.add_developer(create(:user)) # make this 2nd one to find any n+1
unresolved_n_plus_ones = 21 # 21 queries added per member
expect do
post api("/projects/#{project.id}/import_project_members/#{measure_project.id}", user)
end.not_to exceed_all_query_limit(control.count).with_threshold(unresolved_n_plus_ones)
end
it 'returns 200 when it successfully imports members from another project' do
expect do
post api("/projects/#{project.id}/import_project_members/#{project2.id}", user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment