Skip to content

Commit f728f89

Browse files
committed
[change] Updated modules, fixed build and tests
Updated openwisp modules, base images, django (4.2) and postgres (12). Fixed selenium tests.
1 parent cbef70d commit f728f89

File tree

11 files changed

+67
-45
lines changed

11 files changed

+67
-45
lines changed

.github/workflows/branch.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
uses: actions/checkout@v2
1616

1717
- name: Install Testing Requirements
18-
run: sudo pip install -r requirements-test.txt
18+
run: |
19+
sudo pip install -U pip setuptools wheel
20+
sudo pip install -r requirements-test.txt
1921
2022
- name: Lint
2123
run: openwisp-qa-check --skip-checkmigrations

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ services:
174174
- NET_ADMIN
175175

176176
postgres:
177-
image: mdillon/postgis:11-alpine
177+
image: postgis/postgis:12-3.4
178178
restart: always
179179
environment:
180180
- POSTGRES_DB=$DB_NAME

images/common/openwisp/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER']
266266
EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD']
267267
EMAIL_USE_TLS = env_bool(os.environ['EMAIL_HOST_TLS'])
268-
EMAIL_TIMEOUT = os.environ['EMAIL_TIMEOUT']
268+
EMAIL_TIMEOUT = int(os.environ['EMAIL_TIMEOUT'])
269269

270270
# Logging
271271
# http://docs.djangoproject.com/en/dev/topics/logging

images/openwisp_base/Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ FROM system AS openwisp_python
2525
ENV PATH="${PATH}:/home/openwisp/.local/bin"
2626
ENV PYTHONPATH=/home/openwisp/.local/lib/python3.10/site-packages
2727

28-
RUN pip install --no-cache-dir --user --upgrade pip~=23.0.1
28+
RUN pip install --no-cache-dir --user --upgrade pip~=24.0.0
2929
# TODO: Remove when next version of openwisp-monitoring is released
30-
ARG OPENWISP_MONITORING_SOURCE=https://github.com/openwisp/openwisp-monitoring/tarball/15977c74b48d846ac469316abc7f13ccbef405f0
30+
ARG OPENWISP_MONITORING_SOURCE=https://github.com/openwisp/openwisp-monitoring/tarball/18cc5249de1f057554826f9d6e6ed8683e3f24bc
3131
# hadolint ignore=DL3013
3232
RUN pip install --no-cache-dir --user --upgrade ${OPENWISP_MONITORING_SOURCE}
33-
ARG OPENWISP_FIRMWARE_SOURCE=https://github.com/openwisp/openwisp-firmware-upgrader/tarball/9c7840c7436eb8b8cd5a63e83194041ccf887cd2
33+
ARG OPENWISP_FIRMWARE_SOURCE=https://github.com/openwisp/openwisp-firmware-upgrader/tarball/5a104a8f06fd566b9c09dddb93005f223df0bb47
3434
# hadolint ignore=DL3013
3535
RUN pip install --no-cache-dir --user --upgrade ${OPENWISP_FIRMWARE_SOURCE}
36-
ARG OPENWISP_TOPOLOGY_SOURCE=https://github.com/openwisp/openwisp-network-topology/tarball/ade4d5f844753879ccb54cce1d3528f17c55a490
36+
ARG OPENWISP_TOPOLOGY_SOURCE=https://github.com/openwisp/openwisp-network-topology/tarball/d150127e6ee244b2c25aa2d35f804d3d1124bde4
3737
# hadolint ignore=DL3013
3838
RUN pip install --no-cache-dir --user --upgrade ${OPENWISP_TOPOLOGY_SOURCE}
39-
ARG OPENWISP_RADIUS_SOURCE=https://github.com/openwisp/openwisp-radius/tarball/1a748466c269df3548557d9d42df6bb886da4f57
39+
ARG OPENWISP_RADIUS_SOURCE=https://github.com/openwisp/openwisp-radius/tarball/6a2d98861a8d43e7622d87f7e1af97503c2677f9
4040
# hadolint ignore=DL3013
4141
RUN pip install --no-cache-dir --user --upgrade ${OPENWISP_RADIUS_SOURCE}
4242

