summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 15:09:08 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 15:09:08 +0000
commitb3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch)
treea91ca3a06abd4c3412775ac3c49b11e3151df2be /qa
parent5366964a10484c2783a646b35a6da9eece01b242 (diff)
downloadgitlab-ce-b3a736ed88a1db0391cd9881e70b987bab7d89d1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/project/show.rb35
-rw-r--r--qa/qa/resource/api_fabricator.rb6
-rw-r--r--qa/qa/resource/fork.rb52
-rw-r--r--qa/qa/resource/merge_request_from_fork.rb2
-rw-r--r--qa/qa/resource/project.rb33
-rw-r--r--qa/qa/runtime/env.rb4
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb2
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/move_project_create_fork_spec.rb53
8 files changed, 169 insertions, 18 deletions
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index c619bd6d6a3..61047c42fcc 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -7,6 +7,14 @@ module QA
include Page::Component::ClonePanel
include Page::Project::SubMenus::Settings
+ view 'app/assets/javascripts/repository/components/table/row.vue' do
+ element :file_name_link
+ end
+
+ view 'app/assets/javascripts/repository/components/table/index.vue' do
+ element :file_tree_table
+ end
+
view 'app/views/layouts/header/_new_dropdown.haml' do
element :new_menu_toggle
element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern
@@ -17,7 +25,8 @@ module QA
end
view 'app/views/projects/_home_panel.html.haml' do
- element :project_name
+ element :forked_from_link
+ element :project_name_content
end
view 'app/views/projects/_files.html.haml' do
@@ -37,10 +46,6 @@ module QA
element :quick_actions
end
- view 'app/views/projects/tree/_tree_content.html.haml' do
- element :file_tree
- end
-
view 'app/views/projects/tree/_tree_header.html.haml' do
element :add_to_tree
element :new_file_option
@@ -79,14 +84,18 @@ module QA
click_on 'Fork'
end
+ def forked_from?(parent_project_name)
+ has_element?(:forked_from_link, text: parent_project_name)
+ end
+
def click_file(filename)
- within_element(:file_tree) do
+ within_element(:file_tree_table) do
click_on filename
end
end
def click_commit(commit_msg)
- within_element(:file_tree) do
+ within_element(:file_tree_table) do
click_on commit_msg
end
end
@@ -96,6 +105,16 @@ module QA
click_link 'New issue'
end
+ def has_file?(name)
+ within_element(:file_tree_table) do
+ has_element?(:file_name_link, text: name)
+ end
+ end
+
+ def has_name?(name)
+ has_element?(:project_name_content, text: name)
+ end
+
def last_commit_content
find_element(:commit_content).text
end
@@ -113,7 +132,7 @@ module QA
end
def project_name
- find('.qa-project-name').text
+ find_element(:project_name_content).text
end
def switch_to_branch(branch_name)
diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb
index 3c06f139738..cac58c599ea 100644
--- a/qa/qa/resource/api_fabricator.rb
+++ b/qa/qa/resource/api_fabricator.rb
@@ -8,10 +8,12 @@ module QA
module ApiFabricator
include Capybara::DSL
- ResourceNotFoundError = Class.new(RuntimeError)
ResourceFabricationFailedError = Class.new(RuntimeError)
- ResourceURLMissingError = Class.new(RuntimeError)
ResourceNotDeletedError = Class.new(RuntimeError)
+ ResourceNotFoundError = Class.new(RuntimeError)
+ ResourceQueryError = Class.new(RuntimeError)
+ ResourceUpdateFailedError = Class.new(RuntimeError)
+ ResourceURLMissingError = Class.new(RuntimeError)
attr_reader :api_resource, :api_response
attr_writer :api_client
diff --git a/qa/qa/resource/fork.rb b/qa/qa/resource/fork.rb
index 73f1b0b9695..854dd92e89c 100644
--- a/qa/qa/resource/fork.rb
+++ b/qa/qa/resource/fork.rb
@@ -3,19 +3,24 @@
module QA
module Resource
class Fork < Base
+ attribute :name do
+ upstream.name
+ end
+
attribute :project do
- Resource::Project.fabricate! do |resource|
- resource.name = upstream.project.name
- resource.path_with_namespace = "#{user.name}/#{upstream.project.name}"
+ Resource::Project.fabricate_via_api! do |resource|
+ resource.add_name_uuid = false
+ resource.name = name
+ resource.path_with_namespace = "#{user.username}/#{name}"
end
end
attribute :upstream do
- Repository::ProjectPush.fabricate!
+ Repository::ProjectPush.fabricate!.project
end
attribute :user do
- User.fabricate! do |resource|
+ User.fabricate_via_api! do |resource|
if Runtime::Env.forker?
resource.username = Runtime::Env.forker_username
resource.password = Runtime::Env.forker_password
@@ -33,7 +38,7 @@ module QA
login.sign_in_using_credentials(user: user)
end
- upstream.project.visit!
+ upstream.visit!
Page::Project::Show.perform(&:fork_project)
@@ -47,6 +52,41 @@ module QA
populate(:project)
end
+
+ def fabricate_via_api!
+ populate(:upstream, :user)
+
+ Runtime::Logger.debug("Forking project #{upstream.name} to namespace #{user.username}...")
+ super
+ wait_until_forked
+
+ populate(:project)
+ end
+
+ def api_get_path
+ "/projects/#{CGI.escape(path_with_namespace)}"
+ end
+
+ def api_post_path
+ "/projects/#{upstream.id}/fork"
+ end
+
+ def api_post_body
+ {
+ namespace: user.username,
+ name: name,
+ path: name
+ }
+ end
+
+ def wait_until_forked
+ Runtime::Logger.debug("Waiting for the fork process to complete...")
+ forked = wait_until do
+ project.import_status == "finished"
+ end
+
+ raise "Timed out while waiting for the fork process to complete." unless forked
+ end
end
end
end
diff --git a/qa/qa/resource/merge_request_from_fork.rb b/qa/qa/resource/merge_request_from_fork.rb
index 9cb4e6a49ca..d9c86b3b527 100644
--- a/qa/qa/resource/merge_request_from_fork.rb
+++ b/qa/qa/resource/merge_request_from_fork.rb
@@ -8,7 +8,7 @@ module QA
attr_accessor :fork_branch
attribute :fork do
- Fork.fabricate!
+ Fork.fabricate_via_browser_ui!
end
attribute :push do
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb
index f2ca0e0b8fd..62e55e18e9b 100644
--- a/qa/qa/resource/project.rb
+++ b/qa/qa/resource/project.rb
@@ -94,6 +94,10 @@ module QA
"#{api_get_path}/runners"
end
+ def api_put_path
+ "/projects/#{id}"
+ end
+
def api_post_path
'/projects'
end
@@ -115,6 +119,35 @@ module QA
post_body
end
+ def change_repository_storage(new_storage)
+ put_body = { repository_storage: new_storage }
+ response = put Runtime::API::Request.new(api_client, api_put_path).url, put_body
+
+ unless response.code == HTTP_STATUS_OK
+ raise ResourceUpdateFailedError, "Could not change repository storage to #{new_storage}. Request returned (#{response.code}): `#{response}`."
+ end
+
+ wait_until do
+ reload!
+
+ api_response[:repository_storage] == new_storage
+ end
+ end
+
+ def import_status
+ response = get Runtime::API::Request.new(api_client, "/projects/#{id}/import").url
+
+ unless response.code == HTTP_STATUS_OK
+ raise ResourceQueryError, "Could not get import status. Request returned (#{response.code}): `#{response}`."
+ end
+
+ result = parse_body(response)
+
+ Runtime::Logger.error("Import failed: #{result[:import_error]}") if result[:import_status] == "failed"
+
+ result[:import_status]
+ end
+
def runners(tag_list: nil)
response = get Runtime::API::Request.new(api_client, "#{api_runners_path}?tag_list=#{tag_list.compact.join(',')}").url
parse_body(response)
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 6514e41e279..1c947b0329f 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -22,6 +22,10 @@ module QA
SUPPORTED_FEATURES
end
+ def additional_repository_storage
+ ENV['QA_ADDITIONAL_REPOSITORY_STORAGE']
+ end
+
def admin_password
ENV['GITLAB_ADMIN_PASSWORD']
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
index 370bf30f3a4..7d4e6b7efbc 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
@@ -6,7 +6,7 @@ module QA
it 'user forks a project, submits a merge request and maintainer merges it' do
Flow::Login.sign_in
- merge_request = Resource::MergeRequestFromFork.fabricate! do |merge_request|
+ merge_request = Resource::MergeRequestFromFork.fabricate_via_browser_ui! do |merge_request|
merge_request.fork_branch = 'feature-branch'
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/move_project_create_fork_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/move_project_create_fork_spec.rb
new file mode 100644
index 00000000000..13fe8918f97
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/move_project_create_fork_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module QA
+ context 'Create' do
+ describe 'Gitaly repository storage', :orchestrated, :repository_storage, :requires_admin, quarantine: { type: :new } do
+ let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
+ let(:parent_project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.name = 'parent-project'
+ project.initialize_with_readme = true
+ end
+ end
+ let(:fork_project) do
+ Resource::Fork.fabricate_via_api! do |fork|
+ fork.user = user
+ fork.upstream = parent_project
+ end.project
+ end
+
+ before do
+ parent_project.add_member(user)
+ end
+
+ it 'creates a 2nd fork after moving the parent project' do
+ Flow::Login.sign_in(as: user)
+
+ fork_project.visit!
+
+ parent_project.change_repository_storage(QA::Runtime::Env.additional_repository_storage)
+
+ second_fork_project = Resource::Fork.fabricate_via_api! do |fork|
+ fork.name = "second-fork"
+ fork.user = user
+ fork.upstream = parent_project
+ end.project
+
+ Resource::Repository::ProjectPush.fabricate! do |push|
+ push.project = second_fork_project
+ push.file_name = 'new_file'
+ push.file_content = '# This is a new file'
+ push.commit_message = 'Add new file'
+ push.new_branch = false
+ end.project.visit!
+
+ Page::Project::Show.perform do |show|
+ expect(show).to have_file('new_file')
+ expect(show).to have_name(second_fork_project.name)
+ expect(show).to be_forked_from(parent_project.name)
+ end
+ end
+ end
+ end
+end