From 2db2f3407da9e8d0d96dab4e8e7691c348f97e20 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 26 Feb 2021 11:29:27 +0100 Subject: [PATCH] Maintenance: Not yet arrived email in inbox of email integration tests causes flaky results on CI. --- app/models/channel/email_parser.rb | 2 +- test/integration/email_postmaster_to_sender.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 58e4d331f..c216da6bb 100644 --- a/app/models/channel/email_parser.rb +++ b/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 diff --git a/test/integration/email_postmaster_to_sender.rb b/test/integration/email_postmaster_to_sender.rb index 31f331bdc..d95644ee6 100644 --- a/test/integration/email_postmaster_to_sender.rb +++ b/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']