Changeset - cde12eec8256
[Not reviewed]
0 5 1
Branko Majic (branko) - 2 months ago 2024-02-28 01:55:25
branko@majic.rs
MAR-192: Added support for Debian 12 Bookworm to wsgi_website role:

- Update list of Python packages that are installed for running the
tests.
- Paramterise Python version testing (depends on distribution
release). Use similar construct like for the php_website role.
6 files changed with 98 insertions and 43 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1991,6 +1991,7 @@ Distribution compatibility
 
Role is compatible with the following distributions:
 

	
 
- Debian 11 (Bullseye)
 
- Debian 12 (Bookworm)
 

	
 

	
 
Examples
roles/wsgi_website/meta/main.yml
Show inline comments
 
@@ -15,3 +15,4 @@ galaxy_info:
 
    - name: Debian
 
      versions:
 
        - 11
 
        - 12
roles/wsgi_website/molecule/default/molecule.yml
Show inline comments
 
@@ -25,6 +25,17 @@ platforms:
 
    provider_raw_config_args:
 
      - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']"
 

	
 
  - name: wsgi-website-bookworm
 
    groups:
 
      - wsgi-website
 
      - parameters-mandatory
 
      - parameters-optional
 
    box: debian/bookworm64
 
    memory: 512
 
    cpus: 1
 
    provider_raw_config_args:
 
      - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']"
 

	
 
provisioner:
 
  name: ansible
 
  playbooks:
roles/wsgi_website/molecule/default/playbook.yml
Show inline comments
 
@@ -12,6 +12,7 @@
 
    default_https_tls_key: "{{ lookup('file', 'tests/data/x509/server/wsgi-website_https.key.pem') }}"
 

	
 
  roles:
 

	
 
    - role: wsgi_website
 
      fqdn: parameters-mandatory
 
      https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/parameters-mandatory_https.cert.pem') }}"
 
@@ -47,16 +48,15 @@
 
      use_paste: false
 
      virtualenv_packages:
 
        # Main packages.
 
        - dnspython==1.15.0
 
        - ptpython==0.41
 
        - prompt-toolkit==1.0.15
 
        - dnspython==2.6.1
 
        - prompt-toolkit==3.0.43
 
        - ptpython==3.0.26
 
        # Dependencies.
 
        - docopt==0.6.2
 
        - jedi==0.13.1
 
        - parso==0.3.1
 
        - Pygments==2.2.0
 
        - six==1.11.0
 
        - wcwidth==0.1.7
 
        - appdirs==1.4.4
 
        - jedi==0.19.1
 
        - parso==0.8.3
 
        - pygments==2.17.2
 
        - wcwidth==0.2.13
 
      website_mail_recipients: user
 
      wsgi_application: testapp:application
 
      wsgi_requirements:
 
@@ -69,16 +69,20 @@
 
      fqdn: parameters-paste-req
 
      use_paste: true
 
      virtualenv_packages:
 
        - click==6.7
 
        - Flask==0.12.2
 
        - itsdangerous==0.24
 
        - Jinja2==2.9.6
 
        - MarkupSafe==1.0
 
        - Paste==2.0.3
 
        - PasteDeploy==1.5.2
 
        - PasteScript==2.0.2
 
        - six==1.10.0
 
        - Werkzeug==0.12.2
 
        # Main packages.
 
        - Flask==3.0.2
 
        - Paste==3.7.1
 
        - PasteDeploy==3.1.0
 
        # Dependencies.
 
        - Jinja2==3.1.3
 
        - MarkupSafe==2.1.5
 
        - Werkzeug==3.0.1
 
        - blinker==1.7.0
 
        - click==8.1.7
 
        - importlib-metadata==7.0.1
 
        - itsdangerous==2.1.2
 
        - six==1.16.0
 
        - zipp==3.17.0
 
      wsgi_application: config.ini
 
      wsgi_requirements:
 
        - gunicorn==21.1.0
roles/wsgi_website/molecule/default/tests/conftest.py
Show inline comments
 
new file 100644
 
from collections import namedtuple
 

	
 
import pytest
 

	
 

	
 
@pytest.fixture
 
