Commit 5cc0f861 authored by Mark Lapierre's avatar Mark Lapierre

Separate node sessions

With nested blocks the inner block was still logged in when the test
tried to visit the login page of the secondary node, so the page
failed validation because it was already logged in.

This moves the secondary sessions outside the primary session block
so that the primary session ends and the secondary session can login.

It also logs out after each test so that subsequent tests aren't logged
in. Resetting the browser session (by using a visit block) isn't enough
to log out subsequent sessions
parent 18555cc4
- 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}",
......
...@@ -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,28 +5,35 @@ module QA ...@@ -5,28 +5,35 @@ 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| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
...@@ -39,15 +46,15 @@ module QA ...@@ -39,15 +46,15 @@ module QA
end end
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
Page::Project::Menu.act { click_issues } Page::Project::Menu.act { click_issues }
Page::Project::Issue::Index.perform do |index| Page::Project::Issue::Index.perform do |index|
index.wait_for_issue_replication(issue) index.wait_for_issue_replication(@issue)
end end
image_url = find('a[href$="banana_sample.gif"]')[:href] image_url = find('a[href$="banana_sample.gif"]')[:href]
...@@ -64,5 +71,4 @@ module QA ...@@ -64,5 +71,4 @@ module QA
end end
end 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,10 +43,11 @@ module QA ...@@ -34,10 +43,11 @@ 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
...@@ -60,16 +70,16 @@ module QA ...@@ -60,16 +70,16 @@ module QA
end end
end end
end end
end
context 'git-lfs commit' do context 'git-lfs commit' do
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,10 +105,11 @@ module QA ...@@ -95,10 +105,11 @@ 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
...@@ -123,5 +134,4 @@ module QA ...@@ -123,5 +134,4 @@ module QA
end end
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,10 +40,11 @@ module QA ...@@ -31,10 +40,11 @@ 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 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
...@@ -82,12 +92,12 @@ module QA ...@@ -82,12 +92,12 @@ module QA
end end
end end
end end
end
context 'git-lfs commit' do context 'git-lfs 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_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,10 +120,11 @@ module QA ...@@ -110,10 +120,11 @@ 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 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
...@@ -164,5 +175,4 @@ module QA ...@@ -164,5 +175,4 @@ module QA
end end
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,21 +40,20 @@ module QA ...@@ -32,21 +40,20 @@ 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
...@@ -57,9 +64,9 @@ module QA ...@@ -57,9 +64,9 @@ module QA
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|
...@@ -72,5 +79,4 @@ module QA ...@@ -72,5 +79,4 @@ module QA
end end
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,10 +51,11 @@ module QA ...@@ -41,10 +51,11 @@ 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
...@@ -74,16 +85,17 @@ module QA ...@@ -74,16 +85,17 @@ module QA
end end
end end
end end
end
context 'git-lfs commit' do context 'git-lfs 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 = '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,10 +127,11 @@ module QA ...@@ -115,10 +127,11 @@ 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
...@@ -150,5 +163,4 @@ module QA ...@@ -150,5 +163,4 @@ module QA
end end
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,10 +49,11 @@ module QA ...@@ -39,10 +49,11 @@ 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 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
...@@ -96,13 +107,14 @@ module QA ...@@ -96,13 +107,14 @@ module QA
end end
end end
end end
end
context 'git-lfs commit' do context 'git-lfs 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
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,10 +143,11 @@ module QA ...@@ -131,10 +143,11 @@ 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 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
...@@ -190,5 +203,4 @@ module QA ...@@ -190,5 +203,4 @@ module QA
end end
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