From 21d02f7b6e679b0348c798789b495a580f8ca14a Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 23 Nov 2020 14:13:16 +0100 Subject: [PATCH] Maintenance: Run XOAUTH2 Gmail and Microsoft365 integration tests in dedicated job and only for develop/stable because of extreme throtteling and fail rate of the providers. --- .gitlab/ci/rspec.yml | 29 +++++++++++++------ spec/{requests => }/integration/gmail_spec.rb | 6 ++-- .../integration/microsoft365_spec.rb | 6 ++-- 3 files changed, 26 insertions(+), 15 deletions(-) rename spec/{requests => }/integration/gmail_spec.rb (82%) rename spec/{requests => }/integration/microsoft365_spec.rb (82%) diff --git a/.gitlab/ci/rspec.yml b/.gitlab/ci/rspec.yml index 3ee6d474f..bf9baab15 100644 --- a/.gitlab/ci/rspec.yml +++ b/.gitlab/ci/rspec.yml @@ -9,7 +9,7 @@ include: RAILS_ENV: "test" script: - bundle exec rake zammad:db:init - - bundle exec rspec -t ~type:system -t ~searchindex -t ~db_strategy:reset + - bundle exec rspec --exclude-pattern "spec/{system,integration}/**/*_spec.rb" -t ~searchindex -t ~db_strategy:reset .template_rspec_db_reset: &template_rspec_db_reset extends: @@ -18,14 +18,25 @@ include: RAILS_ENV: "test" script: - bundle exec rake zammad:db:init - - bundle exec rspec -t ~type:system -t ~searchindex -t db_strategy:reset + - bundle exec rspec --exclude-pattern "spec/{system,integration}/**/*_spec.rb" -t ~searchindex -t db_strategy:reset -# we need at least one job to store and include this template -# $IGNORE is not defined -ignore: +# RSpec 3rd party integration tests are independent of the database +# therefore we need only one job and choose a random database for each run + +rspec:mysql:integration: stage: test - only: - variables: - - $IGNORE + extends: + - .env_base + - .services_mysql_postgresql + variables: + RAILS_ENV: "test" + rules: + - if: $CI_MERGE_REQUEST_ID + when: never + - if: '$CI_COMMIT_BRANCH =~ /^private/' + when: manual + allow_failure: true + - when: always script: - - '' + - bundle exec rake zammad:db:init + - bundle exec rspec -t type:integration diff --git a/spec/requests/integration/gmail_spec.rb b/spec/integration/gmail_spec.rb similarity index 82% rename from spec/requests/integration/gmail_spec.rb rename to spec/integration/gmail_spec.rb index e2c732dda..69479adb2 100644 --- a/spec/requests/integration/gmail_spec.rb +++ b/spec/integration/gmail_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe 'Gmail XOAUTH2' do # rubocop:disable RSpec/DescribeClass +RSpec.describe 'Gmail XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass let(:channel) do create(:google_channel).tap(&:refresh_xoauth2!) end @@ -11,14 +11,14 @@ RSpec.describe 'Gmail XOAUTH2' do # rubocop:disable RSpec/DescribeClass end end - context 'inbound' do + context 'when probing inbound' do it 'succeeds' do result = EmailHelper::Probe.inbound(channel.options[:inbound]) expect(result[:result]).to eq('ok') end end - context 'outbound' do + context 'when probing outbound' do it 'succeeds' do result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['GMAIL_USER'], "test gmail oauth unittest #{Random.new_seed}") expect(result[:result]).to eq('ok') diff --git a/spec/requests/integration/microsoft365_spec.rb b/spec/integration/microsoft365_spec.rb similarity index 82% rename from spec/requests/integration/microsoft365_spec.rb rename to spec/integration/microsoft365_spec.rb index 64f58efce..5b2a32275 100644 --- a/spec/requests/integration/microsoft365_spec.rb +++ b/spec/integration/microsoft365_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe 'Microsoft365 XOAUTH2' do # rubocop:disable RSpec/DescribeClass +RSpec.describe 'Microsoft365 XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass let(:channel) do create(:microsoft365_channel).tap(&:refresh_xoauth2!) end @@ -11,14 +11,14 @@ RSpec.describe 'Microsoft365 XOAUTH2' do # rubocop:disable RSpec/DescribeClass end end - context 'inbound' do + context 'when probing inbound' do it 'succeeds' do result = EmailHelper::Probe.inbound(channel.options[:inbound]) expect(result[:result]).to eq('ok') end end - context 'outbound' do + context 'when probing outbound' do it 'succeeds' do result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['MICROSOFT365_USER'], "test microsoft365 oauth unittest #{Random.new_seed}") expect(result[:result]).to eq('ok')