diff options
Diffstat (limited to 'qa')
-rw-r--r-- | qa/Gemfile.lock | 2 | ||||
-rw-r--r-- | qa/README.md | 8 | ||||
-rw-r--r-- | qa/qa.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/component/groups_filter.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/dashboard/groups.rb | 5 | ||||
-rw-r--r-- | qa/qa/page/group/show.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/main/login.rb | 25 | ||||
-rw-r--r-- | qa/qa/page/project/new.rb | 3 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 22 | ||||
-rw-r--r-- | qa/qa/runtime/user.rb | 18 | ||||
-rw-r--r-- | qa/qa/scenario/test/sanity/framework.rb (renamed from qa/qa/scenario/test/sanity/failing.rb) | 7 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb | 4 | ||||
-rw-r--r-- | qa/qa/specs/features/sanity/failing_spec.rb | 13 | ||||
-rw-r--r-- | qa/qa/specs/features/sanity/framework_spec.rb | 23 | ||||
-rw-r--r-- | qa/qa/specs/runner.rb | 7 | ||||
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 21 | ||||
-rw-r--r-- | qa/spec/scenario/test/sanity/framework_spec.rb | 5 | ||||
-rw-r--r-- | qa/spec/specs/runner_spec.rb | 60 |
18 files changed, 138 insertions, 95 deletions
diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index 8f523e55adc..8d28fcacc05 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -32,7 +32,7 @@ GEM diff-lcs (1.3) domain_name (0.5.20170404) unf (>= 0.0.5, < 1.0.0) - ffi (1.9.18) + ffi (1.9.25) http-cookie (1.0.3) domain_name (~> 0.5) i18n (0.9.1) diff --git a/qa/README.md b/qa/README.md index f8a5c00efd4..746bd5cf94b 100644 --- a/qa/README.md +++ b/qa/README.md @@ -78,13 +78,7 @@ If your user doesn't have permission to default sandbox group GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance::All https://gitlab.example.com ``` -In addition, the `GITLAB_USER_TYPE` can be set to "ldap" to sign in as an LDAP user: - -``` -GITLAB_USER_TYPE=ldap GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance::All https://gitlab.example.com -``` - -All [supported environment variables are here](https://gitlab.com/gitlab-org/gitlab-qa#supported-environment-variables). +All [supported environment variables are here](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-environment-variables). ### Building a Docker image to test @@ -100,7 +100,7 @@ module QA end module Sanity - autoload :Failing, 'qa/scenario/test/sanity/failing' + autoload :Framework, 'qa/scenario/test/sanity/framework' autoload :Selectors, 'qa/scenario/test/sanity/selectors' end end diff --git a/qa/qa/page/component/groups_filter.rb b/qa/qa/page/component/groups_filter.rb index 69d465e8ac7..e647d368f0f 100644 --- a/qa/qa/page/component/groups_filter.rb +++ b/qa/qa/page/component/groups_filter.rb @@ -7,7 +7,7 @@ module QA def self.included(base) base.view 'app/views/shared/groups/_search_form.html.haml' do element :groups_filter, 'search_field_tag :filter' - element :groups_filter_placeholder, 'Filter by name...' + element :groups_filter_placeholder, 'Search by name' end base.view 'app/views/shared/groups/_empty_state.html.haml' do @@ -27,7 +27,7 @@ module QA page.has_css?(element_selector_css(:groups_list_tree_container)) end - fill_in 'Filter by name...', with: name + fill_in 'Search by name', with: name end end end diff --git a/qa/qa/page/dashboard/groups.rb b/qa/qa/page/dashboard/groups.rb index 5654cc01e09..70c5f996ff8 100644 --- a/qa/qa/page/dashboard/groups.rb +++ b/qa/qa/page/dashboard/groups.rb @@ -4,6 +4,11 @@ module QA class Groups < Page::Base include Page::Component::GroupsFilter + view 'app/views/shared/groups/_search_form.html.haml' do + element :groups_filter, 'search_field_tag :filter' + element :groups_filter_placeholder, 'Search by name' + end + view 'app/views/dashboard/_groups_head.html.haml' do element :new_group_button, 'link_to _("New group")' end diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb index ac85f16d8af..6747f7f10b6 100644 --- a/qa/qa/page/group/show.rb +++ b/qa/qa/page/group/show.rb @@ -16,7 +16,7 @@ module QA end view 'app/assets/javascripts/groups/constants.js' do - element :no_result_text, 'Sorry, no groups or projects matched your search' + element :no_result_text, 'No groups or projects matched your search' end def go_to_subgroup(name) @@ -30,7 +30,7 @@ module QA def has_subgroup?(name) filter_by_name(name) - page.has_text?(/#{name}|Sorry, no groups or projects matched your search/, wait: 60) + page.has_text?(/#{name}|No groups or projects matched your search/, wait: 60) page.has_text?(name, wait: 0) end diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index afc8b66d878..08cf8da34fd 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -59,10 +59,31 @@ module QA Page::Menu::Main.act { has_personal_area? } end + def sign_in_using_admin_credentials + admin = QA::Factory::Resource::User.new.tap do |user| + user.username = QA::Runtime::User.admin_username + user.password = QA::Runtime::User.admin_password + end + + using_wait_time 0 do + sign_in_using_gitlab_credentials(admin) + end + + Page::Menu::Main.act { has_personal_area? } + end + def self.path '/users/sign_in' end + def sign_in_tab? + page.has_button?('Sign in') + end + + def ldap_tab? + page.has_link?('LDAP') + end + def switch_to_sign_in_tab click_on 'Sign in' end @@ -90,8 +111,8 @@ module QA end def sign_in_using_gitlab_credentials(user) - switch_to_sign_in_tab unless page.has_button?('Sign in') - switch_to_standard_tab if page.has_content?('LDAP') + switch_to_sign_in_tab unless sign_in_tab? + switch_to_standard_tab if ldap_tab? fill_in :user_login, with: user.username fill_in :user_password, with: user.password diff --git a/qa/qa/page/project/new.rb b/qa/qa/page/project/new.rb index 1fb569b0f29..0766c98da6f 100644 --- a/qa/qa/page/project/new.rb +++ b/qa/qa/page/project/new.rb @@ -11,6 +11,7 @@ module QA view 'app/views/projects/_new_project_fields.html.haml' do element :project_namespace_select element :project_namespace_field, 'namespaces_options' + element :project_name, 'text_field :name' element :project_path, 'text_field :path' element :project_description, 'text_area :description' element :project_create_button, "submit 'Create project'" @@ -32,7 +33,7 @@ module QA end def choose_name(name) - fill_in 'project_path', with: name + fill_in 'project_name', with: name end def add_description(description) diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 841c959045f..27ba915961d 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -3,8 +3,6 @@ module QA module Env extend self - attr_writer :user_type - # set to 'false' to have Chrome run visibly instead of headless def chrome_headless? (ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0 @@ -19,18 +17,6 @@ module QA ENV['PERSONAL_ACCESS_TOKEN'] end - # By default, "standard" denotes a standard GitLab user login. - # Set this to "ldap" if the user should be logged in via LDAP. - def user_type - return @user_type if defined?(@user_type) # rubocop:disable Gitlab/ModuleWithInstanceVariables - - ENV.fetch('GITLAB_USER_TYPE', 'standard').tap do |type| - unless %w(ldap standard).include?(type) - raise ArgumentError.new("Invalid user type '#{type}': must be 'ldap' or 'standard'") - end - end - end - def user_username ENV['GITLAB_USERNAME'] end @@ -39,6 +25,14 @@ module QA ENV['GITLAB_PASSWORD'] end + def admin_username + ENV['GITLAB_ADMIN_USERNAME'] + end + + def admin_password + ENV['GITLAB_ADMIN_PASSWORD'] + end + def forker? forker_username && forker_password end diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb index b016777c987..5eb7a210fce 100644 --- a/qa/qa/runtime/user.rb +++ b/qa/qa/runtime/user.rb @@ -7,25 +7,37 @@ module QA 'root' end + def default_password + '5iveL!fe' + end + def username Runtime::Env.user_username || default_username end def password - Runtime::Env.user_password || '5iveL!fe' + Runtime::Env.user_password || default_password end def ldap_user? - Runtime::Env.user_type == 'ldap' + Runtime::Env.ldap_username && Runtime::Env.ldap_password end def ldap_username - Runtime::Env.ldap_username || name + Runtime::Env.ldap_username || username end def ldap_password Runtime::Env.ldap_password || password end + + def admin_username + Runtime::Env.admin_username || default_username + end + + def admin_password + Runtime::Env.admin_password || default_password + end end end end diff --git a/qa/qa/scenario/test/sanity/failing.rb b/qa/qa/scenario/test/sanity/framework.rb index 03452f6693d..7835d2564f0 100644 --- a/qa/qa/scenario/test/sanity/failing.rb +++ b/qa/qa/scenario/test/sanity/framework.rb @@ -5,12 +5,13 @@ module QA module Test module Sanity ## - # This scenario exits with a 1 exit code. + # This scenario runs 1 passing example, and 1 failing example, and exits + # with a 1 exit code. # - class Failing < Template + class Framework < Template include Bootable - tags :failing + tags :framework end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb index c9958917be9..c296296def6 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb @@ -3,10 +3,6 @@ module QA context :manage, :orchestrated, :ldap do describe 'LDAP login' do - before do - Runtime::Env.user_type = 'ldap' - end - it 'user logs into GitLab using LDAP credentials' do Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } diff --git a/qa/qa/specs/features/sanity/failing_spec.rb b/qa/qa/specs/features/sanity/failing_spec.rb deleted file mode 100644 index 7e0480e9067..00000000000 --- a/qa/qa/specs/features/sanity/failing_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module QA - context 'Sanity checks', :orchestrated, :failing do - describe 'Failing orchestrated example' do - it 'always fails' do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - - expect(page).to have_text("These Aren't the Texts You're Looking For", wait: 1) - end - end - end -end diff --git a/qa/qa/specs/features/sanity/framework_spec.rb b/qa/qa/specs/features/sanity/framework_spec.rb new file mode 100644 index 00000000000..ee9d068eb3a --- /dev/null +++ b/qa/qa/specs/features/sanity/framework_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module QA + context 'Framework sanity checks', :orchestrated, :framework do + describe 'Passing orchestrated example' do + it 'succeeds' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + + Page::Main::Login.perform do |main_login| + expect(main_login.sign_in_tab?).to be(true) + end + end + end + + describe 'Failing orchestrated example' do + it 'fails' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + + expect(page).to have_text("These Aren't the Texts You're Looking For", wait: 1) + end + end + end +end diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb index 5b5699d8a93..fea0ef94df3 100644 --- a/qa/qa/specs/runner.rb +++ b/qa/qa/specs/runner.rb @@ -5,10 +5,12 @@ module QA class Runner < Scenario::Template attr_accessor :tty, :tags, :options + DEFAULT_TEST_PATH_ARGS = ['--', File.expand_path('./features', __dir__)].freeze + def initialize @tty = false @tags = [] - @options = [File.expand_path('./features', __dir__)] + @options = [] end def perform @@ -18,10 +20,11 @@ module QA if tags.any? tags.each { |tag| args.push(['--tag', tag.to_s]) } else - args.push(%w[--tag ~orchestrated]) + args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any? end args.push(options) + args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} } Runtime::Browser.configure! diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index 5493a33cd2a..d889d185a45 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -56,27 +56,6 @@ describe QA::Runtime::Env do end end - describe '.user_type' do - it 'returns standard if not defined' do - expect(described_class.user_type).to eq('standard') - end - - it 'returns standard as defined' do - stub_env('GITLAB_USER_TYPE', 'standard') - expect(described_class.user_type).to eq('standard') - end - - it 'returns ldap as defined' do - stub_env('GITLAB_USER_TYPE', 'ldap') - expect(described_class.user_type).to eq('ldap') - end - - it 'returns an error if invalid user type' do - stub_env('GITLAB_USER_TYPE', 'foobar') - expect { described_class.user_type }.to raise_error(ArgumentError) - end - end - describe '.forker?' do it 'returns false if no forker credentials are defined' do expect(described_class).not_to be_forker diff --git a/qa/spec/scenario/test/sanity/framework_spec.rb b/qa/spec/scenario/test/sanity/framework_spec.rb new file mode 100644 index 00000000000..44ac780556e --- /dev/null +++ b/qa/spec/scenario/test/sanity/framework_spec.rb @@ -0,0 +1,5 @@ +describe QA::Scenario::Test::Sanity::Framework do + it_behaves_like 'a QA scenario class' do + let(:tags) { [:framework] } + end +end diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb index b237b954889..cf22d1c9395 100644 --- a/qa/spec/specs/runner_spec.rb +++ b/qa/spec/specs/runner_spec.rb @@ -7,43 +7,65 @@ describe QA::Specs::Runner do end it 'excludes the orchestrated tag by default' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS]) subject.perform end context 'when tty is set' do - subject do - described_class.new.tap do |runner| - runner.tty = true - end - end + subject { described_class.new.tap { |runner| runner.tty = true } } it 'sets the `--tty` flag' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tty', '--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tty', '--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS]) subject.perform end end context 'when tags are set' do - subject do - described_class.new.tap do |runner| - runner.tags = %i[orchestrated github] - end - end + subject { described_class.new.tap { |runner| runner.tags = %i[orchestrated github] } } it 'focuses on the given tags' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tag', 'orchestrated', '--tag', 'github', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tag', 'orchestrated', '--tag', 'github', *described_class::DEFAULT_TEST_PATH_ARGS]) + + subject.perform + end + end + + context 'when "--tag smoke" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[--tag smoke] } } + + it 'focuses on the given tag without excluded the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', 'smoke', *described_class::DEFAULT_TEST_PATH_ARGS]) + + subject.perform + end + end + + context 'when "qa/specs/features/foo" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[qa/specs/features/foo] } } + + it 'passes the given tests path and excludes the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', '~orchestrated', 'qa/specs/features/foo']) subject.perform end end + + context 'when "-- qa/specs/features/foo" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[-- qa/specs/features/foo] } } + + it 'passes the given tests path and excludes the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', '~orchestrated', '--', 'qa/specs/features/foo']) + + subject.perform + end + end + + def expect_rspec_runner_arguments(arguments) + expect(RSpec::Core::Runner).to receive(:run) + .with(arguments, $stderr, $stdout) + .and_return(0) + end end end |