diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /qa/qa/specs/features/api | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'qa/qa/specs/features/api')
8 files changed, 142 insertions, 15 deletions
diff --git a/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb b/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb new file mode 100644 index 00000000000..1b873d35d75 --- /dev/null +++ b/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Manage', :github, :requires_admin do + describe 'Project import' do + let!(:api_client) { Runtime::API::Client.as_admin } + let!(:group) { Resource::Group.fabricate_via_api! { |resource| resource.api_client = api_client } } + let!(:user) do + Resource::User.fabricate_via_api! do |resource| + resource.api_client = api_client + resource.hard_delete_on_api_removal = true + end + end + + let(:imported_project) do + Resource::ProjectImportedFromGithub.fabricate_via_api! do |project| + project.name = 'imported-project' + project.group = group + project.github_personal_access_token = Runtime::Env.github_access_token + project.github_repository_path = 'gitlab-qa-github/test-project' + project.api_client = api_client + end + end + + before do + group.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + end + + after do + user.remove_via_api! + end + + it 'imports Github repo via api', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1858' do + imported_project # import the project + + expect { imported_project.reload!.import_status }.to eventually_eq('finished').within(duration: 90) + + aggregate_failures do + verify_repository_import + verify_commits_import + verify_labels_import + verify_issues_import + verify_milestones_import + verify_wikis_import + verify_merge_requests_import + end + end + + def verify_repository_import + expect(imported_project.api_response).to include( + description: 'A new repo for test', + import_error: nil + ) + end + + def verify_commits_import + expect(imported_project.commits.length).to eq(20) + end + + def verify_labels_import + labels = imported_project.labels.map { |label| label.slice(:name, :color) } + + expect(labels).to include( + { name: 'bug', color: '#d73a4a' }, + { name: 'custom new label', color: '#fc8f91' }, + { name: 'documentation', color: '#0075ca' }, + { name: 'duplicate', color: '#cfd3d7' }, + { name: 'enhancement', color: '#a2eeef' }, + { name: 'good first issue', color: '#7057ff' }, + { name: 'help wanted', color: '#008672' }, + { name: 'invalid', color: '#e4e669' }, + { name: 'question', color: '#d876e3' }, + { name: 'wontfix', color: '#ffffff' } + ) + end + + def verify_issues_import + issues = imported_project.issues + + expect(issues.length).to eq(1) + expect(issues.first).to include( + title: 'This is a sample issue', + description: "*Created by: gitlab-qa-github*\n\nThis is a sample first comment", + labels: ['custom new label', 'good first issue', 'help wanted'], + user_notes_count: 1 + ) + end + + def verify_milestones_import + milestones = imported_project.milestones + + expect(milestones.length).to eq(1) + expect(milestones.first).to include(title: 'v1.0', description: nil, state: 'active') + end + + def verify_wikis_import + wikis = imported_project.wikis + + expect(wikis.length).to eq(1) + expect(wikis.first).to include(title: 'Home', format: 'markdown') + end + + def verify_merge_requests_import + merge_requests = imported_project.merge_requests + merge_request = Resource::MergeRequest.init do |mr| + mr.project = imported_project + mr.iid = merge_requests.first[:iid] + mr.api_client = api_client + end.reload! + mr_comments = merge_request.comments.map { |comment| comment[:body] } # rubocop:disable Rails/Pluck + + expect(merge_requests.length).to eq(1) + expect(merge_request.api_resource).to include( + title: 'Improve readme', + state: 'opened', + target_branch: 'main', + source_branch: 'improve-readme', + labels: %w[bug documentation], + description: <<~DSC.strip + *Created by: gitlab-qa-github*\n\nThis improves the README file a bit.\r\n\r\nTODO:\r\n\r\n \r\n\r\n- [ ] Do foo\r\n- [ ] Make bar\r\n - [ ] Think about baz + DSC + ) + expect(mr_comments).to eq( + [ + "*Created by: gitlab-qa-github*\n\n[PR comment by @sliaquat] Nice work! ", + "*Created by: gitlab-qa-github*\n\n[Single diff comment] Nice addition", + "*Created by: gitlab-qa-github*\n\n[Single diff comment] Good riddance" + ] + ) + end + end + end +end diff --git a/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb index 08b71258cc6..6c70c09c7ab 100644 --- a/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb +++ b/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb @@ -5,8 +5,7 @@ require 'parallel' module QA RSpec.describe 'Create' do context 'Gitaly' do - # Issue to track removal of feature flag: https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/602 - describe 'Distributed reads', :orchestrated, :gitaly_cluster, :skip_live_env, :requires_admin, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/322814', type: :investigating } do + describe 'Distributed reads', :orchestrated, :gitaly_cluster, :skip_live_env, :requires_admin do let(:number_of_reads_per_loop) { 9 } let(:praefect_manager) { Service::PraefectManager.new } let(:project) do @@ -17,14 +16,9 @@ module QA end before do - Runtime::Feature.enable(:gitaly_distributed_reads) praefect_manager.wait_for_replication(project.id) end - after do - Runtime::Feature.disable(:gitaly_distributed_reads) - end - it 'reads from each node', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/979' do pre_read_data = praefect_manager.query_read_distribution diff --git a/qa/qa/specs/features/api/3_create/gitaly/praefect_replication_queue_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/praefect_replication_queue_spec.rb index 396d3f52798..7e924475437 100644 --- a/qa/qa/specs/features/api/3_create/gitaly/praefect_replication_queue_spec.rb +++ b/qa/qa/specs/features/api/3_create/gitaly/praefect_replication_queue_spec.rb @@ -4,7 +4,7 @@ require 'parallel' module QA RSpec.describe 'Create' do - context 'Gitaly Cluster replication queue', :orchestrated, :gitaly_cluster, :skip_live_env, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/331989', type: :investigating } do + context 'Gitaly Cluster replication queue', :orchestrated, :gitaly_cluster, :skip_live_env do let(:praefect_manager) { Service::PraefectManager.new } let(:project) do Resource::Project.fabricate! do |project| diff --git a/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb b/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb index dde4708874d..157a9e92817 100644 --- a/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb +++ b/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb @@ -64,7 +64,7 @@ module QA merge_request = Resource::MergeRequest.fabricate_via_api! do |mr| mr.project = project - mr.id = merge_request[:iid] + mr.iid = merge_request[:iid] end expect(merge_request.state).to eq('opened') @@ -109,7 +109,7 @@ module QA merge_request = Support::Waiter.wait_until(sleep_interval: 5) do mr = Resource::MergeRequest.fabricate_via_api! do |mr| mr.project = project - mr.id = merge_request[:iid] + mr.iid = merge_request[:iid] end next unless mr.state == 'merged' diff --git a/qa/qa/specs/features/api/3_create/merge_request/push_options_remove_source_branch_spec.rb b/qa/qa/specs/features/api/3_create/merge_request/push_options_remove_source_branch_spec.rb index bf2ecfdb513..eb93f4cd5cb 100644 --- a/qa/qa/specs/features/api/3_create/merge_request/push_options_remove_source_branch_spec.rb +++ b/qa/qa/specs/features/api/3_create/merge_request/push_options_remove_source_branch_spec.rb @@ -34,7 +34,7 @@ module QA merge_request = Resource::MergeRequest.fabricate_via_api! do |mr| mr.project = project - mr.id = merge_request[:iid] + mr.iid = merge_request[:iid] end.merge_via_api! expect(merge_request[:state]).to eq('merged') diff --git a/qa/qa/specs/features/api/3_create/merge_request/push_options_target_branch_spec.rb b/qa/qa/specs/features/api/3_create/merge_request/push_options_target_branch_spec.rb index e02d32bc4c7..799efc243d4 100644 --- a/qa/qa/specs/features/api/3_create/merge_request/push_options_target_branch_spec.rb +++ b/qa/qa/specs/features/api/3_create/merge_request/push_options_target_branch_spec.rb @@ -55,7 +55,7 @@ module QA merge_request = Resource::MergeRequest.fabricate_via_api! do |mr| mr.project = project - mr.id = merge_request[:iid] + mr.iid = merge_request[:iid] end.merge_via_api! expect(merge_request[:state]).to eq('merged') diff --git a/qa/qa/specs/features/api/3_create/merge_request/push_options_title_description_spec.rb b/qa/qa/specs/features/api/3_create/merge_request/push_options_title_description_spec.rb index f49a8a229dc..62e6290183f 100644 --- a/qa/qa/specs/features/api/3_create/merge_request/push_options_title_description_spec.rb +++ b/qa/qa/specs/features/api/3_create/merge_request/push_options_title_description_spec.rb @@ -39,7 +39,7 @@ module QA merge_request = Resource::MergeRequest.fabricate_via_api! do |mr| mr.project = project - mr.id = merge_request[:iid] + mr.iid = merge_request[:iid] end.merge_via_api! expect(merge_request[:state]).to eq('merged') diff --git a/qa/qa/specs/features/api/5_package/container_registry_spec.rb b/qa/qa/specs/features/api/5_package/container_registry_spec.rb index 57b059ffc02..5003d49fe6c 100644 --- a/qa/qa/specs/features/api/5_package/container_registry_spec.rb +++ b/qa/qa/specs/features/api/5_package/container_registry_spec.rb @@ -17,8 +17,8 @@ module QA end let(:registry) do - Resource::RegistryRepository.new.tap do |repository| - repository.name = "#{project.path_with_namespace}" + Resource::RegistryRepository.init do |repository| + repository.name = project.path_with_namespace repository.project = project repository.tag_name = 'master' end |