diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-13 17:21:28 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-15 12:46:58 +0300 |
commit | 5c393b39ab561d615bfc08908bb9721699337dc8 (patch) | |
tree | 50a664688838d2a12ab22acacd766747e6c1a0ba /qa | |
parent | 8b436fb8f87878264508c78471e3e71e2d024aa0 (diff) |
Rename QA scenarios to make factory concept explicit
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 44 | ||||
-rw-r--r-- | qa/qa/factory/base.rb | 16 | ||||
-rw-r--r-- | qa/qa/factory/repository/push.rb | 45 | ||||
-rw-r--r-- | qa/qa/factory/resource/group.rb | 23 | ||||
-rw-r--r-- | qa/qa/factory/resource/project.rb | 40 | ||||
-rw-r--r-- | qa/qa/factory/resource/sandbox.rb | 28 | ||||
-rw-r--r-- | qa/qa/factory/settings/hashed_storage.rb | 22 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/admin/hashed_storage.rb | 24 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/group/create.rb | 27 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/project/create.rb | 42 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/repository/push.rb | 47 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/sandbox/prepare.rb | 28 |
12 files changed, 195 insertions, 191 deletions
@@ -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 @@ -35,29 +56,6 @@ module QA 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/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 |