Commit ed39f737 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'mk-qa-deprecation-toolkit' into 'master'

Enable Deprecation Toolkit for qa tests

See merge request gitlab-org/gitlab!67042
parents 25d84bd9 8d6e8a04
...@@ -8,7 +8,7 @@ gem 'allure-rspec', '~> 2.14.1' ...@@ -8,7 +8,7 @@ gem 'allure-rspec', '~> 2.14.1'
gem 'capybara', '~> 3.35.0' gem 'capybara', '~> 3.35.0'
gem 'capybara-screenshot', '~> 1.0.23' gem 'capybara-screenshot', '~> 1.0.23'
gem 'rake', '~> 12.3.3' gem 'rake', '~> 12.3.3'
gem 'rspec', '~> 3.7' gem 'rspec', '~> 3.10'
gem 'selenium-webdriver', '~> 4.0.0.beta4' gem 'selenium-webdriver', '~> 4.0.0.beta4'
gem 'airborne', '~> 0.3.4' gem 'airborne', '~> 0.3.4'
gem 'rest-client', '~> 2.1.0' gem 'rest-client', '~> 2.1.0'
...@@ -28,6 +28,8 @@ gem 'webdrivers', '~> 4.6' ...@@ -28,6 +28,8 @@ gem 'webdrivers', '~> 4.6'
gem 'chemlab', '~> 0.7' gem 'chemlab', '~> 0.7'
gem 'chemlab-library-www-gitlab-com', '~> 0.1' gem 'chemlab-library-www-gitlab-com', '~> 0.1'
gem 'deprecation_toolkit', '~> 1.5.1', require: false
group :development do group :development do
gem 'pry-byebug', '~> 3.5.1', platform: :mri gem 'pry-byebug', '~> 3.5.1', platform: :mri
gem "ruby-debug-ide", "~> 0.7.0" gem "ruby-debug-ide", "~> 0.7.0"
......
...@@ -56,6 +56,8 @@ GEM ...@@ -56,6 +56,8 @@ GEM
adamantium (~> 0.2.0) adamantium (~> 0.2.0)
equalizer (~> 0.0.9) equalizer (~> 0.0.9)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.9)
deprecation_toolkit (1.5.1)
activesupport (>= 4.2)
diff-lcs (1.3) diff-lcs (1.3)
domain_name (0.5.20190701) domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
...@@ -141,18 +143,18 @@ GEM ...@@ -141,18 +143,18 @@ GEM
netrc (~> 0.8) netrc (~> 0.8)
rexml (3.2.5) rexml (3.2.5)
rotp (3.1.0) rotp (3.1.0)
rspec (3.9.0) rspec (3.10.0)
rspec-core (~> 3.9.0) rspec-core (~> 3.10.0)
rspec-expectations (~> 3.9.0) rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.9.0) rspec-mocks (~> 3.10.0)
rspec-core (3.9.3) rspec-core (3.10.1)
rspec-support (~> 3.9.3) rspec-support (~> 3.10.0)
rspec-expectations (3.9.1) rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.10.0)
rspec-mocks (3.9.1) rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.10.0)
rspec-parameterized (0.4.2) rspec-parameterized (0.4.2)
binding_ninja (>= 0.2.3) binding_ninja (>= 0.2.3)
parser parser
...@@ -161,7 +163,7 @@ GEM ...@@ -161,7 +163,7 @@ GEM
unparser unparser
rspec-retry (0.6.1) rspec-retry (0.6.1)
rspec-core (> 3.3) rspec-core (> 3.3)
rspec-support (3.9.4) rspec-support (3.10.2)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
ruby-debug-ide (0.7.2) ruby-debug-ide (0.7.2)
...@@ -215,6 +217,7 @@ DEPENDENCIES ...@@ -215,6 +217,7 @@ DEPENDENCIES
capybara-screenshot (~> 1.0.23) capybara-screenshot (~> 1.0.23)
chemlab (~> 0.7) chemlab (~> 0.7)
chemlab-library-www-gitlab-com (~> 0.1) chemlab-library-www-gitlab-com (~> 0.1)
deprecation_toolkit (~> 1.5.1)
faker (~> 1.6, >= 1.6.6) faker (~> 1.6, >= 1.6.6)
gitlab-qa gitlab-qa
knapsack (~> 1.17) knapsack (~> 1.17)
...@@ -226,7 +229,7 @@ DEPENDENCIES ...@@ -226,7 +229,7 @@ DEPENDENCIES
rake (~> 12.3.3) rake (~> 12.3.3)
rest-client (~> 2.1.0) rest-client (~> 2.1.0)
rotp (~> 3.1.0) rotp (~> 3.1.0)
rspec (~> 3.7) rspec (~> 3.10)
rspec-parameterized (~> 0.4.2) rspec-parameterized (~> 0.4.2)
rspec-retry (~> 0.6.1) rspec-retry (~> 0.6.1)
rspec_junit_formatter (~> 0.4.1) rspec_junit_formatter (~> 0.4.1)
......
...@@ -108,7 +108,7 @@ module QA ...@@ -108,7 +108,7 @@ module QA
wait_for_requests(skip_finished_loading_check: skip_finished_loading_check) wait_for_requests(skip_finished_loading_check: skip_finished_loading_check)
element_selector = element_selector_css(name, reject_capybara_query_keywords(kwargs)) element_selector = element_selector_css(name, reject_capybara_query_keywords(kwargs))
find(element_selector, only_capybara_query_keywords(kwargs)) find(element_selector, **only_capybara_query_keywords(kwargs))
end end
def only_capybara_query_keywords(kwargs) def only_capybara_query_keywords(kwargs)
......
...@@ -26,7 +26,7 @@ module QA ...@@ -26,7 +26,7 @@ module QA
end end
def restore_application_settings(*application_settings_keys) def restore_application_settings(*application_settings_keys)
set_application_settings(@original_application_settings.slice(*application_settings_keys)) set_application_settings(**@original_application_settings.slice(*application_settings_keys))
end end
private private
......
...@@ -148,7 +148,7 @@ module QA ...@@ -148,7 +148,7 @@ module QA
Capybara::Selenium::Driver.new( Capybara::Selenium::Driver.new(
app, app,
selenium_options **selenium_options
) )
end end
......
...@@ -32,7 +32,7 @@ module QA ...@@ -32,7 +32,7 @@ module QA
def enabled?(key, **scopes) def enabled?(key, **scopes)
feature = JSON.parse(get_features).find { |flag| flag['name'] == key.to_s } feature = JSON.parse(get_features).find { |flag| flag['name'] == key.to_s }
feature && (feature['state'] == 'on' || feature['state'] == 'conditional' && scopes.present? && enabled_scope?(feature['gates'], scopes)) feature && (feature['state'] == 'on' || feature['state'] == 'conditional' && scopes.present? && enabled_scope?(feature['gates'], **scopes))
end end
private private
...@@ -43,7 +43,7 @@ module QA ...@@ -43,7 +43,7 @@ module QA
raise AuthorizationError, "Administrator access is required to enable/disable feature flags. #{e.message}" raise AuthorizationError, "Administrator access is required to enable/disable feature flags. #{e.message}"
end end
def enabled_scope?(gates, scopes) def enabled_scope?(gates, **scopes)
scopes.each do |key, value| scopes.each do |key, value|
case key case key
when :project, :group, :user when :project, :group, :user
...@@ -71,16 +71,16 @@ module QA ...@@ -71,16 +71,16 @@ module QA
# scopes: Any scope (user, project, group) to restrict the change to # scopes: Any scope (user, project, group) to restrict the change to
def set_and_verify(key, enable:, **scopes) def set_and_verify(key, enable:, **scopes)
msg = "#{enable ? 'En' : 'Dis'}abling feature: #{key}" msg = "#{enable ? 'En' : 'Dis'}abling feature: #{key}"
msg += " for scope \"#{scopes_to_s(scopes)}\"" if scopes.present? msg += " for scope \"#{scopes_to_s(**scopes)}\"" if scopes.present?
QA::Runtime::Logger.info(msg) QA::Runtime::Logger.info(msg)
Support::Retrier.retry_on_exception(sleep_interval: 2) do Support::Retrier.retry_on_exception(sleep_interval: 2) do
set_feature(key, enable, scopes) set_feature(key, enable, **scopes)
is_enabled = nil is_enabled = nil
QA::Support::Waiter.wait_until(sleep_interval: 1) do QA::Support::Waiter.wait_until(sleep_interval: 1) do
is_enabled = enabled?(key, scopes) is_enabled = enabled?(key, **scopes)
is_enabled == enable || !enable && scopes.present? is_enabled == enable || !enable && scopes.present?
end end
......
# frozen_string_literal: true
require 'deprecation_toolkit'
require 'deprecation_toolkit/rspec'
require 'concurrent/utility/monotonic_time'
require 'active_support/gem_version'
module QaDeprecationToolkitEnv
# Taken from https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
def self.kwargs_warning
%r{warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z}
end
def self.configure!
# Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7.2
Warning[:deprecated] = true
DeprecationToolkit::Configuration.test_runner = :rspec
DeprecationToolkit::Configuration.deprecation_path = 'deprecations'
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [kwargs_warning]
end
end
...@@ -14,7 +14,7 @@ RSpec.describe QA::Runtime::API::Request do ...@@ -14,7 +14,7 @@ RSpec.describe QA::Runtime::API::Request do
end end
context 'when oauth_access_token is passed in the query string' do context 'when oauth_access_token is passed in the query string' do
let(:request) { described_class.new(client, '/users', { oauth_access_token: 'foo' }) } let(:request) { described_class.new(client, '/users', oauth_access_token: 'foo') }
it 'does not adds a private_token query string' do it 'does not adds a private_token query string' do
expect(request.url).to eq 'http://example.com/api/v4/users?oauth_access_token=foo' expect(request.url).to eq 'http://example.com/api/v4/users?oauth_access_token=foo'
......
...@@ -6,6 +6,9 @@ require 'rspec-parameterized' ...@@ -6,6 +6,9 @@ require 'rspec-parameterized'
require 'active_support/core_ext/hash' require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/blank'
require_relative 'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv.configure!
if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK'] if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
require 'knapsack' require 'knapsack'
Knapsack::Adapters::RSpecAdapter.bind Knapsack::Adapters::RSpecAdapter.bind
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment