Commit 9245db7c authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-ml-validate-after-visit-in-block' into 'master'

[EE] Validate page after visit in block

Closes gitlab-ce#62062

See merge request gitlab-org/gitlab-ee!13994
parents 4c42a061 5cc0f861
- form_field_classes = local_assigns[:admin_view] || !Feature.enabled?(:project_list_filter_bar) ? 'input-short js-projects-list-filter' : '' - form_field_classes = local_assigns[:admin_view] || !Feature.enabled?(:project_list_filter_bar) ? 'input-short js-projects-list-filter' : ''
- placeholder = local_assigns[:search_form_placeholder] ? search_form_placeholder : 'Filter by name...' - placeholder = local_assigns[:search_form_placeholder] ? search_form_placeholder : 'Filter by name...'
= form_tag filter_projects_path, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f| = form_tag filter_projects_path, method: :get, class: 'project-filter-form qa-project-filter-form', id: 'project-filter-form' do |f|
= search_field_tag :name, params[:name], = search_field_tag :name, params[:name],
placeholder: placeholder, placeholder: placeholder,
class: "project-filter-form-field form-control #{form_field_classes}", class: "project-filter-form-field form-control #{form_field_classes}",
......
...@@ -35,6 +35,7 @@ module QA ...@@ -35,6 +35,7 @@ module QA
Geo::Secondary.act do Geo::Secondary.act do
replicate_database replicate_database
wait_for_services wait_for_services
authorize
end end
end end
...@@ -105,6 +106,19 @@ module QA ...@@ -105,6 +106,19 @@ module QA
@name = QA::Runtime::Scenario.geo_secondary_name @name = QA::Runtime::Scenario.geo_secondary_name
end end
def authorize
# Provide OAuth authorization now so that tests don't have to
QA::Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
QA::Page::Main::Login.perform(&:sign_in_using_credentials)
QA::Page::Main::OAuth.perform do |oauth|
oauth.authorize! if oauth.needs_authorization?
end
# Log out so that tests are in an initially unauthenticated state
QA::Page::Main::Menu.perform(&:sign_out)
end
end
def replicate_database def replicate_database
puts 'Starting Geo replication on secondary node ...' puts 'Starting Geo replication on secondary node ...'
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
prepend QA::EE::Page::Dashboard::Projects prepend QA::EE::Page::Dashboard::Projects
view 'app/views/shared/projects/_search_form.html.haml' do view 'app/views/shared/projects/_search_form.html.haml' do
element :form_filter_by_name, /form_tag.+id: 'project-filter-form'/ # rubocop:disable QA/ElementWithPattern element :project_filter_form, required: true
end end
def go_to_project(name) def go_to_project(name)
...@@ -16,10 +16,14 @@ module QA ...@@ -16,10 +16,14 @@ module QA
find_link(text: name).click find_link(text: name).click
end end
def self.path
'/'
end
private private
def filter_by_name(name) def filter_by_name(name)
page.within('form#project-filter-form') do within_element(:project_filter_form) do
fill_in :name, with: name fill_in :name, with: name
end end
end end
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
class Address class Address
attr_reader :address attr_reader :address
def initialize(instance, page = nil) def initialize(instance, page)
@instance = instance @instance = instance
@address = host + (page.is_a?(String) ? page : page&.path) @address = host + (page.is_a?(String) ? page : page&.path)
end end
......
...@@ -28,13 +28,12 @@ module QA ...@@ -28,13 +28,12 @@ module QA
# In case of an address that is a symbol we will try to guess address # In case of an address that is a symbol we will try to guess address
# based on `Runtime::Scenario#something_address`. # based on `Runtime::Scenario#something_address`.
# #
def visit(address, page = nil, &block) def visit(address, page_class, &block)
Browser::Session.new(address, page).perform(&block) Browser::Session.new(address, page_class).perform(&block)
end end
def self.visit(address, page = nil, &block) def self.visit(address, page_class, &block)
new.visit(address, page, &block) new.visit(address, page_class, &block)
page.validate_elements_present!
end end
def self.configure! def self.configure!
...@@ -129,8 +128,11 @@ module QA ...@@ -129,8 +128,11 @@ module QA
class Session class Session
include Capybara::DSL include Capybara::DSL
def initialize(instance, page = nil) attr_reader :page_class
@session_address = Runtime::Address.new(instance, page)
def initialize(instance, page_class)
@session_address = Runtime::Address.new(instance, page_class)
@page_class = page_class
end end
def url def url
...@@ -140,6 +142,8 @@ module QA ...@@ -140,6 +142,8 @@ module QA
def perform(&block) def perform(&block)
visit(url) visit(url)
page_class.validate_elements_present!
if QA::Runtime::Env.qa_cookies if QA::Runtime::Env.qa_cookies
browser = Capybara.current_session.driver.browser browser = Capybara.current_session.driver.browser
QA::Runtime::Env.qa_cookies.each do |cookie| QA::Runtime::Env.qa_cookies.each do |cookie|
......
...@@ -5,61 +5,67 @@ module QA ...@@ -5,61 +5,67 @@ module QA
describe 'GitLab Geo attachment replication' do describe 'GitLab Geo attachment replication' do
let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) } let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
it 'user uploads attachment to the primary node' do it 'user uploads attachment to the primary node' do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
project = Resource::Project.fabricate! do |project| @project = Resource::Project.fabricate! do |project|
project.name = 'project-for-issues' project.name = 'project-for-issues'
project.description = 'project for adding issues' project.description = 'project for adding issues'
end end
issue = Resource::Issue.fabricate! do |issue| @issue = Resource::Issue.fabricate! do |issue|
issue.title = 'My geo issue' issue.title = 'My geo issue'
issue.project = project issue.project = @project
end end
Page::Project::Issue::Show.perform do |show| Page::Project::Issue::Show.perform do |show|
show.comment('See attached banana for scale', attachment: file_to_attach) show.comment('See attached banana for scale', attachment: file_to_attach)
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do |session| Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do |session|
Page::Main::OAuth.act do Page::Main::Login.perform(&:sign_in_using_credentials)
authorize! if needs_authorization?
end
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
expect(page).to have_content 'You are on a secondary, read-only Geo node' EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform do |menu| expect(page).to have_content 'You are on a secondary, read-only Geo node'
menu.go_to_projects
end
Page::Dashboard::Projects.perform do |dashboard| Page::Main::Menu.perform do |menu|
dashboard.wait_for_project_replication(project.name) menu.go_to_projects
end
dashboard.go_to_project(project.name) Page::Dashboard::Projects.perform do |dashboard|
end dashboard.wait_for_project_replication(@project.name)
Page::Project::Menu.act { click_issues } dashboard.go_to_project(@project.name)
end
Page::Project::Issue::Index.perform do |index| Page::Project::Menu.act { click_issues }
index.wait_for_issue_replication(issue)
end
image_url = find('a[href$="banana_sample.gif"]')[:href] Page::Project::Issue::Index.perform do |index|
index.wait_for_issue_replication(@issue)
end
Page::Project::Issue::Show.perform do |show| image_url = find('a[href$="banana_sample.gif"]')[:href]
# Wait for attachment replication
found = show.wait(reload: false) do
show.asset_exists?(image_url)
end
expect(found).to be_truthy Page::Project::Issue::Show.perform do |show|
# Wait for attachment replication
found = show.wait(reload: false) do
show.asset_exists?(image_url)
end end
expect(found).to be_truthy
end end
end end
end end
......
...@@ -5,13 +5,22 @@ module QA ...@@ -5,13 +5,22 @@ module QA
describe 'GitLab HTTP push' do describe 'GitLab HTTP push' do
let(:file_name) { 'README.md' } let(:file_name) { 'README.md' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is replicated to the secondary' do it 'is replicated to the secondary' do
file_content = 'This is a Geo project! Commit from primary.' file_content = 'This is a Geo project! Commit from primary.'
project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new Project # Create a new Project
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
...@@ -34,29 +43,29 @@ module QA ...@@ -34,29 +43,29 @@ module QA
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login # Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? } Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform { |menu| menu.go_to_projects }
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Validate the content has been sync'd from the primary # Validate the content has been sync'd from the primary
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name) show.wait_for_repository_replication_with(file_name)
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end
end end
end end
end end
...@@ -66,10 +75,11 @@ module QA ...@@ -66,10 +75,11 @@ module QA
it 'is replicated to the secondary' do it 'is replicated to the secondary' do
file_content = 'This is a Geo project!' file_content = 'This is a Geo project!'
lfs_file_content = 'The rendered file could not be displayed because it is stored in LFS.' lfs_file_content = 'The rendered file could not be displayed because it is stored in LFS.'
project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new Project # Create a new Project
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
...@@ -95,29 +105,29 @@ module QA ...@@ -95,29 +105,29 @@ module QA
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(lfs_file_content) expect(page).to have_content(lfs_file_content)
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login # Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? } Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform { |menu| menu.go_to_projects }
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Validate the content has been sync'd from the primary # Validate the content has been sync'd from the primary
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name) show.wait_for_repository_replication_with(file_name)
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(lfs_file_content) expect(page).to have_content(lfs_file_content)
end
end end
end end
end end
......
...@@ -6,9 +6,18 @@ module QA ...@@ -6,9 +6,18 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' } let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' } let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is redirected to the primary and ultimately replicated to the secondary' do it 'is redirected to the primary and ultimately replicated to the secondary' do
file_name = 'README.md' file_name = 'README.md'
project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
...@@ -31,54 +40,54 @@ module QA ...@@ -31,54 +40,54 @@ module QA
push.commit_message = "Add #{file_name}" push.commit_message = "Add #{file_name}"
end end
project.visit! project.visit!
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Page::Dashboard::Projects.perform do |dashboard|
# Visit the secondary node and login dashboard.wait_for_project_replication(project.name)
Page::Main::OAuth.act { authorize! if needs_authorization? } dashboard.go_to_project(project.name)
end
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner # Grab the HTTP URI for the secondary and store as 'location'
end location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
Page::Main::Menu.perform(&:go_to_projects) project_page.repository_clone_http_location
end
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) # Perform a git push over HTTP at the secondary
dashboard.go_to_project(project.name) push = Resource::Repository::Push.fabricate! do |push|
end push.new_branch = false
push.repository_http_uri = location.uri
# Grab the HTTP URI for the secondary and store as 'location' push.file_name = file_name
location = Page::Project::Show.perform do |project_page| push.file_content = "# #{file_content_secondary}"
project_page.wait_for_repository_replication push.commit_message = "Update #{file_name}"
project_page.repository_clone_http_location end
end
# We need to strip off the user from the URI, otherwise we won't
# Perform a git push over HTTP at the secondary # get the correct output produced from the git CLI.
push = Resource::Repository::Push.fabricate! do |push| primary_uri = project.repository_http_location.uri
push.new_branch = false primary_uri.user = nil
push.repository_http_uri = location.uri
push.file_name = file_name # The git cli produces the 'warning: redirecting to..' output
push.file_content = "# #{file_content_secondary}" # internally.
push.commit_message = "Update #{file_name}" expect(push.output).to match(/warning: redirecting to #{primary_uri.to_s}/)
end
# Validate git push worked and new content is visible
# We need to strip off the user from the URI, otherwise we won't Page::Project::Show.perform do |show|
# get the correct output produced from the git CLI. show.wait_for_repository_replication_with(file_content_secondary)
primary_uri = project.repository_http_location.uri show.refresh
primary_uri.user = nil
expect(page).to have_content(file_name)
# The git cli produces the 'warning: redirecting to..' output expect(page).to have_content(file_content_secondary)
# internally.
expect(push.output).to match(/warning: redirecting to #{primary_uri.to_s}/)
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_content_secondary)
show.refresh
expect(page).to have_content(file_name)
expect(page).to have_content(file_content_secondary)
end
end end
end end
end end
...@@ -88,6 +97,7 @@ module QA ...@@ -88,6 +97,7 @@ module QA
it 'is redirected to the primary and ultimately replicated to the secondary' do it 'is redirected to the primary and ultimately replicated to the secondary' do
file_name_primary = 'README.md' file_name_primary = 'README.md'
file_name_secondary = 'README_MORE.md' file_name_secondary = 'README_MORE.md'
project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
...@@ -110,55 +120,55 @@ module QA ...@@ -110,55 +120,55 @@ module QA
push.file_content = "# #{file_content_primary}" push.file_content = "# #{file_content_primary}"
push.commit_message = "Add #{file_name_primary}" push.commit_message = "Add #{file_name_primary}"
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the HTTP URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_http_location
end
# Perform a git push over HTTP at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.use_lfs = true
push.new_branch = false
push.repository_http_uri = location.uri
push.file_name = file_name_secondary
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Add #{file_name_secondary}"
end
# We need to strip off the user from the URI, otherwise we won't
# get the correct output produced from the git CLI.
primary_uri = project.repository_http_location.uri
primary_uri.user = nil
# The git cli produces the 'warning: redirecting to..' output
# internally.
expect(push.output).to match(/warning: redirecting to #{primary_uri.to_s}/)
expect(push.output).to match(/Locking support detected on remote "#{location.uri.to_s}"/)
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name_secondary)
show.refresh
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do expect(page).to have_content(file_name_secondary)
# Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? }
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the HTTP URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_http_location
end
# Perform a git push over HTTP at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.use_lfs = true
push.new_branch = false
push.repository_http_uri = location.uri
push.file_name = file_name_secondary
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Add #{file_name_secondary}"
end
# We need to strip off the user from the URI, otherwise we won't
# get the correct output produced from the git CLI.
primary_uri = project.repository_http_location.uri
primary_uri.user = nil
# The git cli produces the 'warning: redirecting to..' output
# internally.
expect(push.output).to match(/warning: redirecting to #{primary_uri.to_s}/)
expect(push.output).to match(/Locking support detected on remote "#{location.uri.to_s}"/)
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name_secondary)
show.refresh
expect(page).to have_content(file_name_secondary)
end
end end
end end
end end
......
...@@ -3,10 +3,18 @@ ...@@ -3,10 +3,18 @@
module QA module QA
context 'Geo', :orchestrated, :geo do context 'Geo', :orchestrated, :geo do
describe 'GitLab Geo project rename replication' do describe 'GitLab Geo project rename replication' do
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
it 'user renames project' do it 'user renames project' do
# create the project and push code # create the project and push code
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = 'geo-before-rename' project.name = 'geo-before-rename'
...@@ -32,42 +40,40 @@ module QA ...@@ -32,42 +40,40 @@ module QA
Page::Project::Menu.act { click_settings } Page::Project::Menu.act { click_settings }
geo_project_renamed = "geo-after-rename-#{SecureRandom.hex(8)}" @geo_project_renamed = "geo-after-rename-#{SecureRandom.hex(8)}"
Page::Project::Settings::Main.perform do |settings| Page::Project::Settings::Main.perform do |settings|
settings.rename_project_to(geo_project_renamed) settings.rename_project_to(@geo_project_renamed)
expect(page).to have_content "Project '#{geo_project_renamed}' was successfully updated." expect(page).to have_content "Project '#{@geo_project_renamed}' was successfully updated."
settings.expand_advanced_settings do |page| settings.expand_advanced_settings do |page|
page.update_project_path_to(geo_project_renamed) page.update_project_path_to(@geo_project_renamed)
end end
end end
end
# check renamed project exist on secondary node # check renamed project exist on secondary node
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
Page::Main::OAuth.act do Page::Main::Login.perform(&:sign_in_using_credentials)
authorize! if needs_authorization?
end
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
Page::Main::Menu.perform do |menu| Page::Main::Menu.perform do |menu|
menu.go_to_projects menu.go_to_projects
end end
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(geo_project_renamed) dashboard.wait_for_project_replication(@geo_project_renamed)
dashboard.go_to_project(geo_project_renamed) dashboard.go_to_project(@geo_project_renamed)
end end
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication show.wait_for_repository_replication
expect(page).to have_content 'README.md' expect(page).to have_content 'README.md'
expect(page).to have_content 'This is Geo project!' expect(page).to have_content 'This is Geo project!'
end
end end
end end
end end
......
...@@ -5,14 +5,24 @@ module QA ...@@ -5,14 +5,24 @@ module QA
describe 'GitLab SSH push' do describe 'GitLab SSH push' do
let(:file_name) { 'README.md' } let(:file_name) { 'README.md' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it "is replicated to the secondary" do it "is replicated to the secondary" do
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from primary.' file_content = 'This is a Geo project! Commit from primary.'
project = nil
key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
...@@ -41,36 +51,36 @@ module QA ...@@ -41,36 +51,36 @@ module QA
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login # Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? } Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
# Ensure the SSH key has replicated # Ensure the SSH key has replicated
Page::Main::Menu.act { click_settings_link } Page::Main::Menu.act { click_settings_link }
Page::Profile::Menu.act { click_ssh_keys } Page::Profile::Menu.act { click_ssh_keys }
expect(page).to have_content(key_title) expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint) expect(page).to have_content(key.fingerprint)
# Ensure project has replicated # Ensure project has replicated
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform { |menu| menu.go_to_projects }
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Validate the content has been sync'd from the primary # Validate the content has been sync'd from the primary
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_content) show.wait_for_repository_replication_with(file_content)
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end
end end
end end
end end
...@@ -80,10 +90,12 @@ module QA ...@@ -80,10 +90,12 @@ module QA
it "is replicated to the secondary" do it "is replicated to the secondary" do
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'The rendered file could not be displayed because it is stored in LFS.' file_content = 'The rendered file could not be displayed because it is stored in LFS.'
project = nil
key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
...@@ -115,36 +127,36 @@ module QA ...@@ -115,36 +127,36 @@ module QA
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login # Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? } Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
# Ensure the SSH key has replicated # Ensure the SSH key has replicated
Page::Main::Menu.act { click_settings_link } Page::Main::Menu.act { click_settings_link }
Page::Profile::Menu.act { click_ssh_keys } Page::Profile::Menu.act { click_ssh_keys }
expect(page).to have_content(key_title) expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint) expect(page).to have_content(key.fingerprint)
# Ensure project has replicated # Ensure project has replicated
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform { |menu| menu.go_to_projects }
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Validate the content has been sync'd from the primary # Validate the content has been sync'd from the primary
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name) show.wait_for_repository_replication_with(file_name)
expect(page).to have_content(file_name) expect(page).to have_content(file_name)
expect(page).to have_content(file_content) expect(page).to have_content(file_content)
end
end end
end end
end end
......
...@@ -6,11 +6,21 @@ module QA ...@@ -6,11 +6,21 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' } let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' } let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is proxied to the primary and ultimately replicated to the secondary' do it 'is proxied to the primary and ultimately replicated to the secondary' do
file_name = 'README.md' file_name = 'README.md'
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from secondary.' file_content = 'This is a Geo project! Commit from secondary.'
project = nil
key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
...@@ -39,60 +49,60 @@ module QA ...@@ -39,60 +49,60 @@ module QA
push.commit_message = "Add #{file_name}" push.commit_message = "Add #{file_name}"
end end
project.visit! project.visit!
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
# Ensure the SSH key has replicated
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title)
end
expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint)
# Ensure project has replicated
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.new_branch = false
push.ssh_key = key
push.repository_ssh_uri = location.uri
push.file_name = file_name
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Update #{file_name}"
end
# Remove ssh:// from the URI to ensure we can match accurately
# as ssh:// can appear depending on how GitLab is configured.
ssh_uri = project.repository_ssh_location.git_uri.to_s.gsub(%r{ssh://}, '')
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do expect(push.output).to match(%r{GitLab: We'll help you by proxying this request to the primary: (?:ssh://)?#{ssh_uri}})
# Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? } # Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
EE::Page::Main::Banner.perform do |banner| show.wait_for_repository_replication_with(file_content)
expect(banner).to have_secondary_read_only_banner
end expect(page).to have_content(file_content)
# Ensure the SSH key has replicated
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title)
end
expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint)
# Ensure project has replicated
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.new_branch = false
push.ssh_key = key
push.repository_ssh_uri = location.uri
push.file_name = file_name
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Update #{file_name}"
end
# Remove ssh:// from the URI to ensure we can match accurately
# as ssh:// can appear depending on how GitLab is configured.
ssh_uri = project.repository_ssh_location.git_uri.to_s.gsub(%r{ssh://}, '')
expect(push.output).to match(%r{GitLab: We'll help you by proxying this request to the primary: (?:ssh://)?#{ssh_uri}})
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_content)
expect(page).to have_content(file_content)
end
end end
end end
end end
...@@ -103,6 +113,8 @@ module QA ...@@ -103,6 +113,8 @@ module QA
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
file_name_primary = 'README.md' file_name_primary = 'README.md'
file_name_secondary = 'README_MORE.md' file_name_secondary = 'README_MORE.md'
project = nil
key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
...@@ -131,60 +143,60 @@ module QA ...@@ -131,60 +143,60 @@ module QA
push.file_content = "# #{file_content_primary}" push.file_content = "# #{file_content_primary}"
push.commit_message = "Add #{file_name_primary}" push.commit_message = "Add #{file_name_primary}"
end end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
# Ensure the SSH key has replicated
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title)
end
expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint)
# Ensure project has replicated
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.use_lfs = true
push.new_branch = false
push.ssh_key = key
push.repository_ssh_uri = location.uri
push.file_name = file_name_secondary
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Add #{file_name_secondary}"
end
ssh_uri = project.repository_ssh_location.git_uri.to_s.gsub(%r{ssh://}, '')
expect(push.output).to match(%r{GitLab: We'll help you by proxying this request to the primary: (?:ssh://)?#{ssh_uri}})
expect(push.output).to match(/Locking support detected on remote "#{location.uri.to_s}"/)
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name_secondary)
show.refresh
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do expect(page).to have_content(file_name_secondary)
# Visit the secondary node and login
Page::Main::OAuth.act { authorize! if needs_authorization? }
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
# Ensure the SSH key has replicated
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title)
end
expect(page).to have_content(key_title)
expect(page).to have_content(key.fingerprint)
# Ensure project has replicated
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
# Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push|
push.use_lfs = true
push.new_branch = false
push.ssh_key = key
push.repository_ssh_uri = location.uri
push.file_name = file_name_secondary
push.file_content = "# #{file_content_secondary}"
push.commit_message = "Add #{file_name_secondary}"
end
ssh_uri = project.repository_ssh_location.git_uri.to_s.gsub(%r{ssh://}, '')
expect(push.output).to match(%r{GitLab: We'll help you by proxying this request to the primary: (?:ssh://)?#{ssh_uri}})
expect(push.output).to match(/Locking support detected on remote "#{location.uri.to_s}"/)
# Validate git push worked and new content is visible
Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_name_secondary)
show.refresh
expect(page).to have_content(file_name_secondary)
end
end end
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