Files @ fc2c40c98e0c
Branch filter:

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

branko
MAR-189: Refactored web_server tests to be less hostname-dependent:

- Use the inventory name (alongisde distribution version) in places
where it's possible and makes sense to do so.
- Rearrange the IP allocation a bit to make more sense.
- Drop architecture information from the hostnames.
- Make the connectivity test operate over a matrix of input
parameters.
- Replace singular use of wget for testing with curl.
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