Files @ 2d15529786b7
Branch filter:

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

branko
MAR-218: Fix linting errors related to commands doing unconditional changes:

- Tasks run during the prepare stage of test runs do not matter.
- Some of the role tasks are already effectively running only when
change _will_ happen (when it is detected via variable registered by
a previous task).
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