Skip to content

Commit 9b1bf61

Browse files
committed
[tests] Run selenium in non parallel mode on SQlite (drop postgres)
1 parent 0ac08fb commit 9b1bf61

File tree

6 files changed

+24
-55
lines changed

6 files changed

+24
-55
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ jobs:
7979
pip install -U -e .
8080
pip install ${{ matrix.django-version }}
8181
82-
- name: Start postgres and redis
82+
- name: Start redis
8383
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
84-
run: docker compose up -d postgres redis
84+
run: docker compose up -d redis
8585

8686
- name: QA checks
8787
run: ./run-qa-checks

docker-compose.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ services:
1717
ports:
1818
- "6379:6379"
1919
entrypoint: redis-server --appendonly yes
20-
21-
postgres:
22-
image: postgis/postgis:17-3.5-alpine
23-
environment:
24-
POSTGRES_PASSWORD: openwisp2
25-
POSTGRES_USER: openwisp2
26-
POSTGRES_DB: openwisp2
27-
ports:
28-
- 5432:5432

docs/developer/installation.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Navigate into the cloned repository:
3737
3838
cd openwisp-controller/
3939
40-
Launch Redis and PostgreSQL:
40+
Launch Redis:
4141

4242
.. code-block:: shell
4343
44-
docker compose up -d redis postgres
44+
docker compose up -d redis
4545
4646
Setup and activate a virtual-environment (we'll be using `virtualenv
4747
<https://pypi.org/project/virtualenv/>`_):
@@ -99,18 +99,6 @@ Run tests with (make sure you have the :ref:`selenium dependencies
9999
100100
./runtests
101101
102-
Some tests, such as the Selenium UI tests, require a PostgreSQL database
103-
to run. If you don't have a PostgreSQL database running on your system,
104-
you can use :ref:`the Docker Compose configuration provided in this
105-
repository <controller_dev_docker>`. Once set up, you can run these
106-
specific tests as follows:
107-
108-
.. code-block:: shell
109-
110-
# Run only specific selenium tests classes
111-
cd tests/
112-
DJANGO_SETTINGS_MODULE=openwisp2.postgresql_settings ./manage.py test openwisp_controller.config.tests.test_selenium.TestDeviceAdmin
113-
114102
Run quality assurance tests with:
115103

116104
.. code-block:: shell

runtests

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#!/bin/bash
22
set -e
33

4-
# standard tests
5-
coverage run runtests.py --parallel \
4+
echo "Starting standard tests"
5+
coverage run runtests.py --parallel --exclude-tag=selenium_tests \
66
|| coverage run ./runtests.py
7-
# tests the extension capability
7+
8+
echo "Starting standard tests"
9+
coverage run runtests.py --tag=selenium_tests --no-input --exclude-pytest
10+
11+
echo "Starting tests for extensibility"
812
SAMPLE_APP=1 coverage run ./runtests.py \
913
--parallel --exclude-tag=selenium_tests \
1014
|| SAMPLE_APP=1 coverage run ./runtests.py \
1115
--exclude-tag=selenium_tests
16+
1217
coverage combine
1318
coverage xml

runtests.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,22 @@ def run_tests(extra_args, settings_module, test_app):
3535
# Configure Django settings for test execution
3636
# (sets Celery to eager mode, configures in-memory channels layer, etc.)
3737
os.environ.setdefault("TESTING", "1")
38-
base_args = sys.argv.copy()[1:]
38+
args = sys.argv.copy()[1:]
39+
exclude_pytest = "--exclude-pytest" in args
40+
if exclude_pytest:
41+
args.pop(args.index("--exclude-pytest"))
42+
# normal tests vs SAMPLE_APP
3943
if not os.environ.get("SAMPLE_APP", False):
4044
test_app = "openwisp_controller"
4145
app_dir = "openwisp_controller/"
4246
else:
4347
test_app = "openwisp2"
4448
app_dir = "tests/openwisp2/"
45-
# Run all tests except Selenium tests using SQLite
46-
sqlite_args = ["--exclude-tag", "selenium_tests"] + base_args
47-
run_tests(sqlite_args, "openwisp2.settings", test_app)
48-
49-
# Run Selenium tests using PostgreSQL
50-
psql_args = [
51-
"--tag",
52-
"db_tests",
53-
"--tag",
54-
"selenium_tests",
55-
] + base_args
56-
run_tests(psql_args, "openwisp2.postgresql_settings", test_app)
57-
49+
# Run Django tests
50+
django_tests = run_tests(args, "openwisp2.settings", test_app)
5851
# Run pytest tests
59-
sys.exit(pytest.main([app_dir]))
52+
if not exclude_pytest:
53+
# Used to test django-channels
54+
sys.exit(pytest.main([app_dir]))
55+
else:
56+
sys.exit(django_tests)

tests/openwisp2/postgresql_settings.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)