diff options
Diffstat (limited to 'qa/qa/specs/features/sanity')
-rw-r--r-- | qa/qa/specs/features/sanity/feature_flags_spec.rb | 116 | ||||
-rw-r--r-- | qa/qa/specs/features/sanity/framework_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/sanity/interception_spec.rb | 42 | ||||
-rw-r--r-- | qa/qa/specs/features/sanity/version_spec.rb | 44 |
4 files changed, 105 insertions, 99 deletions
diff --git a/qa/qa/specs/features/sanity/feature_flags_spec.rb b/qa/qa/specs/features/sanity/feature_flags_spec.rb index acb9528fe6a..36069558701 100644 --- a/qa/qa/specs/features/sanity/feature_flags_spec.rb +++ b/qa/qa/specs/features/sanity/feature_flags_spec.rb @@ -1,86 +1,88 @@ # frozen_string_literal: true module QA - RSpec.describe 'Feature flag handler sanity checks', :sanity_feature_flags do - context 'with an existing feature flag definition file' do - let(:definition) do - path = Pathname.new('../config/feature_flags') - .expand_path(Runtime::Path.qa_root) - .glob('**/*.yml') - .first - YAML.safe_load(File.read(path)) - end + RSpec.describe 'Framework sanity', :sanity_feature_flags do + describe 'Feature flag handler checks' do + context 'with an existing feature flag definition file' do + let(:definition) do + path = Pathname.new('../config/feature_flags') + .expand_path(Runtime::Path.qa_root) + .glob('**/*.yml') + .first + YAML.safe_load(File.read(path)) + end - it 'reads the correct default enabled state' do - # This test will fail if we ever remove all the feature flags, but that's very unlikely given how many there - # are and how much we rely on them. - expect(QA::Runtime::Feature.enabled?(definition['name'])).to be definition['default_enabled'] + it 'reads the correct default enabled state' do + # This test will fail if we ever remove all the feature flags, but that's very unlikely given how many there + # are and how much we rely on them. + expect(QA::Runtime::Feature.enabled?(definition['name'])).to be definition['default_enabled'] + end end - end - describe 'feature flag definition files' do - let(:file) do - path = Pathname.new("#{root}/config/feature_flags/development").expand_path(Runtime::Path.qa_root) - path.mkpath - Tempfile.new(%w[ff-test .yml], path) - end + describe 'feature flag definition files' do + let(:file) do + path = Pathname.new("#{root}/config/feature_flags/development").expand_path(Runtime::Path.qa_root) + path.mkpath + Tempfile.new(%w[ff-test .yml], path) + end - let(:flag) { Pathname.new(file.path).basename('.yml').to_s } - let(:root) { '..' } + let(:flag) { Pathname.new(file.path).basename('.yml').to_s } + let(:root) { '..' } - before do - definition = <<~YAML + before do + definition = <<~YAML name: #{flag} type: development default_enabled: #{flag_enabled} - YAML - File.write(file, definition) - end + YAML + File.write(file, definition) + end - after do - file.close! - end + after do + file.close! + end - shared_examples 'gets flag value' do - context 'with a default disabled feature flag' do - let(:flag_enabled) { 'false' } + shared_examples 'gets flag value' do + context 'with a default disabled feature flag' do + let(:flag_enabled) { 'false' } - it 'reads the flag as disabled' do - expect(QA::Runtime::Feature.enabled?(flag)).to be false - end + it 'reads the flag as disabled' do + expect(QA::Runtime::Feature.enabled?(flag)).to be false + end - it 'reads as enabled after the flag is enabled' do - QA::Runtime::Feature.enable(flag) + it 'reads as enabled after the flag is enabled' do + QA::Runtime::Feature.enable(flag) - expect { QA::Runtime::Feature.enabled?(flag) }.to eventually_be_truthy - .within(max_duration: 60, sleep_interval: 5) + expect { QA::Runtime::Feature.enabled?(flag) }.to eventually_be_truthy + .within(max_duration: 60, sleep_interval: 5) + end end - end - context 'with a default enabled feature flag' do - let(:flag_enabled) { 'true' } + context 'with a default enabled feature flag' do + let(:flag_enabled) { 'true' } - it 'reads the flag as enabled' do - expect(QA::Runtime::Feature.enabled?(flag)).to be true - end + it 'reads the flag as enabled' do + expect(QA::Runtime::Feature.enabled?(flag)).to be true + end - it 'reads as disabled after the flag is disabled' do - QA::Runtime::Feature.disable(flag) + it 'reads as disabled after the flag is disabled' do + QA::Runtime::Feature.disable(flag) - expect { QA::Runtime::Feature.enabled?(flag) }.to eventually_be_falsey - .within(max_duration: 60, sleep_interval: 5) + expect { QA::Runtime::Feature.enabled?(flag) }.to eventually_be_falsey + .within(max_duration: 60, sleep_interval: 5) + end end end - end - context 'with a CE feature flag' do - include_examples 'gets flag value' - end + context 'with a CE feature flag' do + include_examples 'gets flag value' + end - context 'with an EE feature flag' do - let(:root) { '../ee' } + context 'with an EE feature flag' do + let(:root) { '../ee' } - include_examples 'gets flag value' + include_examples 'gets flag value' + end end end end diff --git a/qa/qa/specs/features/sanity/framework_spec.rb b/qa/qa/specs/features/sanity/framework_spec.rb index fa34f525a85..5c80afe338e 100644 --- a/qa/qa/specs/features/sanity/framework_spec.rb +++ b/qa/qa/specs/features/sanity/framework_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Framework sanity checks', :orchestrated, :framework do + RSpec.describe 'Framework sanity', :orchestrated, :framework do describe 'Passing orchestrated example' do it 'succeeds' do Runtime::Browser.visit(:gitlab, Page::Main::Login) diff --git a/qa/qa/specs/features/sanity/interception_spec.rb b/qa/qa/specs/features/sanity/interception_spec.rb index f8930db3aa5..67be832055d 100644 --- a/qa/qa/specs/features/sanity/interception_spec.rb +++ b/qa/qa/specs/features/sanity/interception_spec.rb @@ -1,39 +1,41 @@ # frozen_string_literal: true module QA - RSpec.describe 'Browser request interception', :orchestrated, :framework do - before(:context) do - skip 'Only can test for chrome' unless QA::Runtime::Env.can_intercept? - end + RSpec.describe 'Framework sanity', :orchestrated, :framework do + describe 'Browser request interception' do + before(:context) do + skip 'Only can test for chrome' unless QA::Runtime::Env.can_intercept? + end - before do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - end + before do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + end - let(:page) { Capybara.current_session } - let(:logger) { class_double('QA::Runtime::Logger') } + let(:page) { Capybara.current_session } + let(:logger) { class_double('QA::Runtime::Logger') } - it 'intercepts failed graphql calls' do - page.execute_script <<~JS + it 'intercepts failed graphql calls' do + page.execute_script <<~JS fetch('/api/graphql', { method: 'POST', body: JSON.stringify({ query: 'query {}'}), headers: { 'Content-Type': 'application/json' } }) - JS + JS - Support::Waiter.wait_until do - !get_cached_error.nil? + Support::Waiter.wait_until do + !get_cached_error.nil? + end + expect(**get_cached_error).to include({ 'method' => 'POST', 'status' => 200, 'url' => '/api/graphql' }) end - expect(**get_cached_error).to include({ 'method' => 'POST', 'status' => 200, 'url' => '/api/graphql' }) - end - def get_cached_error - cache = page.execute_script <<~JS + def get_cached_error + cache = page.execute_script <<~JS return Interceptor.getCache() - JS + JS - cache['errors']&.first + cache['errors']&.first + end end end end diff --git a/qa/qa/specs/features/sanity/version_spec.rb b/qa/qa/specs/features/sanity/version_spec.rb index e93a8a6fea1..deefe830c36 100644 --- a/qa/qa/specs/features/sanity/version_spec.rb +++ b/qa/qa/specs/features/sanity/version_spec.rb @@ -7,31 +7,33 @@ module QA # environment variable is the version actually running. # # See https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1179 - RSpec.describe 'Version sanity check', :smoke, only: { pipeline: [:pre, :release] } do - let(:api_client) { Runtime::API::Client.new(:gitlab) } - let(:request) { Runtime::API::Request.new(api_client, '/version') } + RSpec.describe 'Framework sanity', :smoke, only: { pipeline: [:pre, :release] } do + describe 'Version check' do + let(:api_client) { Runtime::API::Client.new(:gitlab) } + let(:request) { Runtime::API::Request.new(api_client, '/version') } - it 'is the specified version' do - # The `DEPLOY_VERSION` variable will only be provided for deploys to the - # `pre` and `release` environments, which only receive packaged releases. - # - # For these releases, `deploy_version` will be a package string (e.g., - # `13.1.3-ee.0`), and the reported version will be something like - # `13.1.3-ee`, so we only compare the leading SemVer string. - # - # | Package | Version | - # | ---------------- | -------------- | - # | 13.3.5-ee.0 | 13.3.5-ee | - # | 13.3.0-rc42.ee.0 | 13.3.0-rc42-ee | - deploy = Runtime::Env.deploy_version&.gsub(/\A(\d+\.\d+\.\d+).*\z/, '\1') + it 'is the specified version' do + # The `DEPLOY_VERSION` variable will only be provided for deploys to the + # `pre` and `release` environments, which only receive packaged releases. + # + # For these releases, `deploy_version` will be a package string (e.g., + # `13.1.3-ee.0`), and the reported version will be something like + # `13.1.3-ee`, so we only compare the leading SemVer string. + # + # | Package | Version | + # | ---------------- | -------------- | + # | 13.3.5-ee.0 | 13.3.5-ee | + # | 13.3.0-rc42.ee.0 | 13.3.0-rc42-ee | + deploy = Runtime::Env.deploy_version&.gsub(/\A(\d+\.\d+\.\d+).*\z/, '\1') - skip('No deploy version provided') if deploy.nil? || deploy.empty? + skip('No deploy version provided') if deploy.nil? || deploy.empty? - get request.url + get request.url - expect_status(200) - expect(json_body).to have_key(:version) - expect(json_body[:version]).to start_with(deploy) + expect_status(200) + expect(json_body).to have_key(:version) + expect(json_body[:version]).to start_with(deploy) + end end end end |