summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-20 12:21:56 +0000
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-11-22 11:18:07 +0100
commitdabd858812c6d342d095c69ef85aeba7af894121 (patch)
treec94cca8c978b755591b3eff61f6fba2a1e046f81 /qa
parent6369db0196ec7b6e288b16382c95243424a59b62 (diff)
downloadgitlab-ce-dabd858812c6d342d095c69ef85aeba7af894121.tar.gz
Backport QA code that belongs to CE from EE Geoqa/gb/backport-geo-integration-tests-commons
Merge branch 'qa/gb/add-geo-integration-tests' into 'master' See merge request gitlab-org/gitlab-ee!3294
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb14
-rw-r--r--qa/qa/page/admin/menu.rb7
-rw-r--r--qa/qa/page/admin/settings.rb18
-rw-r--r--qa/qa/page/base.rb17
-rw-r--r--qa/qa/page/dashboard/projects.rb11
-rw-r--r--qa/qa/page/main/menu.rb5
-rw-r--r--qa/qa/page/main/oauth.rb15
-rw-r--r--qa/qa/page/project/show.rb4
-rw-r--r--qa/qa/scenario/bootable.rb2
-rw-r--r--qa/qa/scenario/gitlab/admin/hashed_storage.rb25
-rw-r--r--qa/qa/shell/omnibus.rb39
11 files changed, 153 insertions, 4 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index dc1cd9abc6a..06b6a76489b 100644
--- a/qa/qa.rb
+++ b/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
@@ -98,6 +105,13 @@ module QA
end
##
+ # Classes describing shell interaction with GitLab
+ #
+ module Shell
+ autoload :Omnibus, 'qa/shell/omnibus'
+ end
+
+ ##
# Classes that make it possible to execute features tests.
#
module Specs
diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb
index baa06b1c75e..dd289ffe269 100644
--- a/qa/qa/page/admin/menu.rb
+++ b/qa/qa/page/admin/menu.rb
@@ -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
diff --git a/qa/qa/page/admin/settings.rb b/qa/qa/page/admin/settings.rb
new file mode 100644
index 00000000000..39e2f2062ad
--- /dev/null
+++ b/qa/qa/page/admin/settings.rb
@@ -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
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index bdddfb877c5..f9a93ef051e 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -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
diff --git a/qa/qa/page/dashboard/projects.rb b/qa/qa/page/dashboard/projects.rb
new file mode 100644
index 00000000000..7ed27da6d89
--- /dev/null
+++ b/qa/qa/page/dashboard/projects.rb
@@ -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
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb
index 178c5ea6930..bc9c4ec1215 100644
--- a/qa/qa/page/main/menu.rb
+++ b/qa/qa/page/main/menu.rb
@@ -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
diff --git a/qa/qa/page/main/oauth.rb b/qa/qa/page/main/oauth.rb
new file mode 100644
index 00000000000..e746cff0a80
--- /dev/null
+++ b/qa/qa/page/main/oauth.rb
@@ -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
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index 68d9597c4d2..3b2bac84f3f 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -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
diff --git a/qa/qa/scenario/bootable.rb b/qa/qa/scenario/bootable.rb
index cf8996cd597..d6de4d404c8 100644
--- a/qa/qa/scenario/bootable.rb
+++ b/qa/qa/scenario/bootable.rb
@@ -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
diff --git a/qa/qa/scenario/gitlab/admin/hashed_storage.rb b/qa/qa/scenario/gitlab/admin/hashed_storage.rb
new file mode 100644
index 00000000000..ac2cd549829
--- /dev/null
+++ b/qa/qa/scenario/gitlab/admin/hashed_storage.rb
@@ -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
diff --git a/qa/qa/shell/omnibus.rb b/qa/qa/shell/omnibus.rb
new file mode 100644
index 00000000000..6b3628d3109
--- /dev/null
+++ b/qa/qa/shell/omnibus.rb
@@ -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