@@ -49,7 +49,7 @@ RUN if [ "$OPENWISP_IPAM_SOURCE" != "default" ] ; then \
4949
pip install --no-cache-dir --user --upgrade ${OPENWISP_IPAM_SOURCE}; \
5050
fi
5151
# TODO: Remove when next version of openwisp-controller is released
52-
ARG OPENWISP_CONTROLLER_SOURCE=https://github.com/openwisp/openwisp-controller/tarball/3383bc11e5f8e9c89ebd9ac8aefa0066576d3133
52+
ARG OPENWISP_CONTROLLER_SOURCE=https://github.com/openwisp/openwisp-controller/tarball/1e641fe094838178556b4db09317065bd28c625c
5353
# hadolint ignore=DL3013
5454
RUN if [ "$OPENWISP_CONTROLLER_SOURCE" != "default" ] ; then \
5555
pip install --no-cache-dir --user --upgrade ${OPENWISP_CONTROLLER_SOURCE}; \
@@ -59,13 +59,13 @@ ARG OPENWISP_NOTIFICATION_SOURCE=default
5959
RUN if [ "$OPENWISP_NOTIFICATION_SOURCE" != "default" ] ; then \
6060
pip install --no-cache-dir --user --upgrade ${OPENWISP_NOTIFICATION_SOURCE}; \
6161
fi
62-
ARG OPENWISP_USERS_SOURCE=https://github.com/openwisp/openwisp-users/tarball/55023698cf39711585480be90c98d64ce5a04b8d
62+
ARG OPENWISP_USERS_SOURCE=https://github.com/openwisp/openwisp-users/tarball/8a39e488b0b955c7322f6df7927d2adb71ce7caf
6363
# hadolint ignore=DL3013
6464
RUN if [ "$OPENWISP_USERS_SOURCE" != "default" ] ; then \
6565
pip install --no-cache-dir --user --upgrade --force-reinstall ${OPENWISP_USERS_SOURCE}; \
6666
fi
6767
# TODO: Remove when next version of openwisp-utils is released
68-
ARG OPENWISP_UTILS_SOURCE="openwisp-utils[celery,rest] @ https://github.com/openwisp/openwisp-utils/tarball/9fd347fb861af674674a4bcc59c54bcdeef18b8c "
68+
ARG OPENWISP_UTILS_SOURCE="openwisp-utils[celery,rest] @ https://github.com/openwisp/openwisp-utils/tarball/1d3b00cbd8b36686a39b3f24c42667e6482197b2"
6969
# hadolint ignore=DL3013
7070
RUN if [ "$OPENWISP_UTILS_SOURCE" != "default" ] ; then \
7171
pip install --no-cache-dir --user --upgrade --force-reinstall "${OPENWISP_UTILS_SOURCE}"; \
@@ -76,7 +76,7 @@ RUN if [ "$DJANGO_X509_SOURCE" != "default" ]; then \
7676
pip install --no-cache-dir --user --upgrade --force-reinstall ${DJANGO_X509_SOURCE}; \
7777
fi
7878

79-
ARG DJANGO_SOURCE=django~=4.0.10
79+
ARG DJANGO_SOURCE=django~=4.2.0
8080
# hadolint ignore=DL3013
8181
RUN pip install --no-cache-dir --user --upgrade ${DJANGO_SOURCE}
8282

images/openwisp_freeradius/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM freeradius/freeradius-server:3.0.26-alpine
22

