Skip to content

Commit

Permalink
Run tests in parallel; Harmonise test environments (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
asset-web authored Dec 18, 2024
1 parent eee65b0 commit 8ef7088
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

9.6.2 Bug fix admin manage user table sorting
9.7.1 Update version of virtualenv used in testing
Run tests in parallel

9.7.0 Bug fix admin manage user table sorting
Update Python dependencies and packaging tools
Upgrade datatables

Expand Down
2 changes: 1 addition & 1 deletion deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV PIP_VERSION='24.3.1'
ENV SETUPTOOLS_VERSION='75.6.0'
ENV PIP_TOOLS_VERSION='7.4.1'
# NB: Version 15.1.0 is installed on RHEL
ENV VE_VERSION='20.28.0'
ENV VE_VERSION='20.24.5'

# Update system packages and install dependencies
RUN apt update -y && \
Expand Down
4 changes: 2 additions & 2 deletions deploy/Dockerfile-rhel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN yum update -y && \
ENV PIP_VERSION='24.3.1'
ENV SETUPTOOLS_VERSION='75.6.0'
ENV PIP_TOOLS_VERSION='7.4.1'
ENV VE_VERSION='20.28.0'
ENV VE_VERSION='20.24.5'
ENV FABRIC_VERSION='1.15.0'

RUN pip3 -V
Expand Down Expand Up @@ -92,4 +92,4 @@ RUN ls -l /usr/local/projects/temmpo/.settings/private_settings.py

CMD [ "pip3.12", "check" ] # TODO replace with command to run tests

# CMD ../../bin/python3 manage.py test --settings=temmpo.settings.test_mysql --exclude-tag=selenium-test --exclude-tag=skip-on-ubuntu
# CMD ../../bin/python3 manage.py test --parallel --settings=temmpo.settings.test_mysql --exclude-tag=selenium-test
4 changes: 2 additions & 2 deletions deploy/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def run_tests(env="test", use_local_mode=False, reuse_db=False, db_type="mysql",
src_dir = project_dir + "lib/" + env + "/src/temmpo/"

with change_dir(src_dir):
caller('%sbin/python3 manage.py test --noinput --exclude-tag=slow %s --settings=temmpo.settings.test_%s' % (venv_dir, cmd_suffix, db_type))
caller('%sbin/python3 manage.py test --parallel --noinput --exclude-tag=slow %s --settings=temmpo.settings.test_%s' % (venv_dir, cmd_suffix, db_type))

def run_slow_tests(env="test", use_local_mode=False, reuse_db=False, db_type="mysql", run_selenium_tests=False, tag=None, project_dir=PROJECT_ROOT):
"""env=test,use_local_mode=False,reuse_db=False,db_type=mysql,run_selenium_tests=False,tag=None"""
Expand All @@ -428,7 +428,7 @@ def run_slow_tests(env="test", use_local_mode=False, reuse_db=False, db_type="my
src_dir = project_dir + "lib/" + env + "/src/temmpo/"

with change_dir(src_dir):
caller('%sbin/python3 manage.py test --noinput %s --tag=slow --settings=temmpo.settings.test_%s' % (venv_dir, cmd_suffix, db_type))
caller('%sbin/python3 manage.py test --parallel --noinput %s --tag=slow --settings=temmpo.settings.test_%s' % (venv_dir, cmd_suffix, db_type))

def recreate_db(env="test", database_name="temmpo_test", use_local_mode=False, project_dir=PROJECT_ROOT):
"""env="test",database_name="temmpo_test" # This method can only be used on an existing database based upon the way the credentials are looked up."""
Expand Down
2 changes: 1 addition & 1 deletion entrypoints/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "Collect static"
python3 manage.py collectstatic --no-input

echo "Run Django tests"
python3 manage.py test --noinput
python3 manage.py test --noinput --parallel

# --parallel
# --failfast
Expand Down
4 changes: 4 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ stack-data==0.6.3 \
--hash=sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9 \
--hash=sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695
# via ipython
tblib==3.0.0 \
--hash=sha256:80a6c77e59b55e83911e1e607c649836a69c103963c5f28a46cbeef44acf8129 \
--hash=sha256:93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6
# via -r /srv/requirements/test.txt
tokenize-rt==6.1.0 \
--hash=sha256:d706141cdec4aa5f358945abe36b911b8cbdc844545da99e811250c0cee9b6fc \
--hash=sha256:e8ee836616c0877ab7c7b54776d2fefcc3bde714449a206762425ae114b53c86
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pyscreenshot>=3.0
pyvirtualdisplay>=3.0
requests>=2.31.0
selenium>=4.14.0
tblib>=3.0.0
urllib3<2.0 # https://github.com/urllib3/urllib3/issues/2168
4 changes: 4 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,10 @@ sqlparse==0.5.3 \
# via
# -r /srv/requirements/requirements.txt
# django
tblib==3.0.0 \
--hash=sha256:80a6c77e59b55e83911e1e607c649836a69c103963c5f28a46cbeef44acf8129 \
--hash=sha256:93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6
# via -r requirements/test.in
trio==0.27.0 \
--hash=sha256:1dcc95ab1726b2da054afea8fd761af74bad79bd52381b84eae408e983c76831 \
--hash=sha256:68eabbcf8f457d925df62da780eff15ff5dc68fd6b367e2dde59f7aaf2a0b884
Expand Down
2 changes: 1 addition & 1 deletion tests/build-test-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "Install Fabric"
pip3 install fabric==1.15.0 # NB: v1.15.0 supports Python 2, & 3.6, 3.7, & 3.8

echo "Install virtualenv"
pip3 install virtualenv==20.26.3 # NB: Version 15.1.0 is installed on RHEL
pip3 install virtualenv==20.24.5 # NB: Version 15.1.0 is installed on RHEL

echo "Install wheel"
sudo apt-get install -y python3-wheel-whl
Expand Down
2 changes: 1 addition & 1 deletion tests/run-django-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo "Run coverage tests"
cd $GITHUB_WORKSPACE
cd lib/test/src/temmpo
../../bin/coverage
../../bin/coverage run --source='.' manage.py test --settings=temmpo.settings.test_mysql --exclude-tag=selenium-test
../../bin/coverage run --source='.' manage.py test --parallel --settings=temmpo.settings.test_mysql --exclude-tag=selenium-test
../../bin/coverage report --skip-empty --skip-covered -m

0 comments on commit 8ef7088

Please sign in to comment.