Browse Source

Maintenance: Not yet arrived email in inbox of email integration tests causes flaky results on CI.

Thorsten Eckel 4 years ago
parent
commit
2db2f3407d
2 changed files with 12 additions and 3 deletions
  1. 1 1
      app/models/channel/email_parser.rb
  2. 11 2
      test/integration/email_postmaster_to_sender.rb

+ 1 - 1
app/models/channel/email_parser.rb

@@ -887,7 +887,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
       return
     end
 
-    Rails.logger.error "Send mail too large postmaster message to: #{reply_mail[:to]}"
+    Rails.logger.info "Send mail too large postmaster message to: #{reply_mail[:to]}"
     reply_mail[:from] = EmailAddress.find_by(channel: channel).email
     channel.deliver(reply_mail)
   rescue => e

+ 11 - 2
test/integration/email_postmaster_to_sender.rb

@@ -116,8 +116,17 @@ Oversized Email Message Body #{'#' * 120_000}
     assert_equal(large_message, eml_data)
 
     # 2. verify that a postmaster response email has been sent to the sender
-    imap.select('inbox')
-    message_ids = imap.sort(['DATE'], ['ALL'], 'US-ASCII')
+    message_ids = nil
+    5.times do |sleep_offset|
+      imap.select('inbox')
+      message_ids = imap.sort(['DATE'], ['ALL'], 'US-ASCII')
+
+      break if message_ids.count.positive?
+
+      # send mail hasn't arrived yet in the inbox
+      sleep sleep_offset
+    end
+
     assert(message_ids.count.positive?, 'Must have received a reply from the postmaster')
     imap_message_id = message_ids.last
     msg = imap.fetch(imap_message_id, 'RFC822')[0].attr['RFC822']