Changeset - 663c02da41b8
[Not reviewed]
0 3 0
Branko Majic (branko) - 4 years ago 2020-05-05 22:55:23
branko@majic.rs
Noticket: Improve reliability for mail_server tests, detection of running ClamAV daemon:

The fixes mainly help with reliability of tests against the
mail_server role due to ClamAV not becoming available before the tests
get run. This normally is not a real issue in production (since the
daemon will become available farily quickly).

Changes made:

- Wait for ClamAV socket to become available in mail_server
role (otherwise mail delivery failures can happen).
- Increase memory used in mail server instances for testing to avoid
OOM killer kicking-in during tests.
- Introduce slight delay when running local alias tests to avoid race
condition.
- Formating fix in task that waits for ClamAV database to be
available.
3 files changed with 15 insertions and 5 deletions:
0 comments (0 inline, 0 general)
roles/mail_server/molecule/default/molecule.yml
Show inline comments
 
@@ -85,7 +85,7 @@ platforms:
 
      - parameters-mandatory
 
      - jessie
 
    box: debian/contrib-jessie64
 
    memory: 512
 
    memory: 1024
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
@@ -98,7 +98,7 @@ platforms:
 
      - parameters-optional
 
      - jessie
 
    box: debian/contrib-jessie64
 
    memory: 512
 
    memory: 1024
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
@@ -111,7 +111,7 @@ platforms:
 
      - parameters-mandatory
 
      - stretch
 
    box: debian/contrib-stretch64
 
    memory: 512
 
    memory: 1024
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
 
@@ -124,7 +124,7 @@ platforms:
 
      - parameters-optional
 
      - stretch
 
    box: debian/contrib-stretch64
 
    memory: 512
 
    memory: 1024
 
    cpus: 1
 
    interfaces:
 
      - auto_config: true
roles/mail_server/molecule/default/tests/test_optional.py
Show inline comments
 
import os
 
import re
 
import time
 
import uuid
 

	
 
import testinfra.utils.ansible_runner
 
@@ -117,6 +118,7 @@ def test_local_aliases(host):
 
    message_id = str(uuid.uuid4())
 

	
 
    send = host.run('swaks --header %s --suppress-data --to root@localhost', "Message-Id: <%s>" % message_id)
 
    time.sleep(1)
 
    assert send.rc == 0
 

	
 
    with host.sudo():
roles/mail_server/tasks/main.yml
Show inline comments
 
@@ -273,7 +273,9 @@
 
- name: Wait for ClamAV database to be available (up to 10 minutes)
 
  when: not item.stat.exists
 
  with_items: "{{ clamav_db_files.results }}"
 
  wait_for: path="{{ item.item | replace('.cld', '.cvd') }}" timeout=600
 
  wait_for:
 
    path: "{{ item.item | replace('.cld', '.cvd') }}"
 
    timeout: 600
 

	
 
- name: Enable ClamAV daemon and milter services
 
  service:
 
@@ -283,6 +285,12 @@
 
    - clamav-daemon
 
    - clamav-milter
 

	
 
# It may take ClamAV a while to read all the necessary database files etc.
 
- name: Wait for ClamAV to become available (up to 5 minutes)
 
  wait_for:
 
    path: "/var/run/clamav/clamd.ctl"
 
    timeout: 300
 

	
 
- name: Enable Postfix service
 
  service:
 
    name: postfix
0 comments (0 inline, 0 general)