summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/Dockerfile2
-rw-r--r--qa/Gemfile12
-rw-r--r--qa/Gemfile.lock84
-rw-r--r--qa/qa.rb46
-rw-r--r--qa/qa/factory/base.rb16
-rw-r--r--qa/qa/factory/repository/push.rb45
-rw-r--r--qa/qa/factory/resource/group.rb23
-rw-r--r--qa/qa/factory/resource/project.rb40
-rw-r--r--qa/qa/factory/resource/sandbox.rb28
-rw-r--r--qa/qa/factory/settings/hashed_storage.rb22
-rw-r--r--qa/qa/runtime/scenario.rb8
-rw-r--r--qa/qa/scenario/gitlab/admin/hashed_storage.rb24
-rw-r--r--qa/qa/scenario/gitlab/group/create.rb27
-rw-r--r--qa/qa/scenario/gitlab/project/create.rb42
-rw-r--r--qa/qa/scenario/gitlab/repository/push.rb47
-rw-r--r--qa/qa/scenario/gitlab/sandbox/prepare.rb28
-rw-r--r--qa/qa/specs/features/project/create_spec.rb2
-rw-r--r--qa/qa/specs/features/repository/clone_spec.rb2
-rw-r--r--qa/qa/specs/features/repository/push_spec.rb4
19 files changed, 250 insertions, 252 deletions
diff --git a/qa/Dockerfile b/qa/Dockerfile
index 9b6ffff7c4d..ed2ee73bea0 100644
--- a/qa/Dockerfile
+++ b/qa/Dockerfile
@@ -1,4 +1,4 @@
-FROM ruby:2.3
+FROM ruby:2.4
LABEL maintainer "Grzegorz Bizon <grzegorz@gitlab.com>"
ENV DEBIAN_FRONTEND noninteractive
diff --git a/qa/Gemfile b/qa/Gemfile
index ff29824529f..4c866a3f893 100644
--- a/qa/Gemfile
+++ b/qa/Gemfile
@@ -1,8 +1,8 @@
source 'https://rubygems.org'
-gem 'pry-byebug', '~> 3.4.1', platform: :mri
-gem 'capybara', '~> 2.12.1'
-gem 'capybara-screenshot', '~> 1.0.14'
-gem 'rake', '~> 12.0.0'
-gem 'rspec', '~> 3.5'
-gem 'selenium-webdriver', '~> 2.53'
+gem 'pry-byebug', '~> 3.5.1', platform: :mri
+gem 'capybara', '~> 2.16.1'
+gem 'capybara-screenshot', '~> 1.0.18'
+gem 'rake', '~> 12.3.0'
+gem 'rspec', '~> 3.7'
+gem 'selenium-webdriver', '~> 3.8.0'
diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock
index 22d12b479cb..88d5fe834a0 100644
--- a/qa/Gemfile.lock
+++ b/qa/Gemfile.lock
@@ -1,78 +1,72 @@
GEM
remote: https://rubygems.org/
specs:
- addressable (2.5.0)
- public_suffix (~> 2.0, >= 2.0.2)
- byebug (9.0.6)
- capybara (2.12.1)
+ addressable (2.5.2)
+ public_suffix (>= 2.0.2, < 4.0)
+ byebug (9.1.0)
+ capybara (2.16.1)
addressable
- mime-types (>= 1.16)
+ mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
- capybara-screenshot (1.0.14)
+ capybara-screenshot (1.0.18)
capybara (>= 1.0, < 3)
launchy
- childprocess (0.7.0)
+ childprocess (0.8.0)
ffi (~> 1.0, >= 1.0.11)
- coderay (1.1.1)
+ coderay (1.1.2)
diff-lcs (1.3)
ffi (1.9.18)
launchy (2.4.3)
addressable (~> 2.3)
- method_source (0.8.2)
- mime-types (3.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2016.0521)
+ method_source (0.9.0)
+ mini_mime (1.0.0)
mini_portile2 (2.3.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
- pry (0.10.4)
+ pry (0.11.3)
coderay (~> 1.1.0)
- method_source (~> 0.8.1)
- slop (~> 3.4)
- pry-byebug (3.4.2)
- byebug (~> 9.0)
+ method_source (~> 0.9.0)
+ pry-byebug (3.5.1)
+ byebug (~> 9.1)
pry (~> 0.10)
- public_suffix (2.0.5)
- rack (2.0.1)
- rack-test (0.6.3)
- rack (>= 1.0)
- rake (12.0.0)
- rspec (3.5.0)
- rspec-core (~> 3.5.0)
- rspec-expectations (~> 3.5.0)
- rspec-mocks (~> 3.5.0)
- rspec-core (3.5.4)
- rspec-support (~> 3.5.0)
- rspec-expectations (3.5.0)
+ public_suffix (3.0.1)
+ rack (2.0.3)
+ rack-test (0.8.2)
+ rack (>= 1.0, < 3)
+ rake (12.3.0)
+ rspec (3.7.0)
+ rspec-core (~> 3.7.0)
+ rspec-expectations (~> 3.7.0)
+ rspec-mocks (~> 3.7.0)
+ rspec-core (3.7.0)
+ rspec-support (~> 3.7.0)
+ rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.5.0)
- rspec-mocks (3.5.0)
+ rspec-support (~> 3.7.0)
+ rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.5.0)
- rspec-support (3.5.0)
+ rspec-support (~> 3.7.0)
+ rspec-support (3.7.0)
rubyzip (1.2.1)
- selenium-webdriver (2.53.4)
+ selenium-webdriver (3.8.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
- websocket (~> 1.0)
- slop (3.6.0)
- websocket (1.2.4)
- xpath (2.0.0)
+ xpath (2.1.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
- capybara (~> 2.12.1)
- capybara-screenshot (~> 1.0.14)
- pry-byebug (~> 3.4.1)
- rake (~> 12.0.0)
- rspec (~> 3.5)
- selenium-webdriver (~> 2.53)
+ capybara (~> 2.16.1)
+ capybara-screenshot (~> 1.0.18)
+ pry-byebug (~> 3.5.1)
+ rake (~> 12.3.0)
+ rspec (~> 3.7)
+ selenium-webdriver (~> 3.8.0)
BUNDLED WITH
- 1.15.4
+ 1.16.0
diff --git a/qa/qa.rb b/qa/qa.rb
index 0294fc28edf..f473686d344 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -13,6 +13,27 @@ module QA
end
##
+ # GitLab QA fabrication mechanisms
+ #
+ module Factory
+ autoload :Base, 'qa/factory/base'
+
+ module Resource
+ autoload :Sandbox, 'qa/factory/resource/sandbox'
+ autoload :Group, 'qa/factory/resource/group'
+ autoload :Project, 'qa/factory/resource/project'
+ end
+
+ module Repository
+ autoload :Push, 'qa/factory/repository/push'
+ end
+
+ module Settings
+ autoload :HashedStorage, 'qa/factory/settings/hashed_storage'
+ end
+ end
+
+ ##
# GitLab QA Scenarios
#
module Scenario
@@ -34,31 +55,6 @@ module QA
autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
end
end
-
- ##
- # GitLab instance scenarios.
- #
- module Gitlab
- module Group
- autoload :Create, 'qa/scenario/gitlab/group/create'
- end
-
- module Project
- autoload :Create, 'qa/scenario/gitlab/project/create'
- end
-
- module Repository
- autoload :Push, 'qa/scenario/gitlab/repository/push'
- end
-
- module Sandbox
- autoload :Prepare, 'qa/scenario/gitlab/sandbox/prepare'
- end
-
- module Admin
- autoload :HashedStorage, 'qa/scenario/gitlab/admin/hashed_storage'
- end
- end
end
##
diff --git a/qa/qa/factory/base.rb b/qa/qa/factory/base.rb
new file mode 100644
index 00000000000..7b951a99b69
--- /dev/null
+++ b/qa/qa/factory/base.rb
@@ -0,0 +1,16 @@
+module QA
+ module Factory
+ class Base
+ def self.fabricate!(*args)
+ new.tap do |factory|
+ yield factory if block_given?
+ return factory.fabricate!(*args)
+ end
+ end
+
+ def fabricate!(*_args)
+ raise NotImplementedError
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb
new file mode 100644
index 00000000000..1d5375d8c76
--- /dev/null
+++ b/qa/qa/factory/repository/push.rb
@@ -0,0 +1,45 @@
+require "pry-byebug"
+
+module QA
+ module Factory
+ module Repository
+ class Push < Factory::Base
+ PAGE_REGEX_CHECK =
+ %r{\/#{Runtime::Namespace.sandbox_name}\/qa-test[^\/]+\/{1}[^\/]+\z}.freeze
+
+ attr_writer :file_name,
+ :file_content,
+ :commit_message,
+ :branch_name
+
+ def initialize
+ @file_name = 'file.txt'
+ @file_content = '# This is test project'
+ @commit_message = "Add #{@file_name}"
+ @branch_name = 'master'
+ end
+
+ def fabricate!
+ Git::Repository.perform do |repository|
+ repository.location = Page::Project::Show.act do
+ unless PAGE_REGEX_CHECK.match(current_path)
+ raise "To perform this scenario the current page should be project show."
+ end
+
+ choose_repository_clone_http
+ repository_location
+ end
+
+ repository.use_default_credentials
+ repository.clone
+ repository.configure_identity('GitLab QA', 'root@gitlab.com')
+
+ repository.add_file(@file_name, @file_content)
+ repository.commit(@commit_message)
+ repository.push_changes(@branch_name)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/resource/group.rb b/qa/qa/factory/resource/group.rb
new file mode 100644
index 00000000000..a081cd94d39
--- /dev/null
+++ b/qa/qa/factory/resource/group.rb
@@ -0,0 +1,23 @@
+module QA
+ module Factory
+ module Resource
+ class Group < Factory::Base
+ attr_writer :path, :description
+
+ def initialize
+ @path = Runtime::Namespace.name
+ @description = "QA test run at #{Runtime::Namespace.time}"
+ end
+
+ def fabricate!
+ Page::Group::New.perform do |group|
+ group.set_path(@path)
+ group.set_description(@description)
+ group.set_visibility('Private')
+ group.create
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/resource/project.rb b/qa/qa/factory/resource/project.rb
new file mode 100644
index 00000000000..64fcfb084bb
--- /dev/null
+++ b/qa/qa/factory/resource/project.rb
@@ -0,0 +1,40 @@
+require 'securerandom'
+
+module QA
+ module Factory
+ module Resource
+ class Project < Factory::Base
+ attr_writer :description
+
+ def name=(name)
+ @name = "#{name}-#{SecureRandom.hex(8)}"
+ end
+
+ def fabricate!
+ Factory::Resource::Sandbox.fabricate!
+
+ Page::Group::Show.perform do |page|
+ if page.has_subgroup?(Runtime::Namespace.name)
+ page.go_to_subgroup(Runtime::Namespace.name)
+ else
+ page.go_to_new_subgroup
+
+ Factory::Resource::Group.fabricate! do |group|
+ group.path = Runtime::Namespace.name
+ end
+ end
+
+ page.go_to_new_project
+ end
+
+ Page::Project::New.perform do |page|
+ page.choose_test_namespace
+ page.choose_name(@name)
+ page.add_description(@description)
+ page.create_new_project
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/resource/sandbox.rb b/qa/qa/factory/resource/sandbox.rb
new file mode 100644
index 00000000000..fd2177915c5
--- /dev/null
+++ b/qa/qa/factory/resource/sandbox.rb
@@ -0,0 +1,28 @@
+module QA
+ module Factory
+ module Resource
+ ##
+ # Ensure we're in our sandbox namespace, either by navigating to it or by
+ # creating it if it doesn't yet exist.
+ #
+ class Sandbox < Factory::Base
+ def fabricate!
+ Page::Main::Menu.act { go_to_groups }
+
+ Page::Dashboard::Groups.perform do |page|
+ if page.has_group?(Runtime::Namespace.sandbox_name)
+ page.go_to_group(Runtime::Namespace.sandbox_name)
+ else
+ page.go_to_new_group
+
+ Resource::Group.fabricate! do |group|
+ group.path = Runtime::Namespace.sandbox_name
+ group.description = 'GitLab QA Sandbox'
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/settings/hashed_storage.rb b/qa/qa/factory/settings/hashed_storage.rb
new file mode 100644
index 00000000000..eb3b28f2613
--- /dev/null
+++ b/qa/qa/factory/settings/hashed_storage.rb
@@ -0,0 +1,22 @@
+module QA
+ module Factory
+ module Settings
+ class HashedStorage < Factory::Base
+ def fabricate!(*traits)
+ raise ArgumentError unless traits.include?(:enabled)
+
+ 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
diff --git a/qa/qa/runtime/scenario.rb b/qa/qa/runtime/scenario.rb
index 7ef59046640..15d4112d347 100644
--- a/qa/qa/runtime/scenario.rb
+++ b/qa/qa/runtime/scenario.rb
@@ -6,13 +6,15 @@ module QA
module Scenario
extend self
- attr_reader :attributes
+ def attributes
+ @attributes ||= {}
+ end
def define(attribute, value)
- (@attributes ||= {}).store(attribute.to_sym, value)
+ attributes.store(attribute.to_sym, value)
define_singleton_method(attribute) do
- @attributes[attribute.to_sym].tap do |value|
+ attributes[attribute.to_sym].tap do |value|
if value.to_s.empty?
raise ArgumentError, "Empty `#{attribute}` attribute!"
end
diff --git a/qa/qa/scenario/gitlab/admin/hashed_storage.rb b/qa/qa/scenario/gitlab/admin/hashed_storage.rb
deleted file mode 100644
index 44604c6bc66..00000000000
--- a/qa/qa/scenario/gitlab/admin/hashed_storage.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module QA
- module Scenario
- module Gitlab
- module Admin
- class HashedStorage < Scenario::Template
- def perform(*traits)
- raise ArgumentError unless traits.include?(:enabled)
-
- 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/scenario/gitlab/group/create.rb b/qa/qa/scenario/gitlab/group/create.rb
deleted file mode 100644
index 8e6c7c7ad80..00000000000
--- a/qa/qa/scenario/gitlab/group/create.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'securerandom'
-
-module QA
- module Scenario
- module Gitlab
- module Group
- class Create < Scenario::Template
- attr_writer :path, :description
-
- def initialize
- @path = Runtime::Namespace.name
- @description = "QA test run at #{Runtime::Namespace.time}"
- end
-
- def perform
- Page::Group::New.perform do |group|
- group.set_path(@path)
- group.set_description(@description)
- group.set_visibility('Private')
- group.create
- end
- end
- end
- end
- end
- end
-end
diff --git a/qa/qa/scenario/gitlab/project/create.rb b/qa/qa/scenario/gitlab/project/create.rb
deleted file mode 100644
index bb3b9e19c0f..00000000000
--- a/qa/qa/scenario/gitlab/project/create.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'securerandom'
-
-module QA
- module Scenario
- module Gitlab
- module Project
- class Create < Scenario::Template
- attr_writer :description
-
- def name=(name)
- @name = "#{name}-#{SecureRandom.hex(8)}"
- end
-
- def perform
- Scenario::Gitlab::Sandbox::Prepare.perform
-
- Page::Group::Show.perform do |page|
- if page.has_subgroup?(Runtime::Namespace.name)
- page.go_to_subgroup(Runtime::Namespace.name)
- else
- page.go_to_new_subgroup
-
- Scenario::Gitlab::Group::Create.perform do |group|
- group.path = Runtime::Namespace.name
- end
- end
-
- page.go_to_new_project
- end
-
- Page::Project::New.perform do |page|
- page.choose_test_namespace
- page.choose_name(@name)
- page.add_description(@description)
- page.create_new_project
- end
- end
- end
- end
- end
- end
-end
diff --git a/qa/qa/scenario/gitlab/repository/push.rb b/qa/qa/scenario/gitlab/repository/push.rb
deleted file mode 100644
index b00ab0c313a..00000000000
--- a/qa/qa/scenario/gitlab/repository/push.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require "pry-byebug"
-
-module QA
- module Scenario
- module Gitlab
- module Repository
- class Push < Scenario::Template
- PAGE_REGEX_CHECK =
- %r{\/#{Runtime::Namespace.sandbox_name}\/qa-test[^\/]+\/{1}[^\/]+\z}.freeze
-
- attr_writer :file_name,
- :file_content,
- :commit_message,
- :branch_name
-
- def initialize
- @file_name = 'file.txt'
- @file_content = '# This is test project'
- @commit_message = "Add #{@file_name}"
- @branch_name = 'master'
- end
-
- def perform
- Git::Repository.perform do |repository|
- repository.location = Page::Project::Show.act do
- unless PAGE_REGEX_CHECK.match(current_path)
- raise "To perform this scenario the current page should be project show."
- end
-
- choose_repository_clone_http
- repository_location
- end
-
- repository.use_default_credentials
- repository.clone
- repository.configure_identity('GitLab QA', 'root@gitlab.com')
-
- repository.add_file(@file_name, @file_content)
- repository.commit(@commit_message)
- repository.push_changes(@branch_name)
- end
- end
- end
- end
- end
- end
-end
diff --git a/qa/qa/scenario/gitlab/sandbox/prepare.rb b/qa/qa/scenario/gitlab/sandbox/prepare.rb
deleted file mode 100644
index 990de456e20..00000000000
--- a/qa/qa/scenario/gitlab/sandbox/prepare.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-module QA
- module Scenario
- module Gitlab
- module Sandbox
- # Ensure we're in our sandbox namespace, either by navigating to it or
- # by creating it if it doesn't yet exist
- class Prepare < Scenario::Template
- def perform
- Page::Main::Menu.act { go_to_groups }
-
- Page::Dashboard::Groups.perform do |page|
- if page.has_group?(Runtime::Namespace.sandbox_name)
- page.go_to_group(Runtime::Namespace.sandbox_name)
- else
- page.go_to_new_group
-
- Scenario::Gitlab::Group::Create.perform do |group|
- group.path = Runtime::Namespace.sandbox_name
- group.description = 'QA sandbox'
- end
- end
- end
- end
- end
- end
- end
- end
-end
diff --git a/qa/qa/specs/features/project/create_spec.rb b/qa/qa/specs/features/project/create_spec.rb
index 0b3accb848d..61c19378ae0 100644
--- a/qa/qa/specs/features/project/create_spec.rb
+++ b/qa/qa/specs/features/project/create_spec.rb
@@ -4,7 +4,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- Scenario::Gitlab::Project::Create.perform do |project|
+ Factory::Resource::Project.fabricate! do |project|
project.name = 'awesome-project'
project.description = 'create awesome project test'
end
diff --git a/qa/qa/specs/features/repository/clone_spec.rb b/qa/qa/specs/features/repository/clone_spec.rb
index c5c24622657..2adb7524a46 100644
--- a/qa/qa/specs/features/repository/clone_spec.rb
+++ b/qa/qa/specs/features/repository/clone_spec.rb
@@ -12,7 +12,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- Scenario::Gitlab::Project::Create.perform do |scenario|
+ Factory::Resource::Project.fabricate! do |scenario|
scenario.name = 'project-with-code'
scenario.description = 'project for git clone tests'
end
diff --git a/qa/qa/specs/features/repository/push_spec.rb b/qa/qa/specs/features/repository/push_spec.rb
index ef29dfa2d2f..e47c769b015 100644
--- a/qa/qa/specs/features/repository/push_spec.rb
+++ b/qa/qa/specs/features/repository/push_spec.rb
@@ -5,12 +5,12 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- Scenario::Gitlab::Project::Create.perform do |scenario|
+ Factory::Resource::Project.fabricate! do |scenario|
scenario.name = 'project_with_code'
scenario.description = 'project with repository'
end
- Scenario::Gitlab::Repository::Push.perform do |scenario|
+ Factory::Repository::Push.fabricate! do |scenario|
scenario.file_name = 'README.md'
scenario.file_content = '# This is test project'
scenario.commit_message = 'Add README.md'