Browse Source

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.

Thorsten Eckel 4 years ago
parent
commit
21d02f7b6e
3 changed files with 26 additions and 15 deletions
  1. 20 9
      .gitlab/ci/rspec.yml
  2. 3 3
      spec/integration/gmail_spec.rb
  3. 3 3
      spec/integration/microsoft365_spec.rb

+ 20 - 9
.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

+ 3 - 3
spec/requests/integration/gmail_spec.rb → 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')

+ 3 - 3
spec/requests/integration/microsoft365_spec.rb → 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')