33
# hadolint ignore=DL3018
4-
RUN apk add --no-cache --update tzdata~=2022f-r1 postgresql-dev~=13.8-r0 \
5-
postgresql-client~=13.8-r0 && \
4+
RUN apk add --no-cache --update tzdata~=2022f-r1 \
5+
postgresql-client~=13.12-r0 && \
66
rm -rf /var/cache/apk/* /tmp/*
77

88
RUN addgroup -S freerad && \

images/openwisp_nfs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM alpine:3.16
22

33
# hadolint ignore=DL3018
44
RUN apk add --no-cache --update --verbose \
5-
tzdata~=2022f-r1 \
5+
tzdata~=2024a-r0 \
66
nfs-utils~=2.6.1-r1 && \
77
rm -rf /var/cache/apk/* /tmp/*
88

images/openwisp_nginx/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM nginx:1.23.3-alpine
22

33
RUN apk add --update --no-cache \
4-
openssl~=3.0.8-r0 \
4+
openssl~=3.0.12-r5 \
55
certbot~=1.32.0-r0 \
66
certbot-nginx~=1.32.0-r0 && \
77
rm -rf /var/cache/apk/* /tmp/*

images/openwisp_postfix/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ FROM alpine:3.16
22

33
WORKDIR /opt/openwisp/
44
RUN apk add --no-cache --upgrade \
5-
openssl~=1.1.1t-r0 \
5+
openssl~=1.1.1w-r1 \
66
cyrus-sasl~=2.1.28-r1 \
77
cyrus-sasl-login~=2.1.28-r1 && \
88
apk add --no-cache \
9-
postfix~=3.7.3-r0 \
9+
postfix~=3.7.11-r0 \
1010
rsyslog~=8.2204.1-r0 \
11-
tzdata~=2022f-r1 && \
11+
tzdata~=2024a-r0 && \
1212
rm -rf /tmp/* /var/cache/apk/*
1313

1414
CMD ["sh", "init_command.sh"]

requirements-test.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
docker~=5.0.3
2-
selenium~=4.1.0
3-
openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master
1+
docker~=7.0.0
2+
openwisp-utils[qa,selenium] @ https://github.com/openwisp/openwisp-utils/tarball/master

tests/runtests.py

+30-22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from selenium.common.exceptions import NoSuchElementException
1010
from selenium.webdriver.chrome.options import Options as ChromiumOptions
1111
from selenium.webdriver.common.by import By
12+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
1213
from utils import TestUtilities
1314

1415

@@ -120,13 +121,17 @@ def setUpClass(cls):
120121
)
121122
# Create base drivers (Chromium)
122123
if cls.config['driver'] == 'chromium':
123-
chrome_options = ChromiumOptions()
124-
chrome_options.set_capability("goog:loggingPrefs", {'browser': 'ALL'})
125-
chrome_options.add_argument('--ignore-certificate-errors')
124+
options = ChromiumOptions()
125+
options.add_argument('--headless')
126+
options.add_argument('--ignore-certificate-errors')
126127
if cls.config['headless']:
127-
chrome_options.add_argument('--headless')
128-
cls.base_driver = webdriver.Chrome(options=chrome_options)
129-
cls.second_driver = webdriver.Chrome(options=chrome_options)
128+
options.add_argument('--headless')
129+
options.add_argument(f'--remote-debugging-port={5003 + 100}')
130+
capabilities = DesiredCapabilities.CHROME
131+
capabilities['goog:loggingPrefs'] = {'browser': 'ALL'}
132+
options.set_capability('cloud:options', capabilities)
133+
cls.base_driver = webdriver.Chrome(options=options)
134+
cls.second_driver = webdriver.Chrome(options=options)
130135
cls.base_driver.set_window_size(1366, 768)
131136
cls.second_driver.set_window_size(1366, 768)
132137

@@ -137,8 +142,8 @@ def tearDownClass(cls):
137142
cls._delete_object(resource_link)
138143
except NoSuchElementException:
139144
print(f'Unable to delete resource at: {resource_link}')
140-
cls.second_driver.close()
141-
cls.base_driver.close()
145+
cls.second_driver.quit()
146+
cls.base_driver.quit()
142147
if cls.failed_test and cls.config['logs']:
143148
cmd = subprocess.Popen(
144149
['docker-compose', 'logs'],
@@ -170,8 +175,9 @@ def test_topology_graph(self):
170175
self.action_on_resource(label, path, 'delete_selected')
171176
self.assertNotIn('<li>Nodes: ', self.base_driver.page_source)
172177
self.action_on_resource(label, path, 'update_selected')
173-
time.sleep(4) # Wait for nodes to be fetched!
178+
174179
self.action_on_resource(label, path, 'delete_selected')
180+
self._wait_for_element()
175181
self.assertIn('<li>Nodes: ', self.base_driver.page_source)
176182

177183
def test_admin_login(self):
@@ -194,21 +200,21 @@ def test_create_prefix_users(self):
194200
self.base_driver.get(
195201
f"{self.config['app_url']}/admin/openwisp_radius/radiusbatch/add/"
196202
)
197-
self.base_driver.find_element_by_name('strategy').find_element_by_xpath(
198-
'//option[@value="prefix"]'
203+
self.base_driver.find_element(By.NAME, 'strategy').find_element(
204+
By.XPATH, '//option[@value="prefix"]'
199205
).click()
200-
self.base_driver.find_element_by_name('organization').find_element_by_xpath(
201-
'//option[text()="default"]'
206+
self.base_driver.find_element(By.NAME, 'organization').find_element(
207+
By.XPATH, '//option[text()="default"]'
202208
).click()
203-
self.base_driver.find_element_by_name('name').send_keys(prefix_objname)
204-
self.base_driver.find_element_by_name('prefix').send_keys('automated-prefix')
205-
self.base_driver.find_element_by_name('number_of_users').send_keys('1')
206-
self.base_driver.find_element_by_name('_save').click()
209+
self.base_driver.find_element(By.NAME, 'name').send_keys(prefix_objname)
210+
self.base_driver.find_element(By.NAME, 'prefix').send_keys('automated-prefix')
211+
self.base_driver.find_element(By.NAME, 'number_of_users').send_keys('1')
212+
self.base_driver.find_element(By.NAME, '_save').click()
207213
# Check PDF available
208214
self.get_resource(prefix_objname, '/admin/openwisp_radius/radiusbatch/')
209215
self.objects_to_delete.append(self.base_driver.current_url)
210-
prefix_pdf_file_path = self.base_driver.find_element_by_xpath(
211-
'//a[text()="Download User Credentials"]'
216+
prefix_pdf_file_path = self.base_driver.find_element(
217+
By.XPATH, '//a[text()="Download User Credentials"]'
212218
).get_property('href')
213219
reqHeader = {
214220
'Cookie': f"sessionid={self.base_driver.get_cookies()[0]['value']}"
@@ -314,6 +320,7 @@ def test_forgot_password(self):
314320
self.base_driver.get(f"{self.config['app_url']}/accounts/password/reset/")
315321
self.base_driver.find_element(By.NAME, 'email').send_keys('[email protected]')
316322
self.base_driver.find_element(By.XPATH, '//input[@type="submit"]').click()
323+
self._wait_for_element()
317324
self.assertIn(
318325
'We have sent you an e-mail. If you have not received '
319326
'it please check your spam folder. Otherwise contact us '
@@ -355,13 +362,14 @@ def test_celery(self):
355362
"openwisp_monitoring.check.tasks.run_checks",
356363
"openwisp_monitoring.device.tasks.delete_wifi_clients_and_sessions",
357364
"openwisp_monitoring.device.tasks.offline_device_close_session",
358-
"openwisp_monitoring.device.tasks.save_wifi_clients_and_sessions",
359365
"openwisp_monitoring.device.tasks.trigger_device_checks",
360366
"openwisp_monitoring.device.tasks.write_device_metrics",
367+
"openwisp_monitoring.device.tasks.handle_disabled_organization",
361368
"openwisp_monitoring.monitoring.tasks.delete_timeseries",
362369
"openwisp_monitoring.monitoring.tasks.migrate_timeseries_database",
363370
"openwisp_monitoring.monitoring.tasks.timeseries_batch_write",
364371
"openwisp_monitoring.monitoring.tasks.timeseries_write",
372+
"openwisp_monitoring.monitoring.tasks.delete_timeseries",
365373
"openwisp_notifications.tasks.delete_ignore_object_notification",
366374
"openwisp_notifications.tasks.delete_notification",
367375
"openwisp_notifications.tasks.delete_obsolete_objects",
@@ -392,8 +400,8 @@ def _test_celery_task_registered(container_name):
392400
for expected_output in expected_output_list:
393401
if expected_output not in output:
394402
self.fail(
395-
'Not all celery / celery-beat tasks are registered\n'
396-
f'Output:\n{output}\n'
403+
'Not all celery / celery-beat tasks are registered.\n'
404+
f'Expected celery task not found:\n{expected_output}'
397405
)
398406

399407
with self.subTest('Test celery container'):

tests/utils.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
from selenium.common.exceptions import NoAlertPresentException
99
from selenium.webdriver import ActionChains
1010
from selenium.webdriver.common.by import By
11+
from selenium.webdriver.support import expected_conditions as EC
12+
from selenium.webdriver.support.ui import WebDriverWait
1113

1214

13-
class TestConfig(object):
15+
class TestConfig:
1416
"""
1517
Get the configurations that are to be used for all the tests.
1618
"""
@@ -96,6 +98,7 @@ def create_superuser(
9698
if not driver:
9799
driver = self.base_driver
98100
driver.get(f"{self.config['app_url']}/admin/openwisp_users/user/add/")
101+
self._wait_for_element()
99102
driver.find_element(By.NAME, 'username').send_keys(username)
100103
driver.find_element(By.NAME, 'email').send_keys(email)
101104
driver.find_element(By.NAME, 'password1').send_keys(password)
@@ -104,6 +107,7 @@ def create_superuser(
104107
self._click_save_btn(driver)
105108
self.objects_to_delete.append(driver.current_url)
106109
self._click_save_btn(driver)
110+
self._wait_for_element()
107111

108112
def get_resource(self, resource_name, path, select_field='field-name', driver=None):
109113
"""
@@ -195,8 +199,10 @@ def create_mobile_location(self, location_name, driver=None):
195199
self._click_save_btn(driver)
196200
# Add to delete list
197201
self.get_resource(location_name, '/admin/geo/location/', driver=driver)
202+
self._wait_for_element()
198203
self.objects_to_delete.append(driver.current_url)
199204
driver.get(f"{self.config['app_url']}/admin/geo/location/")
205+
self._wait_for_element()
200206

201207
def add_mobile_location_point(self, location_name, driver=None):
202208
"""
@@ -261,5 +267,12 @@ def create_network_topology(
261267
self.get_resource(
262268
label, '/admin/topology/topology/', 'field-label', driver=driver
263269
)
270+
self._wait_for_element()
264271
self.objects_to_delete.append(driver.current_url)
265272
driver.get(f"{self.config['app_url']}/admin/topology/topology/")
273+
self._wait_for_element()
274+
275+
def _wait_for_element(self, element_id='content'):
276+
WebDriverWait(self.base_driver, 10).until(
277+
EC.visibility_of_element_located((By.ID, element_id))
278+
)

0 commit comments

Comments
 (0)