Changeset - 9bc79c136d4f
[Not reviewed]
0 2 0
Branko Majic (branko) - 2 months ago 2025-01-22 15:22:57
branko@majic.rs
MAR-233: Replace hping3 with nmap in connectivity tests for the xmpp_server role:

- Parametrize the connectivity tests instead of running them in a
loop.
2 files changed with 6 insertions and 13 deletions:
0 comments (0 inline, 0 general) First comment
roles/xmpp_server/molecule/default/prepare.yml
Show inline comments
 
@@ -99,11 +99,6 @@
 
  become: true
 
  tasks:
 

	
 
    - name: Install tool for testing TCP connectivity
 
      ansible.builtin.apt:
 
        name: hping3
 
        state: present
 

	
 
    - name: Deploy CA certificate
 
      ansible.builtin.copy:
 
        src: tests/data/x509/ca/level1.cert.pem
roles/xmpp_server/molecule/default/tests/test_client.py
Show inline comments
 
@@ -9,20 +9,18 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('clients')
 

	
 

	
 
def test_connectivity(host):
 
@pytest.mark.parametrize('server', ['parameters-mandatory', 'parameters-optional'])
 
@pytest.mark.parametrize('port', [5222, 5223, 5000, 5269])
 
def test_connectivity(host, server, port):
 
    """
 
    Tests connectivity to the XMPP server (ports that should be reachable).
 
    """
 

	
 
    with host.sudo():
 

	
 
        for server in ["parameters-mandatory",
 
                       "parameters-optional"]:
 
            # c2s plaintext, c2s TLS, file proxy, s2s.
 
            for port in [5222, 5223, 5000, 5269]:
 

	
 
                ping = host.run('hping3 -S -p %s -c 1 %s', str(port), server)
 
                assert ping.rc == 0
 
        scan = host.run('nmap -p %s -oG - %s', str(port), server)
 
        assert scan.rc == 0
 
        assert "Ports: %d/open/tcp//" % port in scan.stdout
 

	
 

	
 
@pytest.mark.parametrize("username, password, domain", [
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now