diff options
Diffstat (limited to 'qa')
22 files changed, 356 insertions, 146 deletions
diff --git a/qa/.gitignore b/qa/.gitignore index 19ec17d0005..102f7e5e54d 100644 --- a/qa/.gitignore +++ b/qa/.gitignore @@ -1,2 +1,3 @@ tmp/ .ruby-version +urls.txt diff --git a/qa/Gemfile b/qa/Gemfile index f29006617ed..38e95ba2d65 100644 --- a/qa/Gemfile +++ b/qa/Gemfile @@ -9,3 +9,4 @@ gem 'selenium-webdriver', '~> 3.12' gem 'airborne', '~> 0.2.13' gem 'nokogiri', '~> 1.10.1' gem 'rspec-retry', '~> 0.6.1' +gem 'faker', '~> 1.6', '>= 1.6.6' diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index c3d9f558c23..c9b0db6a272 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -32,6 +32,8 @@ GEM diff-lcs (1.3) domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) + faker (1.9.3) + i18n (>= 0.7) ffi (1.9.25) http-cookie (1.0.3) domain_name (~> 0.5) @@ -99,6 +101,7 @@ DEPENDENCIES airborne (~> 0.2.13) capybara (~> 2.16.1) capybara-screenshot (~> 1.0.18) + faker (~> 1.6, >= 1.6.6) nokogiri (~> 1.10.1) pry-byebug (~> 3.5.1) rake (~> 12.3.0) diff --git a/qa/README.md b/qa/README.md index 7709db36f8e..735868e7640 100644 --- a/qa/README.md +++ b/qa/README.md @@ -42,6 +42,9 @@ following call would login to a local [GDK] instance and run all specs in bin/qa Test::Instance::All http://localhost:3000 ``` +Note: If you want to run tests requiring SSH against GDK, you +will need to [modify your GDK setup](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md). + ### Writing tests 1. [Using page objects](qa/page/README.md) diff --git a/qa/Rakefile b/qa/Rakefile index 9a7b9c6bb35..b6ad09f9b00 100644 --- a/qa/Rakefile +++ b/qa/Rakefile @@ -1,5 +1,6 @@ require_relative 'qa/tools/revoke_all_personal_access_tokens' require_relative 'qa/tools/delete_subgroups' +require_relative 'qa/tools/generate_perf_testdata' desc "Revokes all personal access tokens" task :revoke_personal_access_tokens do @@ -10,3 +11,8 @@ desc "Deletes subgroups within a provided group" task :delete_subgroups do QA::Tools::DeleteSubgroups.new.run end + +desc "Generate Performance Testdata" +task :generate_perf_testdata do + QA::Tools::GeneratePerfTestdata.new.run +end diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index 0aa94101098..b3bad40a90f 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -12,6 +12,7 @@ module QA module Git class Repository include Scenario::Actable + RepositoryCommandError = Class.new(StandardError) attr_writer :use_lfs attr_accessor :env_vars @@ -205,6 +206,10 @@ module QA output.chomp! Runtime::Logger.debug "Git: output=[#{output}], exitstatus=[#{status.exitstatus}]" + unless status.success? + raise RepositoryCommandError, "The command #{command} failed (#{status.exitstatus}) with the following output:\n#{output}" + end + Result.new(status.exitstatus == 0, output) end diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 11ebd70292e..9fabf83e2ce 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -157,6 +157,10 @@ module QA find('body').click end + def visit_link_in_element(name) + visit find_element(name)['href'] + end + def self.path raise NotImplementedError end diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index 976e431186d..c0411db6505 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -27,6 +27,12 @@ module QA element :squash_checkbox end + view 'app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue' do + element :dropdown_toggle + element :download_email_patches + element :download_plain_diff + end + view 'app/views/projects/merge_requests/show.html.haml' do element :notes_tab element :diffs_tab @@ -159,6 +165,16 @@ module QA def edit! click_element :edit_button end + + def view_email_patches + click_element :dropdown_toggle + visit_link_in_element(:download_email_patches) + end + + def view_plain_diff + click_element :dropdown_toggle + visit_link_in_element(:download_plain_diff) + end end end end diff --git a/qa/qa/page/project/new.rb b/qa/qa/page/project/new.rb index 9f1867ef8a5..eabeae1acc4 100644 --- a/qa/qa/page/project/new.rb +++ b/qa/qa/page/project/new.rb @@ -24,9 +24,12 @@ module QA end def choose_test_namespace - click_element :project_namespace_select + retry_on_exception do + click_body + click_element :project_namespace_select - search_and_select(Runtime::Namespace.path) + search_and_select(Runtime::Namespace.path) + end end def go_to_import_project diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb index c5f12255d72..41ab702d8b2 100644 --- a/qa/qa/service/kubernetes_cluster.rb +++ b/qa/qa/service/kubernetes_cluster.rb @@ -9,7 +9,7 @@ module QA attr_reader :api_url, :ca_certificate, :token, :rbac - def initialize(rbac: false) + def initialize(rbac: true) @rbac = rbac end diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb index e172206eb88..d4cedc9362d 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/21 - context 'Manage', :quarantine do + context 'Manage' do describe 'Project activity' do it 'user creates an event in the activity page upon Git push' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb new file mode 100644 index 00000000000..9e48ee7ca2a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module QA + context 'Create' do + describe 'Download merge request patch and diff' do + before(:context) do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + + @merge_request = Resource::MergeRequest.fabricate! do |merge_request| + merge_request.title = 'This is a merge request' + merge_request.description = 'For downloading patches and diffs' + end + end + + it 'user views merge request email patches' do + @merge_request.visit! + Page::MergeRequest::Show.perform(&:view_email_patches) + + expect(page.text).to start_with('From') + expect(page).to have_content('Subject: [PATCH] This is a test commit') + expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt') + end + + it 'user views merge request plain diff' do + @merge_request.visit! + Page::MergeRequest::Show.perform(&:view_plain_diff) + + expect(page.text).to start_with('diff --git a/added_file.txt b/added_file.txt') + expect(page).to have_content('+File Added') + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb index d1535d6519d..01a367fceac 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module QA - context 'Create' do + # Git protocol v2 is temporarily disabled + # https://gitlab.com/gitlab-org/gitlab-ce/issues/55769 (confidential) + context 'Create', :quarantine do describe 'Push over HTTP using Git protocol version 2', :requires_git_protocol_v2 do it 'user pushes to the repository' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb index 48800cc81e5..eb59b54e9ab 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module QA - context 'Create' do + # Git protocol v2 is temporarily disabled + # https://gitlab.com/gitlab-org/gitlab-ce/issues/55769 (confidential) + context 'Create', :quarantine do describe 'Push over SSH using Git protocol version 2', :requires_git_protocol_v2 do # Note: If you run this test against GDK make sure you've enabled sshd and # enabled setting the Git protocol by adding `AcceptEnv GIT_PROTOCOL` to diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb index 4464fb812b7..6aebd04af03 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb @@ -37,12 +37,7 @@ module QA it 'user without push rights fails to push to the protected branch' do create_protected_branch(allow_to_push: false) - push = push_new_file(branch_name) - - expect(push.output) - .to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/) - expect(push.output) - .to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/) + expect { push_new_file(branch_name) }.to raise_error(QA::Git::Repository::RepositoryCommandError, /remote: GitLab: You are not allowed to push code to protected branches on this project\.([\s\S]+)\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/) end end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb index 7223831d96f..a8a00296881 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true module QA - context 'Create' do + # Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/84 + context 'Create', :quarantine do describe 'SSH key support' do # Note: If you run this test against GDK make sure you've enabled sshd # See: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb index b862a7bd1ed..b862a7bd1ed 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb index e444bc7ef1b..0837b720df1 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/30 - context 'Verify', :quarantine do + context 'Verify' do describe 'CI variable support' do it 'user adds a CI variable' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb index 02bd378acfc..4212a2b0392 100644 --- a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb +++ b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb @@ -11,163 +11,148 @@ module QA end describe 'Auto DevOps support', :orchestrated, :kubernetes, :quarantine do - [true, false].each do |rbac| - context "when rbac is #{rbac ? 'enabled' : 'disabled'}" do - before(:all) do - login - - @project = Resource::Project.fabricate! do |p| - p.name = Runtime::Env.auto_devops_project_name || 'project-with-autodevops' - p.description = 'Project with Auto DevOps' - end - - # Disable code_quality check in Auto DevOps pipeline as it takes - # too long and times out the test - Resource::CiVariable.fabricate! do |resource| - resource.project = @project - resource.key = 'CODE_QUALITY_DISABLED' - resource.value = '1' - end + context 'when rbac is enabled' do + before(:all) do + login - # Create Auto DevOps compatible repo - Resource::Repository::ProjectPush.fabricate! do |push| - push.project = @project - push.directory = Pathname - .new(__dir__) - .join('../../../../../fixtures/auto_devops_rack') - push.commit_message = 'Create Auto DevOps compatible rack application' - end - - # Create and connect K8s cluster - @cluster = Service::KubernetesCluster.new(rbac: rbac).create! - Resource::KubernetesCluster.fabricate! do |cluster| - cluster.project = @project - cluster.cluster = @cluster - cluster.install_helm_tiller = true - cluster.install_ingress = true - cluster.install_prometheus = true - cluster.install_runner = true - end + @project = Resource::Project.fabricate! do |p| + p.name = Runtime::Env.auto_devops_project_name || 'project-with-autodevops' + p.description = 'Project with Auto DevOps' + end - @project.visit! - Page::Project::Menu.perform(&:click_ci_cd_settings) - Page::Project::Settings::CICD.perform do |p| - p.enable_auto_devops - end + # Disable code_quality check in Auto DevOps pipeline as it takes + # too long and times out the test + Resource::CiVariable.fabricate! do |resource| + resource.project = @project + resource.key = 'CODE_QUALITY_DISABLED' + resource.value = '1' end - after(:all) do - @cluster&.remove! + # Create and connect K8s cluster + @cluster = Service::KubernetesCluster.new.create! + Resource::KubernetesCluster.fabricate! do |cluster| + cluster.project = @project + cluster.cluster = @cluster + cluster.install_helm_tiller = true + cluster.install_ingress = true + cluster.install_prometheus = true + cluster.install_runner = true end - before do - login + # Create Auto DevOps compatible repo + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = @project + push.directory = Pathname + .new(__dir__) + .join('../../../../../fixtures/auto_devops_rack') + push.commit_message = 'Create Auto DevOps compatible rack application' end + end - it 'runs auto devops' do - @project.visit! - Page::Project::Menu.perform(&:click_ci_cd_pipelines) - Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline) + after(:all) do + @cluster&.remove! + end - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('build') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 600) + it 'runs auto devops' do + @project.visit! + Page::Project::Menu.perform(&:click_ci_cd_pipelines) + Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline) - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('build') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 600) - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('test') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 600) + job.click_element(:pipeline_path) + end - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('test') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 600) - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('production') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 1200) + job.click_element(:pipeline_path) + end - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('production') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 1200) - Page::Project::Menu.perform(&:click_operations_environments) - Page::Project::Operations::Environments::Index.perform do |index| - index.go_to_environment('production') - end - Page::Project::Operations::Environments::Show.perform do |show| - show.view_deployment do - expect(page).to have_content('Hello World!') - end - end + job.click_element(:pipeline_path) end - it 'user sets application secret variable and Auto DevOps passes it to container' do - # Set an application secret CI variable (prefixed with K8S_SECRET_) - Resource::CiVariable.fabricate! do |resource| - resource.project = @project - resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE' - resource.value = 'You can see this application secret' + Page::Project::Menu.perform(&:click_operations_environments) + Page::Project::Operations::Environments::Index.perform do |index| + index.go_to_environment('production') + end + Page::Project::Operations::Environments::Show.perform do |show| + show.view_deployment do + expect(page).to have_content('Hello World!') end + end + end - # Our current Auto DevOps implementation won't update the production - # app if we only update a CI variable with no code change. - # - # Workaround: push new code and use the resultant pipeline. - Resource::Repository::ProjectPush.fabricate! do |push| - push.project = @project - push.commit_message = 'Force a Deployment change by pushing new code' - push.file_name = 'new_file.txt' - push.file_content = 'new file contents' - end + it 'user sets application secret variable and Auto DevOps passes it to container' do + # Set an application secret CI variable (prefixed with K8S_SECRET_) + Resource::CiVariable.fabricate! do |resource| + resource.project = @project + resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE' + resource.value = 'You can see this application secret' + end - @project.visit! - Page::Project::Menu.perform(&:click_ci_cd_pipelines) - Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline) + # Our current Auto DevOps implementation won't update the production + # app if we only update a CI variable with no code change. + # + # Workaround: push new code and use the resultant pipeline. + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = @project + push.commit_message = 'Force a Deployment change by pushing new code' + push.file_name = 'new_file.txt' + push.file_content = 'new file contents' + end - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('build') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 600) + Page::Project::Menu.perform(&:click_ci_cd_pipelines) + Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline) - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('build') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 600) - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('test') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 600) + job.click_element(:pipeline_path) + end - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('test') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 600) - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.go_to_job('production') - end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 1200) + job.click_element(:pipeline_path) + end - job.click_element(:pipeline_path) - end + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.go_to_job('production') + end + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 1200) + end - Page::Project::Menu.perform(&:click_operations_environments) + Page::Project::Menu.perform(&:click_operations_environments) - Page::Project::Operations::Environments::Index.perform do |index| - index.go_to_environment('production') - end + Page::Project::Operations::Environments::Index.perform do |index| + index.go_to_environment('production') + end - Page::Project::Operations::Environments::Show.perform do |show| - show.view_deployment do - expect(page).to have_content('Hello World!') - expect(page).to have_content('You can see this application secret') - end + Page::Project::Operations::Environments::Show.perform do |show| + show.view_deployment do + expect(page).to have_content('Hello World!') + expect(page).to have_content('You can see this application secret') end end end diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb index 8aa7d6812ac..229bfb44fa5 100644 --- a/qa/qa/support/api.rb +++ b/qa/qa/support/api.rb @@ -20,6 +20,16 @@ module QA e.response end + def put(url, payload) + RestClient::Request.execute( + method: :put, + url: url, + payload: payload, + verify_ssl: false) + rescue RestClient::ExceptionWithResponse => e + e.response + end + def delete(url) RestClient::Request.execute( method: :delete, diff --git a/qa/qa/tools/generate_perf_testdata.rb b/qa/qa/tools/generate_perf_testdata.rb new file mode 100644 index 00000000000..ad515014794 --- /dev/null +++ b/qa/qa/tools/generate_perf_testdata.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +require 'securerandom' +require 'faker' +require_relative '../../qa' +# This script generates testdata for Performance Testing. +# Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS +# This job creates a urls.txt which contains a hash of all the URLs needed for Performance Testing +# Run `rake generate_perf_testdata` + +module QA + module Tools + class GeneratePerfTestdata + include Support::Api + + def initialize + raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS'] + raise ArgumentError, "Please provide PERSONAL_ACCESS_TOKEN" unless ENV['PERSONAL_ACCESS_TOKEN'] + + @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN']) + @group_name = "gitlab-qa-perf-sandbox-#{SecureRandom.hex(8)}" + @project_name = "my-test-project-#{SecureRandom.hex(8)}" + @urls = {} + end + + def run + STDOUT.puts 'Running...' + group_id = create_group + create_project(group_id) + create_branch + add_new_file + methods_arr = [ + method(:create_issues), + method(:create_todos), + method(:create_merge_requests), + method(:create_issue_with_500_discussions), + method(:create_mr_with_large_files) + ] + threads_arr = [] + + methods_arr.each do |m| + threads_arr << Thread.new {m.call} + end + + threads_arr.each(&:join) + STDOUT.puts "\nURLs: #{@urls}" + File.open("urls.txt", "w") { |file| file.puts @urls.to_s} + STDOUT.puts "\nDone" + end + + private + + def create_group + group_search_response = post Runtime::API::Request.new(@api_client, "/groups").url, "name=#{@group_name}&path=#{@group_name}" + group = JSON.parse(group_search_response.body) + @urls[:group_page] = group["web_url"] + group["id"] + end + + def create_project(group_id) + create_project_response = post Runtime::API::Request.new(@api_client, "/projects").url, "name=#{@project_name}&namespace_id=#{group_id}" + @urls[:project_page] = JSON.parse(create_project_response.body)["web_url"] + end + + def create_issues + 30.times do |i| + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/issues").url, "title=issue#{i}&description=desc#{i}" + end + @urls[:issues_list_page] = @urls[:project_page] + "/issues" + STDOUT.puts "Created Issues" + end + + def create_todos + 30.times do |i| + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/issues/#{i + 1}/todo").url, nil + end + @urls[:todos_page] = ENV['GITLAB_ADDRESS'] + "/dashboard/todos" + STDOUT.puts "Created todos" + end + + def create_merge_requests + 30.times do |i| + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/merge_requests").url, "source_branch=branch#{i}&target_branch=master&title=MR#{i}" + end + @urls[:mr_list_page] = @urls[:project_page] + "/merge_requests" + STDOUT.puts "Created MRs" + end + + def add_new_file + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/files/hello.txt").url, "branch=master&commit_message=\"hello\"&content=\"my new content\"" + 30.times do |i| + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/files/hello#{i}.txt").url, "branch=branch#{i}&commit_message=\"hello\"&content=\"my new content\"" + end + STDOUT.puts "Added Files" + end + + def create_branch + 30.times do |i| + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/branches").url, "branch=branch#{i}&ref=master" + end + STDOUT.puts "Created branches" + end + + def create_issue_with_500_discussions + issue_id = 1 + 500.times do + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/issues/#{issue_id}/discussions").url, "body=\"Let us discuss\"" + end + @urls[:large_issue] = @urls[:project_page] + "/issues/#{issue_id}" + STDOUT.puts "Created Issue with 500 Discussions" + end + + def create_mr_with_large_files + content_arr = [] + 20.times do |i| + faker_line_arr = Faker::Lorem.sentences(1500) + content = faker_line_arr.join("\n\r") + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/files/hello#{i}.txt").url, "branch=master&commit_message=\"Add hello#{i}.txt\"&content=#{content}" + content_arr[i] = faker_line_arr + end + + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/branches").url, "branch=performance&ref=master" + + 20.times do |i| + missed_line_array = content_arr[i].each_slice(2).map(&:first) + content = missed_line_array.join("\n\rIm new!:D \n\r ") + put Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/repository/files/hello#{i}.txt").url, "branch=performance&commit_message=\"Update hello#{i}.txt\"&content=#{content}" + end + + create_mr_response = post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/merge_requests").url, "source_branch=performance&target_branch=master&title=Large_MR" + + iid = JSON.parse(create_mr_response.body)["iid"] + 500.times do + post Runtime::API::Request.new(@api_client, "/projects/#{@group_name}%2F#{@project_name}/merge_requests/#{iid}/discussions").url, "body=\"Let us discuss\"" + end + @urls[:large_mr] = JSON.parse(create_mr_response.body)["web_url"] + STDOUT.puts "Created MR with 500 Discussions and 20 Very Large Files" + end + end + end +end diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb index 62c81050bd9..0ded33a73a2 100644 --- a/qa/spec/git/repository_spec.rb +++ b/qa/spec/git/repository_spec.rb @@ -39,7 +39,7 @@ describe QA::Git::Repository do describe '#clone' do it 'is unable to resolve host' do - expect(repository.clone).to include("fatal: unable to access 'http://root@foo/bar.git/'") + expect { repository.clone }.to raise_error(described_class::RepositoryCommandError, /The command .* failed \(128\) with the following output/) end end @@ -49,7 +49,7 @@ describe QA::Git::Repository do end it 'fails to push changes' do - expect(repository.push_changes).to include("error: failed to push some refs to 'http://root@foo/bar.git'") + expect { repository.push_changes }.to raise_error(described_class::RepositoryCommandError, /The command .* failed \(1\) with the following output/) end end |