diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /qa/qa/specs | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'qa/qa/specs')
23 files changed, 944 insertions, 102 deletions
diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb new file mode 100644 index 00000000000..055300122d4 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Manage', :requires_admin do + describe 'Group bulk import' do + let!(:api_client) { Runtime::API::Client.as_admin } + let!(:user) do + Resource::User.fabricate_via_api! do |usr| + usr.api_client = api_client + usr.hard_delete_on_api_removal = true + end + end + + let!(:personal_access_token) { Runtime::API::Client.new(user: user).personal_access_token } + + let!(:sandbox) do + Resource::Sandbox.fabricate_via_api! do |group| + group.api_client = api_client + end + end + + let!(:source_group) do + Resource::Sandbox.fabricate_via_api! do |group| + group.api_client = api_client + group.path = "source-group-for-import-#{SecureRandom.hex(4)}" + end + end + + let!(:subgroup) do + Resource::Group.fabricate_via_api! do |group| + group.api_client = api_client + group.sandbox = source_group + group.path = "subgroup-for-import-#{SecureRandom.hex(4)}" + end + end + + let(:imported_group) do + Resource::Group.new.tap do |group| + group.api_client = api_client + group.path = source_group.path + end + end + + let(:imported_subgroup) do + Resource::Group.new.tap do |group| + group.api_client = api_client + group.sandbox = imported_group + group.path = subgroup.path + end + end + + def staging? + Runtime::Scenario.gitlab_address.include?('staging.gitlab.com') + end + + before(:all) do + Runtime::Feature.enable(:bulk_import) + Runtime::Feature.enable(:top_level_group_creation_enabled) if staging? + end + + before do + sandbox.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + source_group.add_member(user, Resource::Members::AccessLevel::MAINTAINER) + + Flow::Login.sign_in(as: user) + Page::Main::Menu.new.go_to_import_group + Page::Group::New.new.connect_gitlab_instance(Runtime::Scenario.gitlab_address, personal_access_token) + end + + it( + 'performs bulk group import from another gitlab instance', + testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1785', + exclude: { job: ['ce:relative_url', 'ee:relative_url'] } # https://gitlab.com/gitlab-org/gitlab/-/issues/330344 + ) do + Page::Group::BulkImport.perform do |import_page| + import_page.import_group(source_group.path, sandbox.path) + + aggregate_failures do + expect(import_page).to have_imported_group(source_group.path, wait: 120) + expect(imported_group).to eq(source_group) + expect(imported_subgroup).to eq(subgroup) + end + end + end + + after do + user.remove_via_api! + source_group.remove_via_api! + end + + after(:all) do + Runtime::Feature.disable(:bulk_import) + Runtime::Feature.disable(:top_level_group_creation_enabled) if staging? + end + end + 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 5fbcd69817b..23a21d70cc1 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 @@ -138,7 +138,7 @@ module QA Page::Admin::Overview::Users::Index.perform do |index| index.click_pending_approval_tab index.search_user(user.username) - index.click_user(user.username) + index.click_user(user.name) end Page::Admin::Overview::Users::Show.perform do |show| diff --git a/qa/qa/specs/features/browser_ui/1_manage/user/follow_user_activity_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/user/follow_user_activity_spec.rb new file mode 100644 index 00000000000..964cd453049 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/user/follow_user_activity_spec.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Manage' do + describe 'User', :requires_admin 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(:user_api_client) do + Runtime::API::Client.new(:gitlab, user: user) + end + + let(:group) do + group = QA::Resource::Group.fabricate_via_api! do |group| + group.path = "group_for_follow_user_activity_#{SecureRandom.hex(8)}" + end + group.add_member(user) + group + end + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-for-tags' + project.initialize_with_readme = true + project.api_client = user_api_client + project.group = group + end + end + + let(:merge_request) do + Resource::MergeRequest.fabricate_via_api! do |mr| + mr.project = project + mr.api_client = user_api_client + end + end + + let(:issue) do + Resource::Issue.fabricate_via_api! do |issue| + issue.project = project + issue.api_client = user_api_client + end + end + + let(:comment) do + Resource::ProjectIssueNote.fabricate_via_api! do |project_issue_note| + project_issue_note.project = project + project_issue_note.issue = issue + project_issue_note.body = 'This is a comment' + project_issue_note.api_client = user_api_client + end + end + + before do + # Create both tokens before logging in the first time so that we don't need to log out in the middle of the test + admin_api_client.personal_access_token + user_api_client.personal_access_token + end + + it 'can be followed and their activity seen', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1773' do + Flow::Login.sign_in + page.visit Runtime::Scenario.gitlab_address + "/#{user.username}" + Page::User::Show.perform(&:click_follow_user_link) + + expect(page).to have_text("No activities found") + + project + merge_request + issue + comment + + Page::Main::Menu.perform(&:click_user_profile_link) + Page::User::Show.perform do |show| + show.click_following_link + show.click_user_link(user.username) + + aggregate_failures do + expect(show).to have_activity('created project') + expect(show).to have_activity('opened merge request') + expect(show).to have_activity('opened issue') + expect(show).to have_activity('commented on issue') + end + end + end + + after do + project.api_client = admin_api_client + project.remove_via_api! + user.remove_via_api! + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb index 2a91c674a22..d9b5ffcdc47 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb @@ -49,7 +49,7 @@ module QA Page::File::Show.perform(&:click_edit) - expect(page).to have_text("You're not allowed to edit files in this project directly.") + expect(page).to have_text("You can’t edit files directly in this project.") end after do 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 b2b37fcd424..8c0b3da6004 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 @@ -9,7 +9,7 @@ module QA Flow::Login.sign_in end - it 'creates an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1167' do + it 'creates an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1793' do issue = Resource::Issue.fabricate_via_browser_ui! Page::Project::Menu.perform(&:click_issues) @@ -19,7 +19,7 @@ module QA end end - it 'closes an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1085' do + it 'closes an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1792' do closed_issue.visit! Page::Project::Issue::Show.perform do |issue_page| diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb index 34669eb3815..ca0eeb2403c 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb @@ -3,7 +3,7 @@ module QA RSpec.describe 'Create', quarantine: { only: { subdomain: :staging }, issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/323990', type: :flaky } do describe 'Merge request rebasing' do - it 'user rebases source branch of merge request', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1274' do + it 'user rebases source branch of merge request', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1800' do Flow::Login.sign_in project = Resource::Project.fabricate_via_api! do |project| diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb new file mode 100644 index 00000000000..089b87be423 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Reverting a commit' do + let(:file_name) { "secret_file.md" } + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project' + project.initialize_with_readme = true + end + end + + let(:commit) do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add new file' + commit.add_files([ + { file_path: file_name, content: 'pssst!' } + ]) + end + end + + before do + Flow::Login.sign_in + commit.visit! + end + + it 'creates a merge request', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1784' do + Page::Project::Commit::Show.perform(&:revert_commit) + Page::MergeRequest::New.perform(&:create_merge_request) + + Page::MergeRequest::Show.perform do |merge_request| + merge_request.click_diffs_tab + expect(merge_request).to have_file(file_name) + end + end + + after do + project.remove_via_api! + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/revert_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/reverting_merge_request_spec.rb index 3574cdbe4ac..3574cdbe4ac 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/revert_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/reverting_merge_request_spec.rb diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb new file mode 100644 index 00000000000..db31cadb37d --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Branch with unusual name' do + let(:branch_name) { 'unUsually/named#br--anch' } + let(:project) do + Resource::Project.fabricate_via_api! do |resource| + resource.name = 'unusually-named-branch-project' + resource.initialize_with_readme = true + end + end + + before do + Flow::Login.sign_in + end + + context 'when branch name contains slash, hash, double dash, and capital letter' do + it 'renders repository file tree correctly', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1780' do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.branch = branch_name + commit.start_branch = project.default_branch + commit.commit_message = 'Add new file' + commit.add_files([ + { file_path: 'test-folder/test-file.md', content: 'new content' } + ]) + end + + project.visit! + + Page::Project::Show.perform do |show| + show.switch_to_branch(branch_name) + show.click_file('test-folder') + + expect(show).to have_file('test-file.md') + + show.click_file('test-file.md') + + expect(show).to have_content('new content') + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/file/file_with_unusual_name_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/file/file_with_unusual_name_spec.rb new file mode 100644 index 00000000000..98d0a3c5706 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/repository/file/file_with_unusual_name_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'File with unusual name' do + let(:file_name) { '-un:usually;named#file?.md' } + let(:project) do + Resource::Project.fabricate_via_api! do |resource| + resource.name = 'unusually-named-file-project' + resource.initialize_with_readme = true + end + end + + before do + Flow::Login.sign_in + end + + context 'when file name starts with a dash and contains hash, semicolon, colon, and question mark' do + it 'renders repository file tree correctly', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1779' do + Resource::File.fabricate_via_api! do |file| + file.project = project + file.commit_message = 'Add new file' + file.name = "test-folder/#{file_name}" + file.content = "### Heading\n\n[Gitlab link](https://gitlab.com/)" + end + + project.visit! + + Page::Project::Show.perform do |show| + show.click_file('test-folder') + + expect(show).to have_file(file_name) + + show.click_file(file_name) + + aggregate_failures 'markdown file contents' do + expect(show).to have_content('Heading') + expect(show).to have_content('Gitlab link') + expect(show).not_to have_content('###') + expect(show).not_to have_content('https://gitlab.com/') + end + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb index b67e0e54aa0..9d90ff189c6 100644 --- a/qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb @@ -71,7 +71,7 @@ module QA snippet.remove_via_api! end - it 'clones, pushes, and pulls a project snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/832' do + it 'clones, pushes, and pulls a project snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1794' do Resource::Repository::Push.fabricate! do |push| push.repository_ssh_uri = repository_uri_ssh push.ssh_key = ssh_key diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/snippet_index_page_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/snippet_index_page_spec.rb new file mode 100644 index 00000000000..9c7dc868a2e --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/snippet_index_page_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Snippet index page' do + let(:personal_snippet_with_single_file) do + Resource::Snippet.fabricate_via_api! do |snippet| + snippet.title = "Personal snippet with one file-#{SecureRandom.hex(8)}" + snippet.visibility = 'Public' + end + end + + let(:personal_snippet_with_multiple_files) do + Resource::Snippet.fabricate_via_api! do |snippet| + snippet.title = "Personal snippet with multiple files-#{SecureRandom.hex(8)}" + snippet.visibility = 'Private' + snippet.file_name = 'First file name' + snippet.file_content = 'first file content' + + snippet.add_files do |files| + files.append(name: 'Second file name', content: 'second file content') + files.append(name: 'Third file name', content: 'third file content') + end + end + end + + let(:project_snippet_with_single_file) do + Resource::ProjectSnippet.fabricate_via_api! do |snippet| + snippet.title = "Project snippet with one file-#{SecureRandom.hex(8)}" + snippet.visibility = 'Private' + end + end + + let(:project_snippet_with_multiple_files) do + Resource::ProjectSnippet.fabricate_via_api! do |snippet| + snippet.title = "Project snippet with multiple files-#{SecureRandom.hex(8)}" + snippet.visibility = 'Public' + snippet.file_name = 'First file name' + snippet.file_content = 'first file content' + + snippet.add_files do |files| + files.append(name: 'Second file name', content: 'second file content') + files.append(name: 'Third file name', content: 'third file content') + end + end + end + + before do + Flow::Login.sign_in + end + + after do + personal_snippet_with_single_file.remove_via_api! + personal_snippet_with_multiple_files.remove_via_api! + project_snippet_with_single_file.remove_via_api! + project_snippet_with_multiple_files.remove_via_api! + end + + shared_examples 'displaying details on index page' do |snippet_type| + it "shows correct details of #{snippet_type} including file number" do + send(snippet_type) + Page::Main::Menu.perform do |menu| + menu.go_to_more_dropdown_option(:snippets_link) + end + + Page::Dashboard::Snippet::Index.perform do |snippet| + aggregate_failures 'file content verification' do + expect(snippet).to have_snippet_title(send(snippet_type).title) + expect(snippet).to have_visibility_level(send(snippet_type).title, send(snippet_type).visibility) + expect(snippet).to have_number_of_files(send(snippet_type).title, send(snippet_type).files.count) + end + end + end + end + + it_behaves_like 'displaying details on index page', :personal_snippet_with_single_file + it_behaves_like 'displaying details on index page', :personal_snippet_with_multiple_files + it_behaves_like 'displaying details on index page', :project_snippet_with_single_file + it_behaves_like 'displaying details on index page', :project_snippet_with_multiple_files + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb new file mode 100644 index 00000000000..c7fc01303b7 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Link to line in Web IDE' do + let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.template_name = 'express' + end + end + + before do + Flow::Login.sign_in + end + + after do + project.remove_via_api! + end + + it 'can link to a specific line of code in Web IDE', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1102' do + project.visit! + + Page::Project::Show.perform(&:open_web_ide!) + + Page::Project::WebIDE::Edit.perform do |ide| + ide.select_file('app.js') + @link = ide.link_line('26') + end + + Flow::Login.sign_in(as: user) + + page.visit(@link) + + Page::Project::WebIDE::Edit.perform do |ide| + expect(ide).to have_file('app.js') + end + + expect(page.driver.current_url).to include('app.js/#L26') + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb index 5b976ae4126..4938ae3f969 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb @@ -115,7 +115,7 @@ module QA commit.add_files( [ { - file_path: "#{Faker::Lorem.word}.txt", + file_path: Faker::File.unique.file_name, content: Faker::Lorem.sentence } ] @@ -129,7 +129,7 @@ module QA merge_request.project = project merge_request.description = Faker::Lorem.sentence merge_request.target_new_branch = false - merge_request.file_name = "#{Faker::Lorem.word}.txt" + merge_request.file_name = Faker::File.unique.file_name merge_request.file_content = Faker::Lorem.sentence end end diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/locked_artifacts_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/locked_artifacts_spec.rb new file mode 100644 index 00000000000..253b5fb2af4 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/locked_artifacts_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Verify', :runner, :requires_admin do + describe 'Artifacts' do + context 'when locked' do + let(:file_name) { 'artifact.txt' } + let(:directory_name) { 'my_artifacts' } + let(:executor) { "qa-runner-#{Time.now.to_i}" } + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-with-locked-artifacts' + end + end + + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.project = project + runner.name = executor + runner.tags = [executor] + end + end + + before do + Flow::Login.sign_in + end + + after do + runner.remove_via_api! + end + + it 'can be browsed' 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 + test-artifacts: + tags: + - '#{executor}' + artifacts: + paths: + - '#{directory_name}' + expire_in: 1 sec + script: + - | + mkdir #{directory_name} + echo "CONTENTS" > #{directory_name}/#{file_name} + YAML + } + ] + ) + end.project.visit! + + Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed') + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('test-artifacts') + end + + Page::Project::Job::Show.perform do |show| + expect(show).to have_browse_button + show.click_browse_button + end + + Page::Project::Artifact::Show.perform do |show| + show.go_to_directory(directory_name) + expect(show).to have_content(file_name) + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb index 519777b32d9..c1625f1e679 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb @@ -5,34 +5,29 @@ require 'faker' module QA RSpec.describe 'Verify', :runner do describe 'Pass dotenv variables to downstream via bridge' do - let(:executor_1) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" } - let(:executor_2) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" } + let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" } + let(:upstream_var) { Faker::Alphanumeric.alphanumeric(8) } + let(:group) { Resource::Group.fabricate_via_api! } let(:upstream_project) do Resource::Project.fabricate_via_api! do |project| - project.name = 'project-with-pipeline-1' + project.group = group + project.name = 'upstream-project-with-bridge' end end let(:downstream_project) do Resource::Project.fabricate_via_api! do |project| - project.name = 'project-with-pipeline-2' + project.group = group + project.name = 'downstream-project-with-bridge' end end - let!(:runner_1) do + let!(:runner) do Resource::Runner.fabricate! do |runner| - runner.project = upstream_project - runner.name = executor_1 - runner.tags = [executor_1] - end - end - - let!(:runner_2) do - Resource::Runner.fabricate! do |runner| - runner.project = downstream_project - runner.name = executor_2 - runner.tags = [executor_2] + runner.name = executor + runner.tags = [executor] + runner.token = group.sandbox.runners_token end end @@ -45,8 +40,8 @@ module QA end after do - runner_1.remove_via_api! - runner_2.remove_via_api! + runner.remove_via_api! + group.remove_via_api! end it 'runs the pipeline with composed config', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1086' do @@ -58,6 +53,7 @@ module QA Page::Project::Job::Show.perform do |show| expect(show).to have_passed(timeout: 360) + expect(show.output).to have_content(upstream_var) end end @@ -77,8 +73,9 @@ module QA content: <<~YAML build: stage: build - tags: ["#{executor_1}"] - script: echo "MY_VAR=hello" >> variables.env + tags: ["#{executor}"] + script: + - echo "DYNAMIC_ENVIRONMENT_VAR=#{upstream_var}" >> variables.env artifacts: reports: dotenv: variables.env @@ -86,7 +83,7 @@ module QA trigger: stage: deploy variables: - PASSED_MY_VAR: $MY_VAR + PASSED_MY_VAR: $DYNAMIC_ENVIRONMENT_VAR trigger: #{downstream_project.full_path} YAML } @@ -98,8 +95,9 @@ module QA content: <<~YAML downstream_test: stage: test - tags: ["#{executor_2}"] - script: '[ "$PASSED_MY_VAR" = hello ]; exit "$?"' + tags: ["#{executor}"] + script: + - echo $PASSED_MY_VAR YAML } end diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb index 5e663d87ae3..7a71d1cfbaf 100644 --- a/qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated do - describe 'Container Registry', only: { subdomain: :staging } do + RSpec.describe 'Package' do + describe 'Container Registry', :reliable, only: { subdomain: %i[staging pre] } do let(:project) do Resource::Project.fabricate_via_api! do |project| project.name = 'project-with-registry' @@ -26,6 +26,10 @@ module QA - docker:19.03.12-dind variables: IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: 1 + DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $IMAGE_TAG . diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb index 7234edb46d3..fb019290d4c 100644 --- a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb @@ -9,6 +9,7 @@ module QA let(:group_id) { 'com.gitlab.qa' } let(:artifact_id) { "maven-#{SecureRandom.hex(8)}" } + let(:another_artifact_id) { "maven-#{SecureRandom.hex(8)}" } let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') } let(:auth_token) do unless Page::Main::Menu.perform(&:signed_in?) @@ -64,7 +65,7 @@ module QA <repositories> <repository> <id>#{project.name}</id> - <url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url> + <url>#{gitlab_address_with_port}/api/v4/groups/#{project.group.id}/-/packages/maven</url> </repository> </repositories> <distributionManagement> @@ -82,6 +83,43 @@ module QA } end + let(:pom_xml_another_project) do + { + file_path: 'pom.xml', + content: <<~XML + <project> + <groupId>#{group_id}</groupId> + <artifactId>#{another_artifact_id}</artifactId> + <version>1.0</version> + <modelVersion>4.0.0</modelVersion> + <repositories> + <repository> + <id>#{another_project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/groups/#{another_project.group.id}/-/packages/maven</url> + </repository> + </repositories> + <distributionManagement> + <repository> + <id>#{another_project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/projects/#{another_project.id}/packages/maven</url> + </repository> + <snapshotRepository> + <id>#{another_project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/projects/#{another_project.id}/packages/maven</url> + </snapshotRepository> + </distributionManagement> + <dependencies> + <dependency> + <groupId>#{group_id}</groupId> + <artifactId>#{artifact_id}</artifactId> + <version>1.0</version> + </dependency> + </dependencies> + </project> + XML + } + end + let(:settings_xml) do { file_path: 'settings.xml', @@ -106,7 +144,7 @@ module QA } end - let(:gitlab_ci_yaml) do + let(:gitlab_ci_deploy_yml) do { file_path: '.gitlab-ci.yml', content: @@ -124,58 +162,90 @@ module QA } end + let(:gitlab_ci_install_yml) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + install: + image: maven:3.6-jdk-11 + script: + - "mvn install" + only: + - "#{project.default_branch}" + tags: + - "runner-for-#{another_project.group.name}" + YAML + } + end + after do runner.remove_via_api! + project.remove_via_api! + another_project.remove_via_api! end - it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do - # Use a maven docker container to deploy the package - with_fixtures([pom_xml, settings_xml]) do |dir| - Service::DockerRun::Maven.new(dir).publish! + it 'pushes and pulls a Maven package via CI and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([ + gitlab_ci_deploy_yml, + settings_xml, + pom_xml + ]) end project.visit! - Page::Project::Menu.perform(&:click_packages_link) - - Page::Project::Packages::Index.perform do |index| - expect(index).to have_package(package_name) - - index.click_package(package_name) - end - - Page::Project::Packages::Show.perform do |show| - expect(show).to have_package_info(package_name, "1.0") + Flow::Pipeline.visit_latest_pipeline - show.click_delete + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('deploy') end - Page::Project::Packages::Index.perform do |index| - expect(index).to have_content("Package deleted successfully") - expect(index).not_to have_package(package_name) + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) end - end - it 'publishes and downloads a maven package via CI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.project = project + commit.project = another_project commit.commit_message = 'Add .gitlab-ci.yml' commit.add_files([ - gitlab_ci_yaml, - settings_xml, - pom_xml + gitlab_ci_install_yml, + pom_xml_another_project ]) end - project.visit! + another_project.visit! Flow::Pipeline.visit_latest_pipeline Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('deploy') + pipeline.click_job('install') end Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 800) end + + project.visit! + + Page::Project::Menu.perform(&:click_packages_link) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package_name) + + index.click_package(package_name) + end + + Page::Project::Packages::Show.perform do |show| + expect(show).to have_package_info(package_name, "1.0") + show.click_delete + end + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_content("Package deleted successfully") + expect(index).not_to have_package(package_name) + end end context 'when "allow duplicate" setting is disabled' do @@ -204,7 +274,7 @@ module QA commit.project = another_project commit.commit_message = 'Add .gitlab-ci.yml' commit.add_files([ - gitlab_ci_yaml, + gitlab_ci_deploy_yml, settings_xml, pom_xml ]) @@ -249,7 +319,7 @@ module QA commit.project = another_project commit.commit_message = 'Add .gitlab-ci.yml' commit.add_files([ - gitlab_ci_yaml, + gitlab_ci_deploy_yml, settings_xml, pom_xml ]) diff --git a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb index 49b42bd1ff6..4d714affd65 100644 --- a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb @@ -5,7 +5,7 @@ module QA describe 'npm registry' do include Runtime::Fixtures - let!(:registry_scope) { project.group.sandbox.path } + let!(:registry_scope) { Runtime::Namespace.sandbox_name } let(:auth_token) do unless Page::Main::Menu.perform(&:signed_in?) Flow::Login.sign_in @@ -14,28 +14,87 @@ module QA Resource::PersonalAccessToken.fabricate!.token end + let(:uri) { URI.parse(Runtime::Scenario.gitlab_address) } + let(:gitlab_address_with_port) { "#{uri.scheme}://#{uri.host}:#{uri.port}" } + let(:gitlab_host_with_port) { "#{uri.host}:#{uri.port}" } + let!(:project) do Resource::Project.fabricate_via_api! do |project| - project.name = 'npm-registry-project' + project.name = 'npm-project' end end - let(:package) do - Resource::Package.new.tap do |package| - package.name = "@#{registry_scope}/#{project.name}" - package.project = project + let!(:another_project) do + Resource::Project.fabricate_via_api! do |another_project| + another_project.name = 'npm-another-project' + another_project.template_name = 'express' + another_project.group = project.group end end - after do - package.remove_via_api! + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.name = "qa-runner-#{Time.now.to_i}" + runner.tags = ["runner-for-#{project.group.name}"] + runner.executor = :docker + runner.token = project.group.sandbox.runners_token + end + end + + let(:gitlab_ci_deploy_yaml) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + image: node:14-buster + + stages: + - deploy + + deploy: + stage: deploy + script: + - npm publish + only: + - "#{project.default_branch}" + tags: + - "runner-for-#{project.group.name}" + YAML + } end - it 'publishes an npm package and then deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/944' do - uri = URI.parse(Runtime::Scenario.gitlab_address) - gitlab_host_with_port = "#{uri.host}:#{uri.port}" - gitlab_address_with_port = "#{uri.scheme}://#{uri.host}:#{uri.port}" - package_json = { + let(:gitlab_ci_install_yaml) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + image: node:latest + + stages: + - install + + install: + stage: install + script: + - "npm config set @#{registry_scope}:registry #{gitlab_address_with_port}/api/v4/packages/npm/" + - "npm install #{package.name}" + cache: + key: ${CI_BUILD_REF_NAME} + paths: + - node_modules/ + artifacts: + paths: + - node_modules/ + only: + - "#{another_project.default_branch}" + tags: + - "runner-for-#{another_project.group.name}" + YAML + } + end + + let(:package_json) do + { file_path: 'package.json', content: <<~JSON { @@ -47,19 +106,79 @@ module QA } } JSON - } - npmrc = { + } + end + + let(:npmrc) do + { file_path: '.npmrc', content: <<~NPMRC //#{gitlab_host_with_port}/api/v4/projects/#{project.id}/packages/npm/:_authToken=#{auth_token} - //#{gitlab_host_with_port}/api/v4/packages/npm/:_authToken=#{auth_token} - @#{registry_scope}:registry=#{gitlab_address_with_port}/api/v4/packages/npm/ + @#{registry_scope}:registry=#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/npm/ NPMRC } + end + + let(:package) do + Resource::Package.new.tap do |package| + package.name = "@#{registry_scope}/#{project.name}" + package.project = project + end + end + + after do + package.remove_via_api! + runner.remove_via_api! + project.remove_via_api! + another_project.remove_via_api! + end + + it 'push and pull a npm package via CI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1772' do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([ + gitlab_ci_deploy_yaml, + npmrc, + package_json + ]) + end + + project.visit! + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('deploy') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = another_project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([ + gitlab_ci_install_yaml + ]) + end + + another_project.visit! + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('install') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + job.click_browse_button + end - # Use a node docker container to publish the package - with_fixtures([npmrc, package_json]) do |dir| - Service::DockerRun::NodeJs.new(dir).publish! + Page::Project::Artifact::Show.perform do |artifacts| + artifacts.go_to_directory('node_modules') + artifacts.go_to_directory("@#{registry_scope}") + expect(artifacts).to have_content( "#{project.name}") end project.visit! diff --git a/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb index c0d84d82e51..3db5b9671d9 100644 --- a/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb @@ -21,33 +21,24 @@ module QA end let(:another_project) do - Resource::Project.fabricate_via_api! do |project| - project.name = 'nuget-package-install-project' - project.template_name = 'dotnetcore' + Resource::Project.fabricate_via_api! do |another_project| + another_project.name = 'nuget-package-install-project' + another_project.template_name = 'dotnetcore' + another_project.group = project.group end end let!(:runner) do Resource::Runner.fabricate! do |runner| runner.name = "qa-runner-#{Time.now.to_i}" - runner.tags = ["runner-for-#{project.name}"] - runner.executor = :docker - runner.project = project - end - end - - let!(:another_runner) do - Resource::Runner.fabricate! do |runner| - runner.name = "qa-runner-#{Time.now.to_i}" - runner.tags = ["runner-for-#{another_project.name}"] + runner.tags = ["runner-for-#{project.group.sandbox.name}"] runner.executor = :docker - runner.project = another_project + runner.token = project.group.sandbox.runners_token end end after do runner.remove_via_api! - another_runner.remove_via_api! package.remove_via_api! end @@ -78,7 +69,7 @@ module QA only: - "#{project.default_branch}" tags: - - "runner-for-#{project.name}" + - "runner-for-#{project.group.sandbox.name}" YAML } ] @@ -137,7 +128,7 @@ module QA only: - "#{another_project.default_branch}" tags: - - "runner-for-#{another_project.name}" + - "runner-for-#{project.group.sandbox.name}" YAML } ] diff --git a/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb new file mode 100644 index 00000000000..5d15885cd67 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb @@ -0,0 +1,125 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package', :orchestrated, :requires_admin, :packages do + describe 'RubyGems Repository' do + include Runtime::Fixtures + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'rubygems-package-project' + end + end + + let(:package) do + Resource::Package.new.tap do |package| + package.name = 'mygem' + package.project = project + end + end + + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.name = "qa-runner-#{Time.now.to_i}" + runner.tags = ["runner-for-#{project.name}"] + runner.executor = :docker + runner.project = project + end + end + + let(:gitlab_address_with_port) do + uri = URI.parse(Runtime::Scenario.gitlab_address) + "#{uri.scheme}://#{uri.host}:#{uri.port}" + end + + before do + Runtime::Feature.enable(:rubygem_packages, project: project) + end + + after do + Runtime::Feature.disable(:rubygem_packages, project: project) + runner.remove_via_api! + package.remove_via_api! + project.remove_via_api! + end + + it 'publishes and deletes a Ruby gem', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1131' do + Flow::Login.sign_in + + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = project + push.directory = Pathname + .new(__dir__) + .join('../../../../fixtures/rubygems_package') + push.commit_message = 'RubyGems package' + end + + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add mygem.gemspec' + commit.add_files( + [ + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + image: ruby + + test_package: + stage: deploy + before_script: + - mkdir ~/.gem + - echo "---" > ~/.gem/credentials + - | + echo "#{gitlab_address_with_port}/api/v4/projects/${CI_PROJECT_ID}/packages/rubygems: '${CI_JOB_TOKEN}'" >> ~/.gem/credentials + - chmod 0600 ~/.gem/credentials + script: + - gem build mygem + - gem push mygem-0.0.1.gem --host #{gitlab_address_with_port}/api/v4/projects/${CI_PROJECT_ID}/packages/rubygems + tags: + - "runner-for-#{project.name}" + YAML + }, + { + file_path: 'lib/hello_gem.rb', + content: + <<~RUBY + class HelloWorld + def self.hi + puts "Hello world!" + end + end + RUBY + } + ] + ) + end + + project.visit! + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('test_package') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + + Page::Project::Menu.perform(&:click_packages_link) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package.name) + index.click_package(package.name) + end + + Page::Project::Packages::Show.perform(&:click_delete) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_content("Package deleted successfully") + expect(index).not_to have_package(package.name) + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb b/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb index 5ea7a7bb4cb..2cb2ea2d636 100644 --- a/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb +++ b/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb @@ -30,7 +30,7 @@ module QA pipeline.visit! end - it 'runs a Pages-specific pipeline', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/877' do + it 'runs a Pages-specific pipeline', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1783' do Page::Project::Pipeline::Show.perform do |show| expect(show).to have_job(:pages) show.click_job(:pages) diff --git a/qa/qa/specs/features/browser_ui/8_monitor/all_monitor_core_features_spec.rb b/qa/qa/specs/features/browser_ui/8_monitor/all_monitor_core_features_spec.rb index 07fc4f0e7fa..94df408f9aa 100644 --- a/qa/qa/specs/features/browser_ui/8_monitor/all_monitor_core_features_spec.rb +++ b/qa/qa/specs/features/browser_ui/8_monitor/all_monitor_core_features_spec.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'cluster_with_prometheus.rb' +require_relative 'cluster_with_prometheus' module QA RSpec.describe 'Monitor', :orchestrated, :kubernetes, :requires_admin, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/241448', type: :investigating } do |