Commit 394a9207 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-ml-pull-mirroring-test' into 'master'

Add E2E test of pull mirroring with password auth

Closes gitlab-org/quality/testcases#119

See merge request gitlab-org/gitlab!16428
parents d175ad5e b479f65a
...@@ -49,12 +49,12 @@ ...@@ -49,12 +49,12 @@
= render_if_exists 'projects/mirrors/table_pull_row' = render_if_exists 'projects/mirrors/table_pull_row'
- @project.remote_mirrors.each_with_index do |mirror, index| - @project.remote_mirrors.each_with_index do |mirror, index|
- next if mirror.new_record? - next if mirror.new_record?
%tr.qa-mirrored-repository-row.rspec-mirrored-repository-row{ class: ('bg-secondary' if mirror.disabled?) } %tr.rspec-mirrored-repository-row{ class: ('bg-secondary' if mirror.disabled?), data: { qa_selector: 'mirrored_repository_row' } }
%td.qa-mirror-repository-url= mirror.safe_url || _('Invalid URL') %td{ data: { qa_selector: 'mirror_repository_url_cell' } }= mirror.safe_url || _('Invalid URL')
%td= _('Push') %td= _('Push')
%td %td
= mirror.last_update_started_at.present? ? time_ago_with_tooltip(mirror.last_update_started_at) : _('Never') = mirror.last_update_started_at.present? ? time_ago_with_tooltip(mirror.last_update_started_at) : _('Never')
%td.qa-mirror-last-update-at= mirror.last_update_at.present? ? time_ago_with_tooltip(mirror.last_update_at) : _('Never') %td{ data: { qa_selector: 'mirror_last_update_at_cell' } }= mirror.last_update_at.present? ? time_ago_with_tooltip(mirror.last_update_at) : _('Never')
%td %td
- if mirror.disabled? - if mirror.disabled?
= render 'projects/mirrors/disabled_mirror_badge' = render 'projects/mirrors/disabled_mirror_badge'
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
- return unless import_state - return unless import_state
%tr %tr{ data: { qa_selector: 'mirrored_repository_row' } }
%td.mirror-url= @project.safe_import_url %td.mirror-url{ data: { qa_selector: 'mirror_repository_url_cell' } }= @project.safe_import_url
%td= _('Pull') %td= _('Pull')
%td %td
= import_state.last_update_started_at.present? ? time_ago_with_tooltip(import_state.last_update_started_at) : _('Never') = import_state.last_update_started_at.present? ? time_ago_with_tooltip(import_state.last_update_started_at) : _('Never')
%td= import_state.last_update_at.present? ? time_ago_with_tooltip(import_state.last_update_at) : _('Never') %td{ data: { qa_selector: 'mirror_last_update_at_cell' } }= import_state.last_update_at.present? ? time_ago_with_tooltip(import_state.last_update_at) : _('Never')
%td %td
- if import_state&.last_error.present? - if import_state&.last_error.present?
.badge.badge-danger{ data: { toggle: 'tooltip', html: 'true' }, title: html_escape(import_state.last_error.try(:strip)) }= _('Error') .badge.badge-danger{ data: { toggle: 'tooltip', html: 'true' }, title: html_escape(import_state.last_error.try(:strip)) }= _('Error')
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
- if import_state.mirror_update_due? || import_state.updating_mirror? - if import_state.mirror_update_due? || import_state.updating_mirror?
%button.btn.disabled{ type: 'button', data: { container: 'body', toggle: 'tooltip' }, title: _('Updating') }= icon("refresh spin") %button.btn.disabled{ type: 'button', data: { container: 'body', toggle: 'tooltip' }, title: _('Updating') }= icon("refresh spin")
- else - else
= link_to update_now_project_mirror_path(@project), method: :post, class: 'btn js-force-update-mirror', data: { container: 'body', toggle: 'tooltip' }, title: _('Update now') do = link_to update_now_project_mirror_path(@project), method: :post, class: 'btn js-force-update-mirror', data: { container: 'body', toggle: 'tooltip', qa_selector: 'update_now_button' }, title: _('Update now') do
= icon("refresh") = icon("refresh")
%button.js-delete-mirror.js-delete-pull-mirror.btn.btn-danger{ type: 'button', data: { toggle: 'tooltip', container: 'body' }, title: _('Remove') }= icon('trash-o') %button.js-delete-mirror.js-delete-pull-mirror.btn.btn-danger{ type: 'button', data: { toggle: 'tooltip', container: 'body' }, title: _('Remove') }= icon('trash-o')
...@@ -11,6 +11,13 @@ module QA ...@@ -11,6 +11,13 @@ module QA
view 'ee/app/views/projects/mirrors/_mirror_repos_form.html.haml' do view 'ee/app/views/projects/mirrors/_mirror_repos_form.html.haml' do
element :mirror_direction element :mirror_direction
end end
view 'ee/app/views/projects/mirrors/_table_pull_row.html.haml' do
element :mirror_last_update_at_cell
element :mirror_repository_url_cell
element :mirrored_repository_row
element :update_now_button
end
end end
end end
end end
......
...@@ -13,8 +13,8 @@ module QA ...@@ -13,8 +13,8 @@ module QA
view 'app/views/projects/mirrors/_mirror_repos.html.haml' do view 'app/views/projects/mirrors/_mirror_repos.html.haml' do
element :mirror_repository_url_input element :mirror_repository_url_input
element :mirror_repository_button element :mirror_repository_button
element :mirror_repository_url element :mirror_repository_url_cell
element :mirror_last_update_at element :mirror_last_update_at_cell
element :mirrored_repository_row element :mirrored_repository_row
end end
...@@ -64,21 +64,21 @@ module QA ...@@ -64,21 +64,21 @@ module QA
wait(interval: 1) do wait(interval: 1) do
within_element_by_index(:mirrored_repository_row, row_index) do within_element_by_index(:mirrored_repository_row, row_index) do
last_update = find_element(:mirror_last_update_at, wait: 0) last_update = find_element(:mirror_last_update_at_cell, wait: 0)
last_update.has_text?('just now') || last_update.has_text?('seconds') last_update.has_text?('just now') || last_update.has_text?('seconds')
end end
end end
# Fail early if the page still shows that there has been no update # Fail early if the page still shows that there has been no update
within_element_by_index(:mirrored_repository_row, row_index) do within_element_by_index(:mirrored_repository_row, row_index) do
find_element(:mirror_last_update_at, wait: 0).assert_no_text('Never') find_element(:mirror_last_update_at_cell, wait: 0).assert_no_text('Never')
end end
end end
private private
def find_repository_row_index(target_url) def find_repository_row_index(target_url)
all_elements(:mirror_repository_url).index do |url| all_elements(:mirror_repository_url_cell).index do |url|
# The url might be a sanitized url but the target_url won't be so # The url might be a sanitized url but the target_url won't be so
# we compare just the paths instead of the full url # we compare just the paths instead of the full url
URI.parse(url.text).path == target_url.path URI.parse(url.text).path == target_url.path
......
...@@ -4,11 +4,12 @@ module QA ...@@ -4,11 +4,12 @@ module QA
module Resource module Resource
module Repository module Repository
class ProjectPush < Repository::Push class ProjectPush < Repository::Push
attr_accessor :project_name
attr_writer :wait_for_push attr_writer :wait_for_push
attribute :project do attribute :project do
Project.fabricate! do |resource| Project.fabricate! do |resource|
resource.name = 'project-with-code' resource.name = project_name
resource.description = 'Project with repository' resource.description = 'Project with repository'
end end
end end
...@@ -19,6 +20,7 @@ module QA ...@@ -19,6 +20,7 @@ module QA
@commit_message = "This is a test commit" @commit_message = "This is a test commit"
@branch_name = 'master' @branch_name = 'master'
@new_branch = true @new_branch = true
@project_name = 'project-with-code'
@wait_for_push = true @wait_for_push = true
end end
......
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Pull mirror a repository over HTTP' do
it 'configures and syncs a (pull) mirrored repository with password auth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
source = Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project_name = 'pull-mirror-source-project'
project_push.file_name = 'README.md'
project_push.file_content = '# This is a pull mirroring test project'
project_push.commit_message = 'Add README.md'
end
source_project_uri = source.project.repository_http_location.uri
source_project_uri.user = Runtime::User.username
target_project = Resource::Project.fabricate_via_api! do |project|
project.name = 'pull-mirror-target-project'
end
target_project.visit!
Page::Project::Menu.perform(&:go_to_repository_settings)
Page::Project::Settings::Repository.perform do |settings|
settings.expand_mirroring_repositories do |mirror_settings|
# Configure the target project to pull from the source project
mirror_settings.repository_url = source_project_uri
mirror_settings.mirror_direction = :pull
mirror_settings.authentication_method = :password
mirror_settings.password = Runtime::User.password
mirror_settings.mirror_repository
mirror_settings.update source_project_uri
end
end
# Check that the target project has the commit from the source
target_project.visit!
expect(page).to have_content("README.md")
expect(page).to have_content("This is a pull mirroring test project")
expect(page).to have_content("Mirrored from #{masked_url(source_project_uri)}")
end
def masked_url(url)
url.password = '*****'
url.user = '*****'
url
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment