Changeset - 2274a6ecbb76
[Not reviewed]
0 2 1
Branko Majic (branko) - 1 month ago 2025-02-14 22:38:14
branko@majic.rs
MAR-242: Mark some of the HTTP file sharing tests as slow:

- Update develpment instructions to include information on how to run
individual tests etc.
3 files changed with 55 insertions and 0 deletions:
0 comments (0 inline, 0 general) First comment
docs/development.rst
Show inline comments
 
@@ -172,6 +172,56 @@ In order to run tests for a specific role, perform the following steps:
 
     molecule test
 

	
 

	
 
Running role tests during development
 
-------------------------------------
 

	
 
During development, as new features are being implemented, it is
 
usually necessary to bring up the test machines and have them
 
operational for prolonged periods of time while changes are being
 
applied and tested.
 

	
 
This usually starts off by bringing up the test machines and applying
 
the configuration against them using Ansible::
 

	
 
  workon majic-ansible-roles
 
  cd roles/ROLENAME/
 
  molecule converge
 

	
 
After the test machines have been brought up and configured, tests can
 
be run with (without destroying the test machines themselves)::
 

	
 
  molecule verify
 

	
 
Another scenario is ability to run individual tests for faster
 
develpoment iteration. Individual tests can be selected for execution
 
by passing options to the underlying test runner (`pytest
 
<https://docs.pytest.org/en/stable/>`_) via ``PYTEST_ADDOPTS``
 
environment variable.
 

	
 
For example, to run a singular test by its function name, use the
 
``-k`` option::
 

	
 
  PYTEST_ADDOPTS="-k test_config_file_content" molecule verify
 

	
 
Tests can also be decorated with markers (``@pytest.mark.*``), which
 
can in turn be used to run the matching (marked) subset of tests. For
 
example, to execute slow-running tests (decorated with
 
``@pytest.mark.slow``), run::
 

	
 
  PYTEST_ADDOPTS="-m slow" molecule verify
 

	
 
To exclude the slow-running tests, use logical expressions (just make
 
sure to surround the entire expression with additional quotation
 
marks)::
 
  
 
  PYTEST_ADDOPTS="-m 'not slow'" molecule verify
 

	
 
To determine what tests take a long time to finish, use the
 
``--durations`` option::
 

	
 
  PYTEST_ADDOPTS="--durations 0" molecule verify"
 

	
 

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

	
pytest.ini
Show inline comments
 
new file 100644
 
[pytest]
 
markers =
 
  slow: mark test as slow
 
\ No newline at end of file
roles/xmpp_server/molecule/default/tests/test_client.py
Show inline comments
 
@@ -151,6 +151,7 @@ def test_http_file_upload(host, server_host, username, password, domain):
 
    ["mick.doe", "mickpassword", "domain3", "parameters-optional", 20 * 1024 * 1024],
 
])
 
@pytest.mark.usefixtures("server_clean_domain_uploads")
 
@pytest.mark.slow
 
def test_http_file_share_size_limit(host, username, password, domain, file_size_limit):
 
    """
 
    Tests the maximum file size for files uploaded via XEP-0363.
 
@@ -181,6 +182,7 @@ def test_http_file_share_size_limit(host, username, password, domain, file_size_
 
    ["mick.doe", "mickpassword", "domain3", "parameters-optional", 20 * 1024 * 1024, 70 * 1024 * 1024],
 
])
 
@pytest.mark.usefixtures("server_clean_domain_uploads")
 
@pytest.mark.slow
 
def test_http_file_share_daily_quota(host, username, password, domain, file_size_limit, user_daily_quota):
 
    """
 
    Tests the user's daily quota for files uploaded via XEP-0363.
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now