summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/api/1_manage
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /qa/qa/specs/features/api/1_manage
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'qa/qa/specs/features/api/1_manage')
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_migration_group_spec.rb (renamed from qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb)20
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb55
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb71
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_migration_project_spec.rb94
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_project_migration_common.rb85
-rw-r--r--qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb6
6 files changed, 321 insertions, 10 deletions
diff --git a/qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_group_spec.rb
index 799a5f7eaf2..a6655471591 100644
--- a/qa/qa/specs/features/api/1_manage/bulk_import_group_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_group_spec.rb
@@ -1,9 +1,7 @@
# frozen_string_literal: true
module QA
- # run only base UI validation on staging because test requires top level group creation which is problematic
- # on staging environment
- RSpec.describe 'Manage', :requires_admin, except: { subdomain: :staging } do
+ RSpec.describe 'Manage', :requires_admin do
describe 'Gitlab migration' do
let(:import_wait_duration) { { max_duration: 300, sleep_interval: 2 } }
let(:admin_api_client) { Runtime::API::Client.as_admin }
@@ -22,9 +20,18 @@ module QA
end
end
+ let(:destination_group) do
+ Resource::Group.fabricate_via_api! do |group|
+ group.api_client = api_client
+ group.sandbox = sandbox
+ group.path = "destination-group-for-import-#{SecureRandom.hex(4)}"
+ end
+ end
+
let(:source_group) do
- Resource::Sandbox.fabricate_via_api! do |group|
+ Resource::Group.fabricate_via_api! do |group|
group.api_client = api_client
+ group.sandbox = sandbox
group.path = "source-group-for-import-#{SecureRandom.hex(4)}"
group.avatar = File.new('qa/fixtures/designs/tanuki.jpg', 'r')
end
@@ -33,8 +40,8 @@ module QA
let(:imported_group) do
Resource::BulkImportGroup.fabricate_via_api! do |group|
group.api_client = api_client
- group.sandbox = sandbox
- group.source_group_path = source_group.path
+ group.sandbox = destination_group
+ group.source_group = source_group
end
end
@@ -167,7 +174,6 @@ module QA
expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration)
imported_member = imported_group.reload!.members.find { |usr| usr.username == member.username }
-
aggregate_failures do
expect(imported_member).not_to be_nil
expect(imported_member.access_level).to eq(Resource::Members::AccessLevel::DEVELOPER)
diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb
new file mode 100644
index 00000000000..8a2a382ac45
--- /dev/null
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require_relative 'gitlab_project_migration_common'
+
+module QA
+ RSpec.describe 'Manage', :requires_admin do
+ describe 'Gitlab migration', quarantine: {
+ only: { job: 'praefect' },
+ type: :investigating,
+ issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/348999'
+ } do
+ include_context 'with gitlab project migration'
+
+ context 'with project issues' do
+ let!(:source_issue) do
+ Resource::Issue.fabricate_via_api! do |issue|
+ issue.api_client = api_client
+ issue.project = source_project
+ issue.labels = %w[label_one label_two]
+ end
+ end
+
+ let!(:source_comment) { source_issue.add_comment(body: 'This is a test comment!') }
+
+ let(:imported_issues) { imported_projects.first.issues }
+
+ let(:imported_issue) do
+ issue = imported_issues.first
+ Resource::Issue.init do |resource|
+ resource.api_client = api_client
+ resource.project = imported_projects.first
+ resource.iid = issue[:iid]
+ end
+ end
+
+ let(:imported_comments) { imported_issue.comments }
+
+ it(
+ 'successfully imports issue',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347608'
+ ) do
+ expect_import_finished
+
+ aggregate_failures do
+ expect(imported_issues.count).to eq(1)
+ expect(imported_issue).to eq(source_issue.reload!)
+
+ expect(imported_comments.count).to eq(1)
+ expect(imported_comments.first[:body]).to include(source_comment[:body])
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb
new file mode 100644
index 00000000000..9dce9bff3c1
--- /dev/null
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+require_relative 'gitlab_project_migration_common'
+
+module QA
+ RSpec.describe 'Manage', :requires_admin do
+ describe 'Gitlab migration', quarantine: {
+ only: { job: 'praefect' },
+ type: :investigating,
+ issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/348999'
+ } do
+ include_context 'with gitlab project migration'
+
+ context 'with merge request' do
+ let!(:source_project_with_readme) { true }
+
+ let!(:other_user) do
+ Resource::User
+ .fabricate_via_api! { |usr| usr.api_client = admin_api_client }
+ .tap do |usr|
+ usr.set_public_email
+ source_project.add_member(usr, Resource::Members::AccessLevel::MAINTAINER)
+ end
+ end
+
+ let!(:source_mr) do
+ Resource::MergeRequest.fabricate_via_api! do |mr|
+ mr.project = source_project
+ mr.api_client = Runtime::API::Client.new(user: other_user)
+ end
+ end
+
+ let!(:source_comment) { source_mr.add_comment('This is a test comment!') }
+
+ let(:imported_mrs) { imported_project.merge_requests }
+ let(:imported_mr_comments) { imported_mr.comments }
+
+ let(:imported_mr) do
+ Resource::MergeRequest.init do |mr|
+ mr.project = imported_project
+ mr.iid = imported_mrs.first[:iid]
+ mr.api_client = api_client
+ end
+ end
+
+ after do
+ other_user.remove_via_api!
+ end
+
+ it(
+ 'successfully imports merge request',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478'
+ ) do
+ expect_import_finished
+
+ aggregate_failures do
+ expect(imported_mrs.count).to eq(1)
+ # TODO: remove custom comparison after member migration is implemented
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/341886
+ expect(imported_mr.comparable.except(:author)).to eq(source_mr.reload!.comparable.except(:author))
+
+ expect(imported_mr_comments.count).to eq(1)
+ expect(imported_mr_comments.first[:body]).to include(source_comment[:body])
+ # Comment will have mention of original user since members are not migrated yet
+ expect(imported_mr_comments.first[:body]).to include(other_user.name)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_project_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_project_spec.rb
new file mode 100644
index 00000000000..a0c758c99e6
--- /dev/null
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_project_spec.rb
@@ -0,0 +1,94 @@
+# frozen_string_literal: true
+
+require_relative 'gitlab_project_migration_common'
+
+module QA
+ RSpec.describe 'Manage', :requires_admin do
+ describe 'Gitlab migration', quarantine: {
+ only: { job: 'praefect' },
+ type: :investigating,
+ issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/348999'
+ } do
+ include_context 'with gitlab project migration'
+
+ context 'with uninitialized project' do
+ it(
+ 'successfully imports project',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347610'
+ ) do
+ expect_import_finished
+
+ expect(imported_projects.first).to eq(source_project)
+ end
+ end
+
+ context 'with repository' do
+ let(:source_project_with_readme) { true }
+ let(:source_commits) { source_project.commits.map { |c| c.except(:web_url) } }
+ let(:source_tags) do
+ source_project.repository_tags.tap do |tags|
+ tags.each { |t| t[:commit].delete(:web_url) }
+ end
+ end
+
+ let(:source_branches) do
+ source_project.repository_branches.tap do |branches|
+ branches.each do |b|
+ b.delete(:web_url)
+ b[:commit].delete(:web_url)
+ end
+ end
+ end
+
+ let(:imported_commits) { imported_project.commits.map { |c| c.except(:web_url) } }
+ let(:imported_tags) do
+ imported_project.repository_tags.tap do |tags|
+ tags.each { |t| t[:commit].delete(:web_url) }
+ end
+ end
+
+ let(:imported_branches) do
+ imported_project.repository_branches.tap do |branches|
+ branches.each do |b|
+ b.delete(:web_url)
+ b[:commit].delete(:web_url)
+ end
+ end
+ end
+
+ before do
+ source_project.create_repository_branch('test-branch')
+ source_project.create_repository_tag('v0.0.1')
+ end
+
+ it(
+ 'successfully imports repository',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347570'
+ ) do
+ expect_import_finished
+
+ aggregate_failures do
+ expect(imported_commits).to match_array(source_commits)
+ expect(imported_tags).to match_array(source_tags)
+ expect(imported_branches).to match_array(source_branches)
+ end
+ end
+ end
+
+ context 'with wiki' do
+ before do
+ source_project.create_wiki_page(title: 'Import test project wiki', content: 'Wiki content')
+ end
+
+ it(
+ 'successfully imports project wiki',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347567'
+ ) do
+ expect_import_finished
+
+ expect(imported_projects.first.wikis).to eq(source_project.wikis)
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_project_migration_common.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_project_migration_common.rb
new file mode 100644
index 00000000000..827ebc1f5e2
--- /dev/null
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_project_migration_common.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.shared_context 'with gitlab project migration' do
+ let(:source_project_with_readme) { false }
+ let(:import_wait_duration) { { max_duration: 300, sleep_interval: 2 } }
+ let(:admin_api_client) { Runtime::API::Client.as_admin }
+ let(:user) do
+ Resource::User.fabricate_via_api! do |usr|
+ usr.api_client = admin_api_client
+ usr.hard_delete_on_api_removal = true
+ end
+ end
+
+ let(:api_client) { Runtime::API::Client.new(user: user) }
+
+ let(:sandbox) do
+ Resource::Sandbox.fabricate_via_api! do |group|
+ group.api_client = admin_api_client
+ end
+ end
+
+ let(:destination_group) do
+ Resource::Group.fabricate_via_api! do |group|
+ group.api_client = api_client
+ group.sandbox = sandbox
+ group.path = "destination-group-for-import-#{SecureRandom.hex(4)}"
+ end
+ end
+
+ let(:source_group) do
+ Resource::Group.fabricate_via_api! do |group|
+ group.api_client = api_client
+ group.path = "source-group-for-import-#{SecureRandom.hex(4)}"
+ end
+ end
+
+ let(:source_project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.api_client = api_client
+ project.group = source_group
+ project.initialize_with_readme = source_project_with_readme
+ end
+ end
+
+ let(:imported_group) do
+ Resource::BulkImportGroup.fabricate_via_api! do |group|
+ group.api_client = api_client
+ group.sandbox = destination_group
+ group.source_group = source_group
+ end
+ end
+
+ let(:imported_projects) { imported_group.reload!.projects }
+ let(:imported_project) { imported_projects.first }
+
+ let(:import_failures) do
+ imported_group.import_details.sum([]) { |details| details[:failures] }
+ end
+
+ def expect_import_finished
+ imported_group # trigger import
+
+ expect { imported_group.import_status }.to eventually_eq('finished').within(import_wait_duration)
+ expect(imported_projects.count).to eq(1), 'Expected to have 1 imported project'
+ end
+
+ before do
+ Runtime::Feature.enable(:bulk_import_projects)
+
+ sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
+ source_project # fabricate source group and project
+ end
+
+ after do |example|
+ # Checking for failures in the test currently makes test very flaky
+ # Just log in case of failure until cause of network errors is found
+ Runtime::Logger.warn("Import failures: #{import_failures}") if example.exception && !import_failures.empty?
+
+ user.remove_via_api!
+ ensure
+ Runtime::Feature.disable(:bulk_import_projects)
+ end
+ end
+end
diff --git a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
index e47e5d22e5e..6a31d173440 100644
--- a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
@@ -37,7 +37,7 @@ module QA
push.file_name = 'test.txt'
push.file_content = "# This is a test project named #{@project.name}"
push.commit_message = 'Add test.txt'
- push.branch_name = 'new_branch'
+ push.branch_name = "new_branch_#{SecureRandom.hex(8)}"
push.user = @user
end
end.to raise_error(QA::Support::Run::CommandError, /You are not allowed to push code to this project/)
@@ -48,7 +48,7 @@ module QA
Resource::File.fabricate_via_api! do |file|
file.api_client = @user_api_client
file.project = @project
- file.branch = 'new_branch'
+ file.branch = "new_branch_#{SecureRandom.hex(8)}"
file.commit_message = 'Add new file'
file.name = 'test.txt'
file.content = "New file"
@@ -61,7 +61,7 @@ module QA
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.api_client = @user_api_client
commit.project = @project
- commit.branch = 'new_branch'
+ commit.branch = "new_branch_#{SecureRandom.hex(8)}"
commit.start_branch = @project.default_branch
commit.commit_message = 'Add new file'
commit.add_files([