diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /qa/qa/specs | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) | |
download | gitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'qa/qa/specs')
38 files changed, 616 insertions, 347 deletions
diff --git a/qa/qa/specs/features/api/1_manage/import/import_github_repo_spec.rb b/qa/qa/specs/features/api/1_manage/import/import_github_repo_spec.rb index a10e95a860c..9017aba8e4a 100644 --- a/qa/qa/specs/features/api/1_manage/import/import_github_repo_spec.rb +++ b/qa/qa/specs/features/api/1_manage/import/import_github_repo_spec.rb @@ -3,7 +3,10 @@ module QA # https://github.com/gitlab-qa-github/import-test <- project under test # - RSpec.describe 'Manage', product_group: :import do + RSpec.describe 'Manage', product_group: :import, quarantine: { + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391228', + type: :waiting_on + } do describe 'GitHub import' do include_context 'with github import' diff --git a/qa/qa/specs/features/api/1_manage/integrations/webhook_events_spec.rb b/qa/qa/specs/features/api/1_manage/integrations/webhook_events_spec.rb index fb530967073..8439b881ed7 100644 --- a/qa/qa/specs/features/api/1_manage/integrations/webhook_events_spec.rb +++ b/qa/qa/specs/features/api/1_manage/integrations/webhook_events_spec.rb @@ -125,11 +125,48 @@ module QA end end + context 'when hook fails' do + let(:fail_mock) do + <<~YAML + - request: + method: POST + path: /default + response: + status: 404 + headers: + Content-Type: text/plain + body: 'webhook failed' + YAML + end + + let(:hook_trigger_times) { 5 } + let(:disabled_after) { 4 } + + it 'hook is auto-disabled', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595' do + setup_webhook(fail_mock, issues: true) do |webhook, smocker| + hook_trigger_times.times do + Resource::Issue.fabricate_via_api! do |issue_init| + issue_init.project = webhook.project + end + end + + expect { smocker.history(session).size }.to eventually_eq(disabled_after) + .within(max_duration: 30, sleep_interval: 2), + -> { "Should have #{disabled_after} events, got: #{smocker.history(session).size}" } + + webhook.reload! + + expect(webhook.alert_status).to eql('disabled') + end + end + end + private - def setup_webhook(**event_args) + def setup_webhook(mock = Vendor::Smocker::SmockerApi::DEFAULT_MOCK, **event_args) Service::DockerRun::Smocker.init(wait: 10) do |smocker| - smocker.register(session: session) + smocker.register(mock, session: session) webhook = Resource::ProjectWebHook.fabricate_via_api! do |hook| hook.url = smocker.url 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 052e3d0e32d..2dcbbadb4aa 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 @@ -78,18 +78,12 @@ module QA end end - # we can't fabricate things in source instance via UI - context "with designs", quarantine: { - type: :broken, - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/366592' - } do + context "with designs" do let!(:source_design) do - Flow::Login.sign_in(as: user) - - Resource::Design.fabricate_via_browser_ui! do |design| - design.api_client = api_client + Resource::Design.fabricate! do |design| + design.api_client = source_admin_api_client design.issue = source_issue - end.reload! + end end let(:imported_design) do diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_members_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_members_spec.rb index 7fe11c3bafe..42793406e6c 100644 --- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_members_spec.rb +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_members_spec.rb @@ -19,11 +19,11 @@ module QA end let(:imported_group_member) do - imported_group.reload!.list_members.find { |usr| usr['username'] == target_member.username } + imported_group.reload!.list_members.find { |usr| usr[:username] == target_member.username } end let(:imported_project_member) do - imported_project.reload!.list_members.find { |usr| usr['username'] == target_member.username } + imported_project.reload!.list_members.find { |usr| usr[:username] == target_member.username } end context 'with group member' do @@ -39,9 +39,7 @@ module QA aggregate_failures do expect(imported_project_member).to be_nil - expect(imported_group_member&.fetch('access_level')).to eq( - Resource::Members::AccessLevel::DEVELOPER - ) + expect(imported_group_member&.fetch(:access_level)).to eq(Resource::Members::AccessLevel::DEVELOPER) end end end @@ -59,9 +57,7 @@ module QA aggregate_failures do expect(imported_group_member).to be_nil - expect(imported_project_member&.fetch('access_level')).to eq( - Resource::Members::AccessLevel::DEVELOPER - ) + expect(imported_project_member&.fetch(:access_level)).to eq(Resource::Members::AccessLevel::DEVELOPER) 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 9f6b1d38bd7..60ece89844d 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 @@ -24,7 +24,7 @@ module QA group.api_client = admin_api_client group.sandbox = source_sandbox group.path = "source-group-for-import-#{SecureRandom.hex(4)}" - group.avatar = File.new('qa/fixtures/designs/tanuki.jpg', 'r') + group.avatar = File.new(File.join(Runtime::Path.fixtures_path, 'designs', 'tanuki.jpg'), 'r') end end diff --git a/qa/qa/specs/features/api/1_manage/user_inherited_access_spec.rb b/qa/qa/specs/features/api/1_manage/user_inherited_access_spec.rb index ad1abe6e5e9..124b6c9cd44 100644 --- a/qa/qa/specs/features/api/1_manage/user_inherited_access_spec.rb +++ b/qa/qa/specs/features/api/1_manage/user_inherited_access_spec.rb @@ -5,9 +5,16 @@ module QA describe 'User', :requires_admin, product_group: :organization do let(:admin_api_client) { Runtime::API::Client.as_admin } + let!(:parent_group) do + QA::Resource::Group.fabricate_via_api! do |group| + group.path = "parent-group-to-test-user-access-#{SecureRandom.hex(8)}" + end + end + let!(:sub_group) do QA::Resource::Group.fabricate_via_api! do |group| group.path = "sub-group-to-test-user-access-#{SecureRandom.hex(8)}" + group.sandbox = parent_group end end @@ -31,7 +38,7 @@ module QA end before do - sub_group.sandbox.add_member(parent_group_user) + parent_group.add_member(parent_group_user) end it( @@ -89,16 +96,14 @@ module QA after do parent_group_user.remove_via_api! - sub_group_project.remove_via_api! - sub_group.remove_via_api! end end context 'when added to sub-group' do let!(:parent_group_project) do Resource::Project.fabricate_via_api! do |project| - project.group = sub_group.sandbox - project.name = "sub-group-project-to-test-user-access" + project.group = parent_group + project.name = "parent-group-project-to-test-user-access" project.initialize_with_readme = true end end @@ -170,8 +175,6 @@ module QA after do sub_group_user.remove_via_api! - parent_group_project.remove_via_api! - sub_group.remove_via_api! end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/group_member_access_request_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/group_member_access_request_spec.rb new file mode 100644 index 00000000000..3a84646977f --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/group/group_member_access_request_spec.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Manage', :requires_admin, product_group: :organization do + describe 'Group member access request' do + let!(:admin_api_client) { Runtime::API::Client.as_admin } + + let!(:user) do + Resource::User.fabricate_via_api! do |user| + user.api_client = admin_api_client + end + end + + let!(:group) do + Resource::Group.fabricate_via_api! do |group| + group.path = "group-for-access-request-#{SecureRandom.hex(8)}" + group.api_client = admin_api_client + end + end + + before do + Flow::Login.sign_in(as: user) + group.visit! + + Page::Group::Show.perform(&:click_request_access) + + Flow::Login.sign_in_as_admin + + Page::Main::Menu.perform do |menu| + menu.go_to_page_by_shortcut(:todos_shortcut_button) + end + + Page::Dashboard::Todos.perform do |todos| + todos.filter_todos_by_group(group) + end + end + + after do + user&.remove_via_api! + end + + it 'generates a todo item for the group owner', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/370132' do + Page::Dashboard::Todos.perform do |todos| + expect(todos).to have_latest_todo_with_author( + author: user.name, + action: "has requested access to group #{group.path}" + ) + end + end + + context 'when managing requests as the group owner' do + before do + Page::Dashboard::Todos.perform do |todos| + todos.click_todo_with_content(group.name) + end + end + + context 'and request is accepted' do + before do + Page::Group::Members.perform do |members| + members.approve_access_request(user.username) + end + end + + it 'adds user to the group', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/386792' do + found_member = group.reload!.find_member(user.username) + + expect(found_member).not_to be_nil + expect(found_member.fetch(:access_level)) + .to eq(Resource::Members::AccessLevel::DEVELOPER) + end + end + + context 'and request is denied' do + before do + Page::Group::Members.perform do |members| + members.deny_access_request(user.username) + end + end + + it 'does not add user to the group', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/386793' do + found_member = group.reload!.find_member(user.username) + + expect(found_member).to be_nil + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/1_manage/import/import_github_repo_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/import/import_github_repo_spec.rb index 43a8af93e27..461928cbf1f 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/import/import_github_repo_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/import/import_github_repo_spec.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true module QA - RSpec.describe 'Manage', product_group: :import do + RSpec.describe 'Manage', product_group: :import, quarantine: { + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391230', + type: :waiting_on + } do describe 'GitHub import' do include_context 'with github import' @@ -49,9 +52,9 @@ module QA aggregate_failures do expect(import_page).to have_imported_project(github_repo, wait: 240) - # validate button is present instead of navigating to avoid dealing with multiple tabs + # validate link is present instead of navigating to avoid dealing with multiple tabs # which makes the test more complicated - expect(import_page).to have_go_to_project_button(github_repo) + expect(import_page).to have_go_to_project_link(github_repo) end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb index e0242008785..3f5842d756e 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb @@ -5,7 +5,9 @@ module QA it 'allows the user to register and login' do Runtime::Browser.visit(:gitlab, Page::Main::Login) - Resource::User.fabricate_via_browser_ui! + Resource::User.fabricate_via_browser_ui! do |user_resource| + user_resource.email_domain = 'gitlab.com' + end Page::Main::Menu.perform do |menu| expect(menu).to have_personal_area @@ -65,8 +67,7 @@ module QA show.delete_account(user.password) end - # TODO: Remove retry_on_exception once https://gitlab.com/gitlab-org/gitlab/-/issues/24294 is resolved - Support::Waiter.wait_until(max_duration: 120, retry_on_exception: true, sleep_interval: 3) { !user.exists? } + Support::Waiter.wait_until(max_duration: 120, sleep_interval: 3) { !user.exists? } end it 'allows recreating with same credentials', :reliable, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347868' do diff --git a/qa/qa/specs/features/browser_ui/1_manage/user/user_inherited_access_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/user/user_inherited_access_spec.rb index 9bb08cb66bc..c57900efe35 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/user/user_inherited_access_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/user/user_inherited_access_spec.rb @@ -5,9 +5,16 @@ module QA describe 'User', :requires_admin, product_group: :organization do let(:admin_api_client) { Runtime::API::Client.as_admin } + let!(:parent_group) do + QA::Resource::Group.fabricate_via_api! do |group| + group.path = "parent-group-to-test-user-access-#{SecureRandom.hex(8)}" + end + end + let!(:sub_group) do QA::Resource::Group.fabricate_via_api! do |group| group.path = "sub-group-to-test-user-access-#{SecureRandom.hex(8)}" + group.sandbox = parent_group end end @@ -31,7 +38,7 @@ module QA end before do - sub_group.sandbox.add_member(parent_group_user) + parent_group.add_member(parent_group_user) end it( @@ -54,16 +61,14 @@ module QA after do parent_group_user.remove_via_api! - sub_group_project.remove_via_api! - sub_group.remove_via_api! end end context 'when added to sub-group' do let!(:parent_group_project) do Resource::Project.fabricate_via_api! do |project| - project.group = sub_group.sandbox - project.name = "sub-group-project-to-test-user-access" + project.group = parent_group + project.name = "parent-group-project-to-test-user-access" project.initialize_with_readme = true end end @@ -100,8 +105,6 @@ module QA after do sub_group_user.remove_via_api! - parent_group_project.remove_via_api! - sub_group.remove_via_api! end end end diff --git a/qa/qa/specs/features/browser_ui/2_plan/design_management/add_design_content_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/design_management/add_design_content_spec.rb index eaf43f04c4b..130006fe424 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/design_management/add_design_content_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/design_management/add_design_content_spec.rb @@ -5,7 +5,7 @@ module QA describe 'Design Management' do let(:issue) { Resource::Issue.fabricate_via_api! } let(:design_filename) { 'banana_sample.gif' } - let(:design) { File.absolute_path(File.join('qa', 'fixtures', 'designs', design_filename)) } + let(:design) { File.join(Runtime::Path.fixtures_path, 'designs', design_filename) } let(:annotation) { "This design is great!" } before do @@ -13,7 +13,7 @@ module QA end it 'user adds a design and annotates it', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347822' do + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347822' do issue.visit! Page::Project::Issue::Show.perform do |issue| diff --git a/qa/qa/specs/features/browser_ui/2_plan/email/trigger_email_notification_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/email/trigger_email_notification_spec.rb index b70590e65c8..4e9d74a5117 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/email/trigger_email_notification_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/email/trigger_email_notification_spec.rb @@ -45,7 +45,7 @@ module QA mailhog_data = JSON.parse(mailhog_response.body) total = mailhog_data.dig('total') subjects = mailhog_data.dig('items') - .map(&method(:mailhog_item_subject)) + .map { |item| mailhog_item_subject(item) } Runtime::Logger.debug(%Q[Total number of emails: #{total}]) Runtime::Logger.debug(%Q[Subjects:\n#{subjects.join("\n")}]) diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb index 45c3c264837..e2fd0ec9cef 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb @@ -60,7 +60,7 @@ module QA context 'when using attachments in comments', :object_storage do let(:png_file_name) { 'testfile.png' } let(:file_to_attach) do - File.absolute_path(File.join('qa', 'fixtures', 'designs', png_file_name)) + File.join(Runtime::Path.fixtures_path, 'designs', png_file_name) end before do diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/batch_suggestion_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/batch_suggestion_spec.rb index 829b7bab829..7b89b021d89 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/batch_suggestion_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/batch_suggestion_spec.rb @@ -2,7 +2,7 @@ module QA RSpec.describe 'Create', :reliable, product_group: :code_review do - context 'Add batch suggestions to a Merge Request' do + context 'with merge request batch suggestions' do let(:project) do Resource::Project.fabricate_via_api! do |project| project.name = 'suggestions_project' @@ -15,9 +15,7 @@ module QA merge_request.title = 'Needs some suggestions' merge_request.description = '... so please add them.' merge_request.file_content = File.read( - Pathname - .new(__dir__) - .join('../../../../../../fixtures/metrics_dashboards/templating.yml') + File.join(Runtime::Path.fixtures_path, 'metrics_dashboards', 'templating.yml') ) end end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/custom_commit_suggestion_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/custom_commit_suggestion_spec.rb index 433ef90d9aa..499d4c00384 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/custom_commit_suggestion_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/suggestions/custom_commit_suggestion_spec.rb @@ -2,7 +2,7 @@ module QA RSpec.describe 'Create' do - context 'Add suggestions to a Merge Request', product_group: :code_review do + context 'with merge request suggestions', product_group: :code_review do let(:commit_message) { 'Applying suggested change for testing purposes.' } let(:project) do @@ -17,9 +17,7 @@ module QA merge_request.title = 'Needs some suggestions' merge_request.description = '... so please add them.' merge_request.file_content = File.read( - Pathname - .new(__dir__) - .join('../../../../../../fixtures/metrics_dashboards/templating.yml') + File.join(Runtime::Path.fixtures_path, 'metrics_dashboards', 'templating.yml') ) end end @@ -43,7 +41,8 @@ module QA merge_request.visit! end - it 'applies a single suggestion with a custom message', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347711' do + it 'applies a single suggestion with a custom message', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347711' do Page::MergeRequest::Show.perform do |merge_request| merge_request.click_diffs_tab merge_request.apply_suggestion_with_message(commit_message) diff --git a/qa/qa/specs/features/browser_ui/3_create/project_wiki/project_based_file_upload_spec.rb b/qa/qa/specs/features/browser_ui/3_create/project_wiki/project_based_file_upload_spec.rb index fbe662341c0..c782139823e 100644 --- a/qa/qa/specs/features/browser_ui/3_create/project_wiki/project_based_file_upload_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/project_wiki/project_based_file_upload_spec.rb @@ -17,7 +17,7 @@ module QA end it 'by creating a formatted page with an image uploaded', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347640' do + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347640' do initial_wiki.visit! Page::Project::Wiki::Show.perform(&:click_new_page) @@ -26,7 +26,7 @@ module QA edit.set_title(page_title) edit.use_new_editor edit.add_heading('Heading 1', heading_text) - edit.upload_image(File.absolute_path(File.join('qa', 'fixtures', 'designs', image_file_name))) + edit.upload_image(File.join(Runtime::Path.fixtures_path, 'designs', image_file_name)) end Page::Project::Wiki::Edit.perform(&:click_submit) diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb index 50df8afafaf..86a9f2c46fb 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb @@ -11,7 +11,7 @@ module QA shared_examples 'project license detection' do it 'displays the name of the license on the repository' do - license_path = File.expand_path("../../../../../fixtures/software_licenses/#{license_file_name}", __dir__) + license_path = File.join(Runtime::Path.fixtures_path, 'software_licenses', license_file_name) Resource::Repository::Commit.fabricate_via_api! do |commit| commit.project = project commit.add_files([{ file_path: 'LICENSE', content: File.read(license_path) }]) diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb index 8c171e6bc8c..080832990c9 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb @@ -2,14 +2,14 @@ module QA RSpec.describe 'Create', :skip_live_env, except: { job: 'review-qa-*' }, - feature_flag: { name: 'vscode_web_ide', scope: :global }, - product_group: :editor, - quarantine: { - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/387928', - type: :stale - } do + feature_flag: { name: 'vscode_web_ide', scope: :global }, + product_group: :editor, + quarantine: { + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/387928', + type: :stale + } do describe 'Git Server Hooks' do - let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', 'README.md')) } + let(:file_path) { File.join(Runtime::Path.fixtures_path, 'web_ide', 'README.md') } let(:project) do Resource::Project.fabricate_via_api! do |project| @@ -29,9 +29,9 @@ module QA Runtime::Feature.enable(:vscode_web_ide) end - context 'Custom error messages' do + context 'with custom error messages' do it 'renders preconfigured error message when user hook failed on commit in WebIDE', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/364751' do + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/364751' do Page::Project::Show.perform(&:open_web_ide_via_shortcut) Page::Project::WebIDE::Edit.perform do |ide| ide.wait_until_ide_loads diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb index 781623d10f6..b83a95694de 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :global }, product_group: :editor, quarantine: { - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/387032', - type: :stale - } do + RSpec.describe 'Create', product_group: :editor, + feature_flag: { name: 'vscode_web_ide', scope: :global }, + quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/387032', type: :stale } do describe 'Upload a file in Web IDE' do - let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', file_name)) } + let(:file_path) { File.join(Runtime::Path.fixtures_path, 'web_ide', file_name) } let(:project) do Resource::Project.fabricate_via_api! do |project| @@ -43,7 +42,8 @@ module QA context 'when the file is a text file' do let(:file_name) { 'text_file.txt' } - it 'shows the Edit tab with the text', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347852' do + it 'shows the Edit tab with the text', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347852' do Page::Project::WebIDE::Edit.perform do |ide| ide.wait_until_ide_loads ide.upload_file(file_path) diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb deleted file mode 100644 index 599c34ed3db..00000000000 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb +++ /dev/null @@ -1,103 +0,0 @@ -# frozen_string_literal: true - -module QA - RSpec.describe( - 'Create', - :runner, - # TODO: remove limitation to only run on main when the bug is fixed - only: { pipeline: :main }, - quarantine: { - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338179', - type: :bug - }, - feature_flag: { name: 'vscode_web_ide', scope: :global }, - product_group: :editor - ) do - describe 'Web IDE web terminal' do - before do - Runtime::Feature.disable(:vscode_web_ide) - project = Resource::Project.fabricate_via_api! do |project| - project.name = 'web-terminal-project' - end - - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.project = project - commit.commit_message = 'Add .gitlab/.gitlab-webide.yml' - commit.add_files( - [ - { - file_path: '.gitlab/.gitlab-webide.yml', - content: <<~YAML - terminal: - tags: ["web-ide"] - script: sleep 60 - YAML - } - ] - ) - end - - @runner = Resource::ProjectRunner.fabricate_via_api! do |runner| - runner.project = project - runner.name = "qa-runner-#{Time.now.to_i}" - runner.tags = %w[web-ide] - runner.image = 'gitlab/gitlab-runner:latest' - runner.config = <<~END - concurrent = 1 - - [session_server] - listen_address = "0.0.0.0:8093" - advertise_address = "localhost:8093" - session_timeout = 120 - END - end - - Flow::Login.sign_in - - project.visit! - end - - after do - Runtime::Feature.enable(:vscode_web_ide) - @runner.remove_via_api! if @runner - end - - it 'user starts the web terminal', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347737' do - Page::Project::Show.perform(&:open_web_ide!) - - # Start the web terminal and check that there were no errors - # The terminal screen is a canvas element, so we can't read its content, - # so we infer that it's working if: - # a) The terminal JS package has loaded, and - # b) It's not stuck in a "Loading/Starting" state, and - # c) There's no alert stating there was a problem - # d) There are no JS console errors - # - # The terminal itself is a third-party package so we assume it is - # adequately tested elsewhere. - # - # There are also FE specs - # * spec/frontend/ide/components/terminal/terminal_controls_spec.js - Page::Project::WebIDE::Edit.perform do |edit| - edit.wait_until_ide_loads - edit.start_web_terminal - - expect(edit).to have_no_alert - expect(edit).to have_finished_loading - expect(edit).to have_terminal_screen - end - - # It takes a few seconds for console errors to appear - sleep 3 - - errors = page.driver.browser.logs.get(:browser) - .select { |e| e.level == "SEVERE" } - .to_a - - if errors.present? - raise("Console error(s):\n#{errors.join("\n\n")}") - end - end - end - end -end diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb index ddd91f97515..379499662c2 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb @@ -2,7 +2,7 @@ module QA RSpec.describe 'Verify', :runner, product_group: :pipeline_execution do - context 'When pipeline is blocked' do + context 'when pipeline is blocked' do let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" } let(:project) do diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/mr_event_rule_pipeline_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/mr_event_rule_pipeline_spec.rb deleted file mode 100644 index 5dff2db6f2b..00000000000 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/mr_event_rule_pipeline_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -# frozen_string_literal: true - -module QA - RSpec.describe 'Verify', :runner, product_group: :pipeline_authoring do - context 'when job is configured to only run on merge_request_events' do - let(:mr_only_job_name) { 'mr_only_job' } - let(:non_mr_only_job_name) { 'non_mr_only_job' } - let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" } - - let(:project) do - Resource::Project.fabricate_via_api! do |project| - project.name = 'merge-request-only-job' - end - end - - let!(:runner) do - Resource::ProjectRunner.fabricate! do |runner| - runner.project = project - runner.name = executor - runner.tags = [executor] - end - end - - let!(:ci_file) do - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.project = project - commit.commit_message = 'Add .gitlab-ci.yml' - commit.add_files( - [ - { - file_path: '.gitlab-ci.yml', - content: <<~YAML - #{mr_only_job_name}: - tags: ["#{executor}"] - script: echo 'OK' - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - #{non_mr_only_job_name}: - tags: ["#{executor}"] - script: echo 'OK' - rules: - - if: '$CI_PIPELINE_SOURCE != "merge_request_event"' - YAML - } - ] - ) - end - end - - let(:merge_request) do - Resource::MergeRequest.fabricate_via_api! do |merge_request| - merge_request.project = project - merge_request.description = Faker::Lorem.sentence - merge_request.target_new_branch = false - merge_request.file_name = 'new.txt' - merge_request.file_content = Faker::Lorem.sentence - end - end - - before do - Flow::Login.sign_in - # TODO: We should remove (wait) revisiting logic when - # https://gitlab.com/gitlab-org/gitlab/-/issues/385332 is resolved - Support::Waiter.wait_until do - merge_request.visit! - Page::MergeRequest::Show.perform(&:click_pipeline_link) - Page::Project::Pipeline::Show.perform(&:has_merge_request_badge_tag?) - end - end - - after do - runner.remove_via_api! - end - - it 'only runs the job configured to run on merge requests', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347662' do - Page::Project::Pipeline::Show.perform do |pipeline| - aggregate_failures do - expect(pipeline).to have_job(mr_only_job_name) - expect(pipeline).to have_no_job(non_mr_only_job_name) - end - end - end - end - end -end diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb index 4294235a8b1..37d1e20111d 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb @@ -29,6 +29,9 @@ module QA { file_path: '.gitlab-ci.yml', content: <<~YAML + default: + tags: ["#{executor}"] + stages: - Stage1 - Stage2 @@ -36,26 +39,22 @@ module QA Prep: stage: Stage1 - tags: ["#{executor}"] script: exit 0 when: manual Build: stage: Stage2 - tags: ["#{executor}"] needs: ['Prep'] script: exit 0 parallel: 6 Test: stage: Stage3 - tags: ["#{executor}"] needs: ['Build'] script: exit 0 Deploy: stage: Stage3 - tags: ["#{executor}"] needs: ['Test'] script: exit 0 parallel: 6 @@ -67,6 +66,8 @@ module QA end before do + make_sure_to_have_a_skipped_pipeline + Flow::Login.sign_in project.visit! Flow::Pipeline.visit_latest_pipeline(status: 'skipped') @@ -84,7 +85,7 @@ module QA show.click_job_action('Prep') # Trigger pipeline manually show.wait_until(max_duration: 300, sleep_interval: 2, reload: false) do - project.pipelines.last[:status] == 'success' + project.latest_pipeline[:status] == 'success' end aggregate_failures do @@ -99,6 +100,50 @@ module QA end end end + + private + + # Wait for first pipeline to finish and have "skipped" status + # If it takes too long, create new pipeline and retry (2 times) + def make_sure_to_have_a_skipped_pipeline + attempts ||= 1 + Runtime::Logger.info('Waiting for pipeline to have status "skipped"...') + Support::Waiter.wait_until(max_duration: 120, sleep_interval: 3, retry_on_exception: true) do + project.latest_pipeline[:status] == 'skipped' + end + rescue Support::Repeater::WaitExceededError + raise 'Failed to create skipped pipeline after 3 attempts.' unless (attempts += 1) < 4 + + Runtime::Logger.debug( + "Previous pipeline took too long to finish. Potential jobs with problems:\n#{problematic_jobs}" + ) + Runtime::Logger.info("Triggering a new pipeline...") + trigger_new_pipeline + retry + end + + def trigger_new_pipeline + original_count = project.pipelines.length + Resource::Pipeline.fabricate_via_api! do |pipeline| + pipeline.project = project + end + + Support::Waiter.wait_until(sleep_interval: 1) { project.pipelines.length > original_count } + end + + # We know that all the jobs in pipeline are purposely skipped + # The pipeline should have status "skipped" almost right away after being created + # If pipeline is held up, likely because there are some jobs that + # doesn't have either "skipped" or "manual" status + def problematic_jobs + pipeline = Resource::Pipeline.fabricate_via_api! do |pipeline| + pipeline.project = project + pipeline.id = project.latest_pipeline[:id] + end + + acceptable_statuses = %w[skipped manual] + pipeline.pipeline_jobs.select { |job| !(acceptable_statuses.include? job[:status]) } + end end end end diff --git a/qa/qa/specs/features/browser_ui/4_verify/runner/register_group_runner_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/runner/register_group_runner_spec.rb new file mode 100644 index 00000000000..fba2f22b3e5 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/4_verify/runner/register_group_runner_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Verify', :runner, product_group: :runner do + describe 'Group runner registration' do + let(:executor) { "qa-runner-#{Time.now.to_i}" } + + let!(:runner) do + Resource::GroupRunner.fabricate! do |runner| + runner.name = executor + end + end + + after do + runner.remove_via_api! + end + + it( + 'user registers a new group runner', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/388740' + ) do + Flow::Login.sign_in + + runner.group.visit! + + Page::Group::Menu.perform(&:go_to_runners) + + expect(page).to have_content(executor) + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb index e141bac5e3f..4db935df43d 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb @@ -15,7 +15,7 @@ module QA runner.remove_via_api! end - it 'user registers a new specific runner', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348025' do + it 'user registers a new project runner', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348025' do Flow::Login.sign_in runner.project.visit! diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb index 800324afc58..ec07116550f 100644 --- a/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :skip_live_env, product_group: :container_registry do + RSpec.describe 'Package', :orchestrated, :skip_live_env, product_group: :container_registry, quarantine: { + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/390090', + type: :investigating + } do describe 'Self-managed Container Registry' do include Support::Helpers::MaskToken @@ -136,26 +139,30 @@ module QA Resource::Repository::Commit.fabricate_via_api! do |commit| commit.project = project commit.commit_message = 'Add .gitlab-ci.yml' - commit.add_files([{ - file_path: '.gitlab-ci.yml', - content: - <<~YAML - build: - image: "#{docker_client_version}" - stage: build - services: - - name: "#{docker_client_version}-dind" - command: ["--insecure-registry=gitlab.test:5050"] - variables: - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - script: - - docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050 - - docker build -t $IMAGE_TAG . - - docker push $IMAGE_TAG - tags: - - "runner-for-#{project.name}" - YAML - }]) + commit.add_files( + [ + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + build: + image: "#{docker_client_version}" + stage: build + services: + - name: "#{docker_client_version}-dind" + command: ["--insecure-registry=gitlab.test:5050"] + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050 + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG + tags: + - "runner-for-#{project.name}" + YAML + } + ] + ) end end @@ -181,39 +188,47 @@ module QA end end - context "when tls is enabled" do - it "pushes image and deletes tag", :registry_tls, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347591' do + context 'when tls is enabled' do + it( + 'pushes image and deletes tag', + :registry_tls, + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347591' + ) do Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do Resource::Repository::Commit.fabricate_via_api! do |commit| commit.project = project commit.commit_message = 'Add .gitlab-ci.yml' - commit.add_files([{ - file_path: '.gitlab-ci.yml', - content: - <<~YAML - build: - image: docker:19.03.12 - stage: build - services: - - name: docker:19.03.12-dind - command: - - /bin/sh - - -c - - | - apk add --no-cache openssl - true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt - update-ca-certificates - dockerd-entrypoint.sh || exit - variables: - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD gitlab.test:5050 - - docker build -t $IMAGE_TAG . - - docker push $IMAGE_TAG - tags: - - "runner-for-#{project.name}" - YAML - }]) + commit.add_files( + [ + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + build: + image: docker:19.03.12 + stage: build + services: + - name: docker:19.03.12-dind + command: + - /bin/sh + - -c + - | + apk add --no-cache openssl + true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt + update-ca-certificates + dockerd-entrypoint.sh || exit + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD gitlab.test:5050 + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG + tags: + - "runner-for-#{project.name}" + YAML + } + ] + ) end end diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb index 4c15b7c7f99..f95bcc59db1 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb @@ -43,7 +43,10 @@ module QA end end - it "pushes and pulls a helm chart", testcase: params[:testcase] do + it "pushes and pulls a helm chart", testcase: params[:testcase], quarantine: { + type: :stale, + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391649' + } do Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do Resource::Repository::Commit.fabricate_via_api! do |commit| helm_upload_yaml = ERB.new(read_fixture('package_managers/helm', 'helm_upload_package.yaml.erb')).result(binding) diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb index cda45efd828..3fb5c921187 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb @@ -41,7 +41,11 @@ module QA 'using a ci job token' => { authentication_token_type: :ci_job_token, maven_header_name: 'Job-Token', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347579' + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347579', + quarantine: { + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/373189', + type: :stale + } } } end @@ -60,7 +64,7 @@ module QA end end - it 'pushes and pulls a maven package', testcase: params[:testcase] do + it 'pushes and pulls a maven package', testcase: params[:testcase], quarantine: params[:quarantine] do Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do Resource::Repository::Commit.fabricate_via_api! do |commit| gitlab_ci_yaml = ERB.new(read_fixture('package_managers/maven/group/producer', 'gitlab_ci.yaml.erb')).result(binding) diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb index a9d66c93fac..d86ce09c4e1 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb @@ -31,7 +31,10 @@ module QA end end - it 'pushes and pulls a maven package via gradle', testcase: params[:testcase] do + it 'pushes and pulls a maven package via gradle', testcase: params[:testcase], quarantine: { + type: :stale, + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391650' + } do Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do Resource::Repository::Commit.fabricate_via_api! do |commit| gradle_upload_yaml = ERB.new(read_fixture('package_managers/maven/gradle', 'gradle_upload_package.yaml.erb')).result(binding) diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb index 0e1ac4d861d..c2cbec3fbb7 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb @@ -97,7 +97,10 @@ module QA end end - it 'publishes a nuget package at the project endpoint and installs it from the group endpoint', testcase: params[:testcase] do + it 'publishes a nuget package at the project endpoint and installs it from the group endpoint', testcase: params[:testcase], quarantine: { + type: :stale, + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391648' + } do Flow::Login.sign_in Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do @@ -133,14 +136,14 @@ module QA { file_path: 'otherdotnet.csproj', content: <<~EOF - <Project Sdk="Microsoft.NET.Sdk"> + <Project Sdk="Microsoft.NET.Sdk"> - <PropertyGroup> - <OutputType>Exe</OutputType> - <TargetFramework>net7.0</TargetFramework> - </PropertyGroup> + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net7.0</TargetFramework> + </PropertyGroup> - </Project> + </Project> EOF } ] diff --git a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/alert_settings_create_new_alerts_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/alert_settings_create_new_alerts_spec.rb index 2b7dd8fb673..b44020ddfce 100644 --- a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/alert_settings_create_new_alerts_spec.rb +++ b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/alert_settings_create_new_alerts_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Monitor', product_group: :respond do + RSpec.describe 'Monitor', :smoke, product_group: :respond do describe 'Alert settings' do shared_examples 'sends test alert' do it 'creates new alert' do @@ -24,6 +24,7 @@ module QA before do Flow::Login.sign_in project.visit! + Flow::AlertSettings.go_to_monitor_settings end context( @@ -35,7 +36,8 @@ module QA end before do - Flow::AlertSettings.setup_http_endpoint(payload: payload) + Flow::AlertSettings.setup_http_endpoint_integration + Flow::AlertSettings.send_test_alert(payload: payload) end it_behaves_like 'sends test alert' @@ -73,7 +75,8 @@ module QA end before do - Flow::AlertSettings.setup_prometheus(payload: payload) + Flow::AlertSettings.setup_prometheus_integration + Flow::AlertSettings.send_test_alert(payload: payload) end it_behaves_like 'sends test alert' diff --git a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/automatically_creates_incident_for_alert_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/automatically_creates_incident_for_alert_spec.rb new file mode 100644 index 00000000000..565f56b90ec --- /dev/null +++ b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/automatically_creates_incident_for_alert_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Monitor', product_group: :respond do + describe 'Alert' do + shared_examples 'new alert' do + it 'automatically creates new incident' do + Page::Project::Menu.perform(&:go_to_monitor_incidents) + Page::Project::Monitor::Incidents::Index.perform do |index| + expect(index).to have_incident + end + end + end + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-for-alerts' + project.description = 'Project for alerts' + end + end + + before do + Flow::Login.sign_in + project.visit! + Flow::AlertSettings.go_to_monitor_settings + Flow::AlertSettings.enable_create_incident + end + + context( + 'when using HTTP endpoint integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/388469' + ) do + before do + Flow::AlertSettings.setup_http_endpoint_integration + Flow::AlertSettings.send_test_alert + end + + it_behaves_like 'new alert' + end + + context( + 'when using Prometheus integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390123' + ) do + before do + Flow::AlertSettings.setup_prometheus_integration + Flow::AlertSettings.send_test_alert(integration_type: 'prometheus') + end + + it_behaves_like 'new alert' + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/create_alert_using_authorization_key_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/create_alert_using_authorization_key_spec.rb index 9d4aff59e48..96db10c1683 100644 --- a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/create_alert_using_authorization_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/create_alert_using_authorization_key_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Monitor', product_group: :respond do + RSpec.describe 'Monitor', :smoke, product_group: :respond do describe 'Alert settings' do shared_examples 'sends test alert using authorization key' do |type| it 'creates new alert', :aggregate_failures do @@ -22,7 +22,8 @@ module QA Page::Project::Menu.perform(&:go_to_monitor_alerts) Page::Project::Monitor::Alerts::Index.perform do |index| - expect(index).to have_alert_with_title(alert_title) + expect { index.has_alert_with_title?(alert_title) } + .to eventually_be_truthy.within(max_duration: 60, reload_page: index) end end end @@ -36,9 +37,14 @@ module QA let(:alert_title) { Faker::Lorem.word } + let(:credentials) do + Flow::AlertSettings.integration_credentials + end + before do Flow::Login.sign_in project.visit! + Flow::AlertSettings.go_to_monitor_settings end context( @@ -49,8 +55,8 @@ module QA { title: alert_title, description: alert_title } end - let(:credentials) do - Flow::AlertSettings.setup_http_endpoint(send: false) + before do + Flow::AlertSettings.setup_http_endpoint_integration end it_behaves_like 'sends test alert using authorization key', 'http' @@ -87,8 +93,8 @@ module QA } end - let(:credentials) do - Flow::AlertSettings.setup_prometheus(send: false) + before do + Flow::AlertSettings.setup_prometheus_integration end it_behaves_like 'sends test alert using authorization key' diff --git a/qa/qa/specs/features/browser_ui/8_monitor/alert_management/email_notification_for_alert_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/email_notification_for_alert_spec.rb new file mode 100644 index 00000000000..70874e46f27 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/8_monitor/alert_management/email_notification_for_alert_spec.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Monitor', :orchestrated, :smtp, :requires_admin, product_group: :respond do + describe 'Alert' do + shared_examples 'notification on new alert', :aggregate_failures do + it 'sends email to user' do + expect { email_subjects }.to eventually_include(alert_email_subject).within(max_duration: 60) + expect(recipient_email_addresses).to include(user.email) + end + end + + let!(:admin_api_client) { Runtime::API::Client.as_admin } + + let!(:user) do + Resource::User.fabricate_via_api! do |user| + user.api_client = admin_api_client + user.hard_delete_on_api_removal = true + end + end + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-for-alerts' + project.description = 'Project for alerts' + end + end + + let(:alert_title) { Faker::Lorem.word } + let(:mail_hog_api) { Vendor::MailHog::API.new } + let(:alert_email_subject) { "#{project.name} | Alert: #{alert_title}" } + let(:http_payload) { { title: alert_title, description: alert_title } } + + let(:prometheus_payload) do + { + version: '4', + groupKey: nil, + status: 'firing', + receiver: '', + groupLabels: {}, + commonLabels: {}, + commonAnnotations: {}, + externalURL: '', + alerts: [ + { + startsAt: Time.now, + generatorURL: Faker::Internet.url, + endsAt: nil, + status: 'firing', + labels: { gitlab_environment_name: Faker::Lorem.word }, + annotations: + { + title: alert_title, + gitlab_y_label: 'status' + } + } + ] + } + end + + before do + Flow::Login.sign_in + project.visit! + Flow::AlertSettings.go_to_monitor_settings + Flow::AlertSettings.enable_email_notification + end + + context 'when user is a maintainer' do + before do + project.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + end + + context( + 'when using HTTP endpoint integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389993' + ) do + before do + send_http_alert + end + + it_behaves_like 'notification on new alert' + end + + context( + 'when using Prometheus integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389994' + ) do + before do + send_prometheus_alert + end + + it_behaves_like 'notification on new alert' + end + end + + context 'when user is an owner' do + before do + project.add_member(user, Resource::Members::AccessLevel::OWNER) + end + + context( + 'when using HTTP endpoint integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390145' + ) do + before do + send_http_alert + end + + it_behaves_like 'notification on new alert' + end + + context( + 'when using Prometheus integration', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/390144' + ) do + before do + send_prometheus_alert + end + + it_behaves_like 'notification on new alert' + end + end + + private + + def send_http_alert + Flow::AlertSettings.setup_http_endpoint_integration + Flow::AlertSettings.send_test_alert(payload: http_payload) + end + + def send_prometheus_alert + Flow::AlertSettings.setup_prometheus_integration + Flow::AlertSettings.send_test_alert(payload: prometheus_payload) + end + + def mail_hog_messages + mail_hog_api.fetch_messages + end + + def email_subjects + mail_hog_messages.map(&:subject) + end + + def recipient_email_addresses + mail_hog_messages.map(&:to) + end + end + end +end diff --git a/qa/qa/specs/features/shared_contexts/advanced_search_shared_context.rb b/qa/qa/specs/features/shared_contexts/advanced_search_shared_context.rb index c6836d11803..805e5ce782a 100644 --- a/qa/qa/specs/features/shared_contexts/advanced_search_shared_context.rb +++ b/qa/qa/specs/features/shared_contexts/advanced_search_shared_context.rb @@ -8,18 +8,25 @@ module QA QA::EE::Resource::Settings::Elasticsearch.fabricate_via_api! unless advanced_search_on end - after do - Runtime::Search.disable_elasticsearch(api_client) if !advanced_search_on && !api_client.nil? - end + # TODO: convert check_advanced_search_status method to use the API instead of the UI once the functionality exists + # https://gitlab.com/gitlab-org/gitlab/-/issues/382849 and then we can resume turning off advanced search after the + # tests as in the `after` block here. For now the advanced search tests will have the side effect of turning on + # advanced search if it wasn't enabled before the tests run. + + # after do + # Runtime::Search.disable_elasticsearch(api_client) if !advanced_search_on && !api_client.nil? + # end - # TODO: convert this method to use the API instead of the UI once the functionality exists - # https://gitlab.com/gitlab-org/gitlab/-/issues/382849 def check_advanced_search_status Flow::Login.sign_in - QA::Page::Main::Menu.perform do |menu| - menu.search_for('lorem ipsum') + QA::Support::Retrier.retry_on_exception( + max_attempts: Runtime::Search::RETRY_MAX_ITERATION, + sleep_interval: Runtime::Search::RETRY_SLEEP_INTERVAL) do + QA::Page::Main::Menu.perform do |menu| + menu.search_for('lorem ipsum') + end + page.has_text?('Advanced search is enabled') end - page.has_text?('Advanced search is enabled') end end end diff --git a/qa/qa/specs/features/shared_contexts/import/gitlab_group_migration_common.rb b/qa/qa/specs/features/shared_contexts/import/gitlab_group_migration_common.rb index 853f427db12..4bd81ccdf36 100644 --- a/qa/qa/specs/features/shared_contexts/import/gitlab_group_migration_common.rb +++ b/qa/qa/specs/features/shared_contexts/import/gitlab_group_migration_common.rb @@ -32,7 +32,7 @@ module QA Resource::Sandbox.fabricate_via_api! do |group| group.api_client = source_admin_api_client group.path = "source-group-for-import-#{SecureRandom.hex(4)}" - group.avatar = File.new("qa/fixtures/designs/tanuki.jpg", "r") + group.avatar = File.new(File.join(Runtime::Path.fixtures_path, 'designs', 'tanuki.jpg'), "r") end end diff --git a/qa/qa/specs/knapsack_runner.rb b/qa/qa/specs/knapsack_runner.rb index 4908553e43d..0c4f938ee28 100644 --- a/qa/qa/specs/knapsack_runner.rb +++ b/qa/qa/specs/knapsack_runner.rb @@ -4,6 +4,8 @@ module QA module Specs class KnapsackRunner def self.run(args) + QA::Support::KnapsackReport.configure! + allocator = Knapsack::AllocatorBuilder.new(Knapsack::Adapters::RSpecAdapter).allocator Knapsack.logger.info '==== Knapsack specs to execute =====' diff --git a/qa/qa/specs/spec_helper.rb b/qa/qa/specs/spec_helper.rb index 0e6e3973de9..1bf189ed6ac 100644 --- a/qa/qa/specs/spec_helper.rb +++ b/qa/qa/specs/spec_helper.rb @@ -11,6 +11,7 @@ QA::Support::GitlabAddress.define_gitlab_address_attribute! QA::Runtime::Browser.configure! unless QA::Runtime::Env.dry_run QA::Runtime::AllureReport.configure! QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes) +QA::Support::KnapsackReport.configure! # Enable zero monkey patching mode before loading any other RSpec code. RSpec.configure(&:disable_monkey_patching!) |