Changeset - 01f4b619cfa6
[Not reviewed]
0 5 0
Branko Majic (branko) - 7 years ago 2017-07-06 23:25:21
branko@majic.rs
MAR-27: Update mail_forwarder role/tests:

- Install swaks on mail-server instance for testing SMTP.
- Install procmail via mail_forwarder role (needed to be explicit for Debian
Stretch).
- Introduce small sleep when mails are sent to localhost for delivery to remote
hosts before checking the logs in order to allow Postfix to process the
queue.
5 files changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
roles/mail_forwarder/playbook.yml
Show inline comments
 
@@ -93,6 +93,11 @@
 
        name: hping3
 
        state: installed
 

	
 
    - name: Install SWAKS for testing SMTP capability
 
      apt:
 
        name: swaks
 
        state: installed
 

	
 
  handlers:
 

	
 
    - name: Update CA certificate cache
roles/mail_forwarder/tasks/main.yml
Show inline comments
 
@@ -3,6 +3,11 @@
 
- name: Install Postfix
 
  apt: name="postfix" state=installed
 

	
 
- name: Install procmail
 
  apt:
 
    name: procmail
 
    state: installed
 

	
 
- name: Purge Exim configuration
 
  apt: name="exim4*" state=absent purge=yes
 

	
roles/mail_forwarder/tests/test_default.py
Show inline comments
 
@@ -11,6 +11,7 @@ def test_installed_packages(Package):
 
    """
 

	
 
    assert Package('postfix').is_installed
 
    assert Package('procmail').is_installed
 
    assert Package('swaks').is_installed
 

	
 

	
roles/mail_forwarder/tests/test_mandatory.py
Show inline comments
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 
@@ -55,6 +56,9 @@ def test_direct_mail_sending(Command, File, Sudo):
 
    assert send.rc == 0
 
    message_id = re.search('Ok: queued as (.*)', send.stdout).group(1)
 

	
 
    # Wait for a little while for message to be processed.
 
    time.sleep(5)
 

	
 
    with Sudo():
 
        mail_log = File('/var/log/mail.log')
 
        pattern = "%s: to=<root@domain1>, relay=domain1.*status=sent" % message_id
roles/mail_forwarder/tests/test_optional.py
Show inline comments
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 
@@ -54,6 +55,9 @@ def test_local_aliases(Command, File, Sudo):
 
    assert send.rc == 0
 
    message_id = re.search('Ok: queued as (.*)', send.stdout).group(1)
 

	
 
    # Wait for a little while for message to be processed.
 
    time.sleep(5)
 

	
 
    with Sudo():
 
        mail_log = File('/var/log/mail.log')
 
        pattern1 = "%s: to=<root@parameters-optional>, orig_to=<root@localhost>.*status=sent" % message_id
 
@@ -72,6 +76,9 @@ def test_relay_mail_sending(Command, File, Sudo):
 
    assert send.rc == 0
 
    message_id = re.search('Ok: queued as (.*)', send.stdout).group(1)
 

	
 
    # Wait for a little while for message to be processed.
 
    time.sleep(5)
 

	
 
    with Sudo():
 
        mail_log = File('/var/log/mail.log')
 
        pattern = "%s: to=<root@domain1>, relay=mail-server.*status=sent" % message_id
0 comments (0 inline, 0 general)