diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /qa/qa/specs/features/api | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) | |
download | gitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'qa/qa/specs/features/api')
12 files changed, 257 insertions, 88 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 index 4bc95395f25..a51d733d484 100644 --- 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 @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Manage', :github, :requires_admin do + RSpec.describe 'Manage', :github, :requires_admin, :reliable 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 } } 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 index 8a2a382ac45..bb4b0472398 100644 --- 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 @@ -3,12 +3,8 @@ 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 + RSpec.describe 'Manage' do + describe 'Gitlab migration' do include_context 'with gitlab project migration' context 'with project issues' do @@ -40,13 +36,13 @@ module QA testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347608' ) do expect_import_finished + expect(imported_issues.count).to eq(1) 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]) + expect(imported_comments.first&.fetch(:body)).to include(source_comment[:body]) 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 index 9dce9bff3c1..d656ea4dea5 100644 --- 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 @@ -3,12 +3,8 @@ 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 + RSpec.describe 'Manage' do + describe 'Gitlab migration' do include_context 'with gitlab project migration' context 'with merge request' do @@ -33,7 +29,8 @@ module QA 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_comments) { imported_mr.comments.map { |note| note.except(:id, :noteable_id) } } + let(:source_mr_comments) { source_mr.comments.map { |note| note.except(:id, :noteable_id) } } let(:imported_mr) do Resource::MergeRequest.init do |mr| @@ -52,17 +49,12 @@ module QA testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478' ) do expect_import_finished + expect(imported_mrs.count).to eq(1) 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).to eq(source_mr.reload!) - 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) + expect(imported_mr_comments).to eq(source_mr_comments) 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 index a0c758c99e6..421dbe56a99 100644 --- 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 @@ -3,12 +3,8 @@ 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 + RSpec.describe 'Manage' do + describe 'Gitlab migration' do include_context 'with gitlab project migration' context 'with uninitialized project' do 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 index 827ebc1f5e2..b7f0a10c525 100644 --- 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 @@ -1,7 +1,13 @@ # frozen_string_literal: true module QA - RSpec.shared_context 'with gitlab project migration' do + # Disable on staging until bulk_import_projects toggle is on by default + # Otherwise tests running in parallel can disable feature in the middle of other test + RSpec.shared_context 'with gitlab project migration', :requires_admin, except: { subdomain: :staging }, quarantine: { + only: { job: 'praefect' }, + type: :investigating, + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/348999' + } 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 } diff --git a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb index 13a795ca976..6480b880400 100644 --- a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb +++ b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb @@ -78,11 +78,6 @@ module QA @different_project.remove_via_api! end end - - after(:all) do - @project_access_token.remove_via_api! - @project_access_token.project.remove_via_api! - end 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 6a31d173440..fe6c89f4ee4 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 @@ -31,44 +31,50 @@ module QA end it 'is not allowed to push code via the CLI', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347863' do - expect do - Resource::Repository::Push.fabricate! do |push| - push.repository_http_uri = @project.repository_http_location.uri - 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_#{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/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::Repository::Push.fabricate! do |push| + push.repository_http_uri = @project.repository_http_location.uri + 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_#{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/) + end end it 'is not allowed to create a file via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347864' do - expect do - Resource::File.fabricate_via_api! do |file| - file.api_client = @user_api_client - file.project = @project - file.branch = "new_branch_#{SecureRandom.hex(8)}" - file.commit_message = 'Add new file' - file.name = 'test.txt' - file.content = "New file" - end - end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::File.fabricate_via_api! do |file| + file.api_client = @user_api_client + file.project = @project + file.branch = "new_branch_#{SecureRandom.hex(8)}" + file.commit_message = 'Add new file' + file.name = 'test.txt' + file.content = "New file" + end + end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden/) + end end it 'is not allowed to commit via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347865' do - expect do - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.api_client = @user_api_client - commit.project = @project - commit.branch = "new_branch_#{SecureRandom.hex(8)}" - commit.start_branch = @project.default_branch - commit.commit_message = 'Add new file' - commit.add_files([ - { file_path: 'test.txt', content: 'new file' } - ]) - end - end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden - You are not allowed to push into this branch/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.api_client = @user_api_client + commit.project = @project + commit.branch = "new_branch_#{SecureRandom.hex(8)}" + commit.start_branch = @project.default_branch + commit.commit_message = 'Add new file' + commit.add_files([ + { file_path: 'test.txt', content: 'new file' } + ]) + end + end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden - You are not allowed to push into this branch/) + end end end diff --git a/qa/qa/specs/features/api/3_create/gitaly/automatic_failover_and_recovery_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/automatic_failover_and_recovery_spec.rb index 6a9be19efdd..55ae0d215cf 100644 --- a/qa/qa/specs/features/api/3_create/gitaly/automatic_failover_and_recovery_spec.rb +++ b/qa/qa/specs/features/api/3_create/gitaly/automatic_failover_and_recovery_spec.rb @@ -9,37 +9,30 @@ module QA project = nil let(:intial_commit_message) { 'Initial commit' } - let(:first_added_commit_message) { 'pushed to primary gitaly node' } - let(:second_added_commit_message) { 'commit to failover node' } + let(:first_added_commit_message) { 'first_added_commit_message to primary gitaly node' } + let(:second_added_commit_message) { 'second_added_commit_message to failover node' } before(:context) do - # Reset the cluster in case previous tests left it in a bad state praefect_manager.start_all_nodes project = Resource::Project.fabricate! do |project| project.name = "gitaly_cluster" project.initialize_with_readme = true end - end - - after do - praefect_manager.start_all_nodes + # We need to ensure that the the project is replicated to all nodes before proceeding with this test + praefect_manager.wait_for_replication(project.id) end it 'automatically fails over', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347830' do - # Create a new project with a commit and wait for it to replicate - - # make sure that our project is published to the 'primary' node + # stop other nodes, so we can control which node the commit is sent to praefect_manager.stop_secondary_node praefect_manager.stop_tertiary_node - praefect_manager.wait_for_secondary_node_health_check_failure - praefect_manager.wait_for_tertiary_node_health_check_failure Resource::Repository::ProjectPush.fabricate! do |push| push.project = project push.commit_message = first_added_commit_message push.new_branch = false - push.file_content = "This should exist on all nodes" + push.file_content = 'This file created on gitaly1 while gitaly2/gitaly3 not running' end praefect_manager.start_all_nodes @@ -56,7 +49,7 @@ module QA commit.add_files([ { file_path: "file-#{SecureRandom.hex(8)}", - content: 'This should exist on one node before reconciliation' + content: 'This is created on gitaly2/gitaly3 while gitaly1 is unavailable' } ]) end diff --git a/qa/qa/specs/features/api/3_create/gitaly/praefect_dataloss_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/praefect_dataloss_spec.rb new file mode 100644 index 00000000000..6e2a34afb3e --- /dev/null +++ b/qa/qa/specs/features/api/3_create/gitaly/praefect_dataloss_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + context 'Praefect dataloss commands', :orchestrated, :gitaly_cluster do + let(:praefect_manager) { Service::PraefectManager.new } + + let(:project) do + Resource::Project.fabricate! do |project| + project.name = 'gitaly_cluster-dataloss-project' + project.initialize_with_readme = true + end + end + + before do + praefect_manager.start_all_nodes + end + + it 'confirms that changes are synced across all storages', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/352691' do + expect { praefect_manager.praefect_dataloss_information(project.id) } + .to(eventually_include('All repositories are fully available on all assigned storages!') + .within(max_duration: 60)) + end + + it 'identifies how many changes are not in sync across storages', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/352692' do + # Ensure our test repository is replicated and in a consistent state prior to test + praefect_manager.wait_for_project_synced_across_all_storages(project.id) + + # testing for gitaly2 'out of sync' + praefect_manager.stop_secondary_node + + number_of_changes = 3 + 1.upto(number_of_changes) do |i| + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.branch = "newbranch-#{SecureRandom.hex(8)}" + commit.start_branch = project.default_branch + commit.commit_message = 'Add new file' + commit.add_files([ + { file_path: "new_file-#{SecureRandom.hex(8)}.txt", content: 'new file' } + ]) + end + end + + # testing for gitaly3 'in sync' but marked unhealthy + praefect_manager.stop_tertiary_node + + project_data_loss = praefect_manager.praefect_dataloss_information(project.id) + aggregate_failures "validate dataloss identified" do + expect(project_data_loss).to include('gitaly1, assigned host') + expect(project_data_loss).to include("gitaly2 is behind by #{number_of_changes} changes or less, assigned host, unhealthy") + expect(project_data_loss).to include('gitaly3, assigned host, unhealthy') + end + end + end + end +end 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 e7e23124312..d066953d12e 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/346453', type: :flaky } 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| @@ -15,12 +15,10 @@ module QA before do praefect_manager.start_all_nodes - praefect_manager.start_praefect end after do praefect_manager.start_all_nodes - praefect_manager.start_praefect praefect_manager.clear_replication_queue end diff --git a/qa/qa/specs/features/api/3_create/integrations/webhook_events_spec.rb b/qa/qa/specs/features/api/3_create/integrations/webhook_events_spec.rb new file mode 100644 index 00000000000..7a277d754c9 --- /dev/null +++ b/qa/qa/specs/features/api/3_create/integrations/webhook_events_spec.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'WebHooks integration', :requires_admin, :integrations, :orchestrated do + before(:context) do + toggle_local_requests(true) + end + + after(:context) do + Vendor::Smocker::SmockerApi.teardown! + end + + let(:session) { SecureRandom.hex(5) } + + it 'sends a push event', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348945' do + setup_webhook(push: true) do |webhook, smocker| + Resource::Repository::ProjectPush.fabricate! do |project_push| + project_push.project = webhook.project + end + + wait_until do + !smocker.history(session).empty? + end + + events = smocker.history(session).map(&:as_hook_event) + aggregate_failures do + expect(events.size).to be(1), "Should have 1 event: \n#{events.map(&:raw).join("\n")}" + expect(events[0].project_name).to eql(webhook.project.name) + expect(events[0].push?).to be(true), "Not push event: \n#{events[0].raw}" + end + end + end + + it 'sends a merge request event', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/349720' do + setup_webhook(merge_requests: true) do |webhook, smocker| + Resource::MergeRequest.fabricate_via_api! do |merge_request| + merge_request.project = webhook.project + end + + wait_until do + !smocker.history(session).empty? + end + + events = smocker.history(session).map(&:as_hook_event) + aggregate_failures do + expect(events.size).to be(1), "Should have 1 event: \n#{events.map(&:raw).join("\n")}" + expect(events[0].project_name).to eql(webhook.project.name) + expect(events[0].mr?).to be(true), "Not MR event: \n#{events[0].raw}" + end + end + end + + it 'sends a wiki page event', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/349722' do + setup_webhook(wiki_page: true) do |webhook, smocker| + Resource::Wiki::ProjectPage.fabricate_via_api! do |page| + page.project = webhook.project + end + + wait_until do + !smocker.history(session).empty? + end + + events = smocker.history(session).map(&:as_hook_event) + aggregate_failures do + expect(events.size).to be(1), "Should have 1 event: \n#{events.map(&:raw).join("\n")}" + expect(events[0].project_name).to eql(webhook.project.name) + expect(events[0].wiki?).to be(true), "Not wiki event: \n#{events[0].raw}" + end + end + end + + it 'sends an issues and note event', 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/349723' do + setup_webhook(issues: true, note: true) do |webhook, smocker| + issue = Resource::Issue.fabricate_via_api! do |issue_init| + issue_init.project = webhook.project + end + + Resource::ProjectIssueNote.fabricate_via_api! do |note| + note.project = issue.project + note.issue = issue + end + + wait_until do + smocker.history(session).size > 1 + end + + events = smocker.history(session).map(&:as_hook_event) + aggregate_failures do + issue_event = events.find(&:issue?) + note_event = events.find(&:note?) + + expect(events.size).to be(2), "Should have 2 events: \n#{events.map(&:raw).join("\n")}" + expect(issue_event).not_to be(nil), "Not issue event: \n#{events[0].raw}" + expect(note_event).not_to be(nil), "Not note event: \n#{events[1].raw}" + end + end + end + + private + + def setup_webhook(**event_args) + Vendor::Smocker::SmockerApi.init(wait: 10) do |smocker| + smocker.register(session: session) + + webhook = Resource::ProjectWebHook.fabricate_via_api! do |hook| + hook.url = smocker.url + + event_args.each do |event, bool| + hook.send("#{event}_events=", bool) + end + end + + yield(webhook, smocker) + + smocker.reset + end + end + + def toggle_local_requests(on) + Runtime::ApplicationSettings.set_application_settings(allow_local_requests_from_web_hooks_and_services: on) + end + + def wait_until(timeout = 120, &block) + Support::Waiter.wait_until(max_duration: timeout, reload_page: false, raise_on_failure: false, &block) + end + end + end +end 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 83dcb163d56..6eb3060fb59 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 @@ -68,9 +68,10 @@ module QA mr.iid = merge_request[:iid] end - expect(merge_request.state).to eq('opened') - expect(merge_request.merge_status).to eq('checking') - expect(merge_request.merge_when_pipeline_succeeds).to be true + aggregate_failures do + expect(merge_request.state).to eq('opened') + expect(merge_request.merge_when_pipeline_succeeds).to be true + end end it 'merges when pipeline succeeds', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347842' do |