Changeset - 893d2f1e7ddd
[Not reviewed]
0 1 0
Branko Majic (branko) - 12 days ago 2024-09-07 15:17:29
branko@majic.rs
MAR-218: Update instructions for running the tests.
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
@@ -25,25 +25,25 @@ performing the following steps:
 
   - `virtualenvwrapper <https://virtualenvwrapper.readthedocs.io/en/latest/>`_
 
   - Development packages for Python.
 

	
 
   On Debian this can be easily done with::
 

	
 
     apt-get install virtualenv virtualenvwrapper git python-pip python-dev \
 
     libffi-dev libssl-dev
 

	
 
2. In order to be able to run role tests, it is necessary to install `VirtualBox
 
   <https://www.virtualbox.org/>`_ and `Vagrant <https://www.vagrantup.com/>`_,
 
   using instructions outlined on their respective websites. It is recommended
 
   to use latest versions available. At time of this writing the role tests have
 
   been successfully run on *VirtualBox 5.2.12* and *Vagrant 2.0.4*.
 
   been successfully run on *VirtualBox 7.0.20* and *Vagrant 2.3.7*.
 

	
 
3. In order to allow static IPv6 addresses to be allocated to virtual
 
   machines during testing, it is necessary to explicitly white-list
 
   the range used by the tests. Once the configuration file has been
 
   created, however, even the VirtualBox default allowed IPv4 subnet
 
   needs to be in the configuration explicitly as well.
 

	
 
   Update the VirtulBox configuration file (and make sure it can be
 
   read by the user running the tests):
 

	
 
   :file:`/etc/vbox/networks.conf`
 

	
 
@@ -104,25 +104,25 @@ When writing new and updating existing tasks, keep the following in mind:
 
- Quote sensibly. If specifying paths (for example ``src``, ``dest``, ``path``
 
  etc in various models), quote the string to make it stand-out better and to
 
  avoid breakages.
 
- Avoid usage of ``set_facts`` task when same functionality can be achieved via
 
  ``defaults/main.yml``.
 
- When specifying tasks, use the fully expanded form. Do not use single-line
 
  form with ``param=value``.
 
- When specifying ``command`` or ``shell`` tasks, in case a ``creates``
 
  parameter or such need to be used, specify them as part of task's ``args``
 
  parameter. E.g.::
 

	
 
    - name: Run command
 
      command: mycommand
 
      ansible.builtin.command: mycommand
 
      args:
 
        creates: "/etc/mycommand"
 

	
 
- When sepcifying tasks, keep the following ordering between different task
 
  parameters:
 

	
 
  - ``name``
 
  - Module and its parameters.
 
  - ``become``
 
  - ``become_user``
 
  - ``when``
 
  - ``with_items`` / ``with_dict`` / ``with_nested``
 
@@ -151,25 +151,31 @@ dedicated shell script (see below). The shell script can also be used for
 
generating reports in an automated environment.
 

	
 
In order to run tests for a specific role, perform the following steps:
 

	
 
1. Switch to Python virtual environment::
 

	
 
     workon majic-ansible-roles
 

	
 
2. Change directory::
 

	
 
     cd roles/ROLENAME/
 

	
 
3. Run the default test scenario (this will normally test against
 
3. Run the linters::
 

	
 
     flake8 .
 
     yamllint .
 
     ansible-lint .
 

	
 
4. Run the default test scenario (this will normally test against
 
   multiple Debian versions if supported)::
 

	
 
     molecule test
 

	
 

	
 
Running role tests via shell script
 
-----------------------------------
 

	
 
In order to make it easier to run tests for all roles, and eventually produce
 
reports of such runs, a dedicated shell script is provided for running the
 
tests.
 

	
0 comments (0 inline, 0 general)