Changeset - 90fcfc170214
[Not reviewed]
0 1 0
Branko Majic (branko) - 3 years ago 2021-01-12 22:41:35
branko@majic.rs
MAR-163: Refactor the connectivity test in mail_server role:

- Parametrise the test instead of looping within. Should help getting
cleaner error messages on what port has failed while also running
the test for every combination.
- Use safer way to pass arguments to host.run invocation.
1 file changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
roles/mail_server/molecule/default/tests/test_client2.py
Show inline comments
 
@@ -250,19 +250,27 @@ def test_sieve_authentication_requires_tls(host):
 
    assert command.rc == 0
 

	
 

	
 
def test_connectivity(host):
 
@pytest.mark.parametrize("server", [
 
    "parameters-mandatory",
 
    "parameters-optional"
 
])
 
@pytest.mark.parametrize("port", [
 
    25,
 
    26,
 
    27,
 
    587,
 
    143,
 
    993,
 
    4190
 
])
 
def test_connectivity(host, server, port):
 
    """
 
    Tests connectivity to the mail server (ports that should be reachable).
 
    """
 

	
 
    with host.sudo():
 

	
 
        for server in ["parameters-mandatory",
 
                       "parameters-optional"]:
 
            for port in [25, 26, 27, 587, 143, 993, 4190]:
 

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

	
 

	
 
def test_port_forwarding(host):
0 comments (0 inline, 0 general)