def python_info(host):
 
    """
 
    Helper fixture used to define what the expected Python details
 
    are (paths, package names etc) based on Debian release.
 

	
 
    Currently supports:
 

	
 
    - Debian 11 (Bullseye)
 
    - Debian 12 (Bookworm)
 

	
 
    Resulting information can be accessed through returned named tuple
 
    with the following properties:
 

	
 
    - python_version (version of installed Python interpreter)
 
    """
 

	
 
    PythonInfo = namedtuple('PythonInfo', 'python_version')
 

	
 
    ansible_facts = host.ansible("setup")["ansible_facts"]
 
    ansible_distribution_release = ansible_facts['ansible_distribution_release']
 

	
 
    if ansible_distribution_release == 'bullseye':
 
        info = PythonInfo(python_version="3.9.2")
 
    elif ansible_distribution_release == 'bookworm':
 
        info = PythonInfo(python_version="3.11.2")
 
    else:
 
        raise Exception('The php_info pytest fixture does not support Debian release: %s' % ansible_distribution_release)
 

	
 
    return info
roles/wsgi_website/molecule/default/tests/test_default.py
Show inline comments
 
@@ -277,31 +277,32 @@ def test_python_virtualenv_wrapper_script(host, wrapper_script, expected_owner,
 
        "packaging==23.2",
 
    ]),
 
    ('admin-parameters-optional_local', '/var/www/parameters-optional.local/virtualenv/bin/pip', [
 
        "Pygments==2.2.0",
 
        "dnspython==1.15.0",
 
        "docopt==0.6.2",
 
        "appdirs==1.4.4",
 
        "dnspython==2.6.1",
 
        "gunicorn==21.1.0",
 
        "jedi==0.13.1",
 
        "jedi==0.19.1",
 
        "packaging==23.2",
 
        "parso==0.3.1",
 
        "prompt-toolkit==1.0.15",
 
        "ptpython==0.41",
 
        "six==1.11.0",
 
        "wcwidth==0.1.7",
 
        "parso==0.8.3",
 
        "prompt-toolkit==3.0.43",
 
        "ptpython==3.0.26",
 
        "pygments==2.17.2",
 
        "wcwidth==0.2.13",
 
    ]),
 
    ('admin-parameters-paste-req', '/var/www/parameters-paste-req/virtualenv/bin/pip', [
 
        "Flask==0.12.2",
 
        "Jinja2==2.9.6",
 
        "MarkupSafe==1.0",
 
        "Paste==2.0.3",
 
        "PasteDeploy==1.5.2",
 
        "PasteScript==2.0.2",
 
        "Werkzeug==0.12.2",
 
        "click==6.7",
 
        "Flask==3.0.2",
 
        "Jinja2==3.1.3",
 
        "MarkupSafe==2.1.5",
 
        "Paste==3.7.1",
 
        "PasteDeploy==3.1.0",
 
        "Werkzeug==3.0.1",
 
        "blinker==1.7.0",
 
        "click==8.1.7",
 
        "gunicorn==21.1.0",
 
        "itsdangerous==0.24",
 
        "importlib-metadata==7.0.1",
 
        "itsdangerous==2.1.2",
 
        "packaging==23.2",
 
        "six==1.10.0",
 
        "six==1.16.0",
 
        "zipp==3.17.0",
 
    ]),
 
])
 
def test_virtualenv_packages(host, admin_user, pip_path, expected_packages):
 
@@ -495,17 +496,19 @@ def test_website_enabled(host, config_file, expected_content):
 
    assert config.linked_to == expected_content
 

	
 

	
 
@pytest.mark.parametrize("python_path, expected_version", [
 
    ("/var/www/parameters-mandatory/virtualenv/bin/python", "Python 3.9.2"),
 
    ("/var/www/parameters-optional.local/virtualenv/bin/python", "Python 3.9.2"),
 
    ("/var/www/parameters-paste-req/virtualenv/bin/python", "Python 3.9.2"),
 
@pytest.mark.parametrize("python_path", [
 
    ("/var/www/parameters-mandatory/virtualenv/bin/python"),
 
    ("/var/www/parameters-optional.local/virtualenv/bin/python"),
 
    ("/var/www/parameters-paste-req/virtualenv/bin/python"),
 
])
 
def test_python_version_in_virtualenv(host, python_path, expected_version):
 
def test_python_version_in_virtualenv(host, python_info, python_path,):
 
    """
 
    Tests if correct Python version is used inside of virtual
 
    environment.
 
    """
 

	
 
    expected_version = "Python %s" % python_info.python_version
 

	
 
    with host.sudo():
 

	
 
        python_version = host.run(python_path + " --version")
0 comments (0 inline, 0 general)