Backport QA code that belongs to CE from EE Geo
Merge branch 'qa/gb/add-geo-integration-tests' into 'master' See merge request gitlab-org/gitlab-ee!3294
This commit is contained in:
parent
6369db0196
commit
dabd858812
11 changed files with 153 additions and 4 deletions
14
qa/qa.rb
14
qa/qa.rb
|
@ -49,6 +49,10 @@ module QA
|
|||
module Sandbox
|
||||
autoload :Prepare, 'qa/scenario/gitlab/sandbox/prepare'
|
||||
end
|
||||
|
||||
module Admin
|
||||
autoload :HashedStorage, 'qa/scenario/gitlab/admin/hashed_storage'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,9 +68,11 @@ module QA
|
|||
autoload :Entry, 'qa/page/main/entry'
|
||||
autoload :Login, 'qa/page/main/login'
|
||||
autoload :Menu, 'qa/page/main/menu'
|
||||
autoload :OAuth, 'qa/page/main/oauth'
|
||||
end
|
||||
|
||||
module Dashboard
|
||||
autoload :Projects, 'qa/page/dashboard/projects'
|
||||
autoload :Groups, 'qa/page/dashboard/groups'
|
||||
end
|
||||
|
||||
|
@ -82,6 +88,7 @@ module QA
|
|||
|
||||
module Admin
|
||||
autoload :Menu, 'qa/page/admin/menu'
|
||||
autoload :Settings, 'qa/page/admin/settings'
|
||||
end
|
||||
|
||||
module Mattermost
|
||||
|
@ -97,6 +104,13 @@ module QA
|
|||
autoload :Repository, 'qa/git/repository'
|
||||
end
|
||||
|
||||
##
|
||||
# Classes describing shell interaction with GitLab
|
||||
#
|
||||
module Shell
|
||||
autoload :Omnibus, 'qa/shell/omnibus'
|
||||
end
|
||||
|
||||
##
|
||||
# Classes that make it possible to execute features tests.
|
||||
#
|
||||
|
|
|
@ -3,8 +3,11 @@ module QA
|
|||
module Admin
|
||||
class Menu < Page::Base
|
||||
def go_to_license
|
||||
link = find_link 'License'
|
||||
link.click
|
||||
click_link 'License'
|
||||
end
|
||||
|
||||
def go_to_settings
|
||||
click_link 'Settings'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
18
qa/qa/page/admin/settings.rb
Normal file
18
qa/qa/page/admin/settings.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module QA
|
||||
module Page
|
||||
module Admin
|
||||
class Settings < Page::Base
|
||||
def enable_hashed_storage
|
||||
scroll_to 'legend', text: 'Repository Storage'
|
||||
check 'Create new projects using hashed storage paths'
|
||||
end
|
||||
|
||||
def save_settings
|
||||
scroll_to '.form-actions' do
|
||||
click_button 'Save'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
require 'capybara/dsl'
|
||||
|
||||
module QA
|
||||
module Page
|
||||
class Base
|
||||
|
@ -7,6 +9,21 @@ module QA
|
|||
def refresh
|
||||
visit current_url
|
||||
end
|
||||
|
||||
def scroll_to(selector, text: nil)
|
||||
page.execute_script <<~JS
|
||||
var elements = Array.from(document.querySelectorAll('#{selector}'));
|
||||
var text = '#{text}';
|
||||
|
||||
if (text.length > 0) {
|
||||
elements.find(e => e.textContent === text).scrollIntoView();
|
||||
} else {
|
||||
elements[0].scrollIntoView();
|
||||
}
|
||||
JS
|
||||
|
||||
page.within(selector) { yield } if block_given?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
qa/qa/page/dashboard/projects.rb
Normal file
11
qa/qa/page/dashboard/projects.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module QA
|
||||
module Page
|
||||
module Dashboard
|
||||
class Projects < Page::Base
|
||||
def go_to_project(name)
|
||||
find_link(text: name).click
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,10 @@ module QA
|
|||
end
|
||||
|
||||
def go_to_projects
|
||||
within_top_menu { click_link 'Projects' }
|
||||
within_top_menu do
|
||||
click_link 'Projects'
|
||||
click_link 'Your projects'
|
||||
end
|
||||
end
|
||||
|
||||
def go_to_admin_area
|
||||
|
|
15
qa/qa/page/main/oauth.rb
Normal file
15
qa/qa/page/main/oauth.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module QA
|
||||
module Page
|
||||
module Main
|
||||
class OAuth < Page::Base
|
||||
def needs_authorization?
|
||||
page.current_url.include?('/oauth')
|
||||
end
|
||||
|
||||
def authorize!
|
||||
click_button 'Authorize'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,6 +14,10 @@ module QA
|
|||
find('#project_clone').value
|
||||
end
|
||||
|
||||
def project_name
|
||||
find('.project-title').text
|
||||
end
|
||||
|
||||
def wait_for_push
|
||||
sleep 5
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ module QA
|
|||
|
||||
private
|
||||
|
||||
def attribute(name, arg, desc)
|
||||
def attribute(name, arg, desc = '')
|
||||
options.push(Option.new(name, arg, desc))
|
||||
end
|
||||
|
||||
|
|
25
qa/qa/scenario/gitlab/admin/hashed_storage.rb
Normal file
25
qa/qa/scenario/gitlab/admin/hashed_storage.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module QA
|
||||
module Scenario
|
||||
module Gitlab
|
||||
module Admin
|
||||
class HashedStorage < Scenario::Template
|
||||
def perform(*traits)
|
||||
raise ArgumentError unless traits.include?(:enabled)
|
||||
|
||||
Page::Main::Entry.act { visit_login_page }
|
||||
Page::Main::Login.act { sign_in_using_credentials }
|
||||
Page::Main::Menu.act { go_to_admin_area }
|
||||
Page::Admin::Menu.act { go_to_settings }
|
||||
|
||||
Page::Admin::Settings.act do
|
||||
enable_hashed_storage
|
||||
save_settings
|
||||
end
|
||||
|
||||
QA::Page::Main::Menu.act { sign_out }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
39
qa/qa/shell/omnibus.rb
Normal file
39
qa/qa/shell/omnibus.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'open3'
|
||||
|
||||
module QA
|
||||
module Shell
|
||||
class Omnibus
|
||||
include Scenario::Actable
|
||||
|
||||
def initialize(container)
|
||||
@name = container
|
||||
end
|
||||
|
||||
def gitlab_ctl(command, input: nil)
|
||||
if input.nil?
|
||||
shell "docker exec #{@name} gitlab-ctl #{command}"
|
||||
else
|
||||
shell "docker exec #{@name} bash -c '#{input} | gitlab-ctl #{command}'"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# TODO, make it possible to use generic QA framework classes
|
||||
# as a library - gitlab-org/gitlab-qa#94
|
||||
#
|
||||
def shell(command)
|
||||
puts "Executing `#{command}`"
|
||||
|
||||
Open3.popen2e(command) do |_in, out, wait|
|
||||
out.each { |line| puts line }
|
||||
|
||||
if wait.value.exited? && wait.value.exitstatus.nonzero?
|
||||
raise "Docker command `#{command}` failed!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue