Files @ 8902cd5aa66b
Branch filter:

Location: majic-ansible-roles/roles/web_server/molecule/default/tests/test_client.py - annotation

branko
MAR-218: Improve mail server role test reliability:

- Introduce sleep after sending out mails in order to ensure that
Postfix has had enough time to process the messages.
- Relevant only for tests that take care of parsing the mail log.
- Solves the false negatives caused by timing issues.
- It might be a good idea down the line to implement some kind of
retry/backoff mechanism instead.
import os

import pytest

import testinfra.utils.ansible_runner


testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('client')


@pytest.mark.parametrize('server', testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-*')
)
@pytest.mark.parametrize('port', [80, 443])
def test_connectivity(host, server, port):
    """
    Tests connectivity to the web server (ports that should be reachable).
    """

    with host.sudo():

        ping = host.run('hping3 -S -p %s -c 1 %s', str(port), server)
        assert ping.rc == 0