============================= test session starts ============================== platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0 rootdir: /var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush, configfile: pyproject.toml plugins: regressions-2.2.0, datadir-1.3.1 collected 10 items tests/test_cron.py FF [ 20%] tests/test_event_parse.py . [ 30%] tests/test_http.py ...F. [ 80%] tests/test_procedure.py FF [100%] =================================== FAILURES =================================== _____________________________ test_cron_execution ______________________________ def test_cron_execution(): """ Test that the cronjob in ``../etc/scripts/test_cron.py`` runs successfully. """ > _test_cron_queue('cron_test') tests/test_cron.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ expected_msg = 'cron_test' def _test_cron_queue(expected_msg: str): msg = None test_start = time.time() while time.time() - test_start <= test_timeout and msg != expected_msg: try: msg = cron_queue.get(block=True, timeout=test_timeout) except queue.Empty: break > assert msg == expected_msg, 'The expected cronjob has not been executed' E AssertionError: The expected cronjob has not been executed E assert None == 'cron_test' tests/test_cron.py:30: AssertionError ---------------------------- Captured stdout setup ----------------------------- INFO:root:Starting Platypush test service INFO:root:Sleeping 5 seconds while waiting for the daemon to start up INFO:platypush:---- Starting platypush v.0.23.3 INFO:platypush:backend:redis:Initialized Redis backend on queue platypush_bus_mq with arguments {} WARNING:platypush:backend:http:Could not register the Zeroconf service ERROR:platypush:backend:http: Traceback (most recent call last): File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/backend/http/__init__.py", line 459, in run self.register_service(port=self.port) File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/backend/__init__.py", line 382, in register_service self.zeroconf.register_service(self.zeroconf_info) File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 574, in register_service run_coro_with_timeout( File "/usr/lib/python3.10/site-packages/zeroconf/_utils/asyncio.py", line 97, in run_coro_with_timeout return asyncio.run_coroutine_threadsafe(aw, loop).result( File "/usr/lib/python3.10/concurrent/futures/_base.py", line 446, in result return self.__get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result raise self._exception File "/usr/lib/python3.10/site-packages/zeroconf/_utils/asyncio.py", line 81, in await_awaitable task = await aw File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 602, in async_register_service await self.async_check_service(info, allow_name_change, cooperating_responders) File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 762, in async_check_service raise NonUniqueNameException zeroconf._exceptions.NonUniqueNameException INFO:platypush:backend:http:Starting local web server on port 8123 INFO:platypush: * Serving Flask app 'platypush' (lazy loading) INFO:platypush: * Environment: production INFO:platypush: WARNING: This is a development server. Do not use it in a production deployment. INFO:platypush: Use a production WSGI server instead. INFO:platypush: * Debug mode: off INFO:werkzeug: * Running on all addresses (0.0.0.0) WARNING: This is a development server. Do not use it in a production deployment. * Running on http://127.0.0.1:8123 * Running on http://172.105.246.212:8123 (Press CTRL+C to quit) ------------------------------ Captured log setup ------------------------------ INFO root:conftest.py:31 Starting Platypush test service INFO root:conftest.py:36 Sleeping 5 seconds while waiting for the daemon to start up INFO platypush:__init__.py:233 ---- Starting platypush v.0.23.3 INFO platypush:backend:redis:__init__.py:75 Initialized Redis backend on queue platypush_bus_mq with arguments {} WARNING platypush:backend:http:__init__.py:461 Could not register the Zeroconf service ERROR platypush:backend:http:__init__.py:462 Traceback (most recent call last): File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/backend/http/__init__.py", line 459, in run self.register_service(port=self.port) File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/backend/__init__.py", line 382, in register_service self.zeroconf.register_service(self.zeroconf_info) File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 574, in register_service run_coro_with_timeout( File "/usr/lib/python3.10/site-packages/zeroconf/_utils/asyncio.py", line 97, in run_coro_with_timeout return asyncio.run_coroutine_threadsafe(aw, loop).result( File "/usr/lib/python3.10/concurrent/futures/_base.py", line 446, in result return self.__get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result raise self._exception File "/usr/lib/python3.10/site-packages/zeroconf/_utils/asyncio.py", line 81, in await_awaitable task = await aw File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 602, in async_register_service await self.async_check_service(info, allow_name_change, cooperating_responders) File "/usr/lib/python3.10/site-packages/zeroconf/_core.py", line 762, in async_check_service raise NonUniqueNameException zeroconf._exceptions.NonUniqueNameException _________________ test_cron_execution_upon_system_clock_change _________________ def test_cron_execution_upon_system_clock_change(): """ Test that the cronjob runs at the right time even upon DST or other system clock changes. """ # Mock datetime.datetime with a class that has overridable timedelta patcher = patch('datetime.datetime', MockDatetime) try: patcher.start() time.sleep(1) # Simulate a +1hr shift on the system clock MockDatetime.timedelta = datetime.timedelta(hours=1) time.sleep(1) finally: patcher.stop() # Ensure that the cronjob that was supposed to run in an hour is now running > _test_cron_queue('cron_1hr_test') tests/test_cron.py:58: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ expected_msg = 'cron_1hr_test' def _test_cron_queue(expected_msg: str): msg = None test_start = time.time() while time.time() - test_start <= test_timeout and msg != expected_msg: try: msg = cron_queue.get(block=True, timeout=test_timeout) except queue.Empty: break > assert msg == expected_msg, 'The expected cronjob has not been executed' E AssertionError: The expected cronjob has not been executed E assert None == 'cron_1hr_test' tests/test_cron.py:30: AssertionError _________________ test_authorized_request_with_registered_user _________________ base_url = 'http://localhost:8123' def test_authorized_request_with_registered_user(base_url): # A request authenticated with user/pass should succeed. > response = send_request(authenticate=True) tests/test_http.py:52: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_http.py:17: in send_request return _send_request('shell.exec', args={'cmd': 'echo ping'}, **kwargs) tests/utils.py:52: in send_request response = requests.post( /usr/lib/python3.10/site-packages/requests/api.py:117: in post return request('post', url, data=data, json=json, **kwargs) /usr/lib/python3.10/site-packages/requests/api.py:61: in request return session.request(method=method, url=url, **kwargs) /usr/lib/python3.10/site-packages/requests/sessions.py:529: in request resp = self.send(prep, **send_kwargs) /usr/lib/python3.10/site-packages/requests/sessions.py:645: in send r = adapter.send(request, **kwargs) /usr/lib/python3.10/site-packages/requests/adapters.py:440: in send resp = conn.urlopen( /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:703: in urlopen httplib_response = self._make_request( /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:449: in _make_request six.raise_from(e, None) :3: in raise_from ??? /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:444: in _make_request httplib_response = conn.getresponse() /usr/lib/python3.10/http/client.py:1374: in getresponse response.begin() /usr/lib/python3.10/http/client.py:318: in begin version, status, reason = self._read_status() /usr/lib/python3.10/http/client.py:279: in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") /usr/lib/python3.10/socket.py:705: in readinto return self._sock.recv_into(b) platypush/utils/__init__.py:137: in _sighandler on_timeout() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > def _f(): raise TimeoutException(msg) E tests.utils.TimeoutException: Receiver response timed out tests/utils.py:86: TimeoutException ----------------------------- Captured stdout call ----------------------------- INFO:platypush:web:Received message on the HTTP backend: {'type': 'request', 'action': 'shell.exec', 'args': {'cmd': 'echo ping'}} _____________________________ test_procedure_call ______________________________ base_url = 'http://localhost:8123' def test_procedure_call(base_url): """ Test the result of a procedure invoked directly over HTTP. """ output_text = 'Procedure test' > send_request( action='procedure.write_file', args={ 'file': tmp_files[0], 'content': output_text, }) tests/test_procedure.py:57: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/utils.py:52: in send_request response = requests.post( /usr/lib/python3.10/site-packages/requests/api.py:117: in post return request('post', url, data=data, json=json, **kwargs) /usr/lib/python3.10/site-packages/requests/api.py:61: in request return session.request(method=method, url=url, **kwargs) /usr/lib/python3.10/site-packages/requests/sessions.py:529: in request resp = self.send(prep, **send_kwargs) /usr/lib/python3.10/site-packages/requests/sessions.py:645: in send r = adapter.send(request, **kwargs) /usr/lib/python3.10/site-packages/requests/adapters.py:440: in send resp = conn.urlopen( /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:703: in urlopen httplib_response = self._make_request( /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:449: in _make_request six.raise_from(e, None) :3: in raise_from ??? /usr/lib/python3.10/site-packages/urllib3/connectionpool.py:444: in _make_request httplib_response = conn.getresponse() /usr/lib/python3.10/http/client.py:1374: in getresponse response.begin() /usr/lib/python3.10/http/client.py:318: in begin version, status, reason = self._read_status() /usr/lib/python3.10/http/client.py:279: in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") /usr/lib/python3.10/socket.py:705: in readinto return self._sock.recv_into(b) platypush/utils/__init__.py:137: in _sighandler on_timeout() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > def _f(): raise TimeoutException(msg) E tests.utils.TimeoutException: Receiver response timed out tests/utils.py:86: TimeoutException ---------------------------- Captured stdout setup ----------------------------- INFO:werkzeug:127.0.0.1 - - [02/Jun/2022 00:15:33] "POST /register?redirect=http://localhost:8123/ HTTP/1.1" 302 - INFO:werkzeug:127.0.0.1 - - [02/Jun/2022 00:15:33] "GET /login?redirect=http://localhost:8123/ HTTP/1.1" 200 - ----------------------------- Captured stdout call ----------------------------- INFO:platypush:web:Received message on the HTTP backend: {'type': 'request', 'action': 'procedure.write_file', 'args': {'file': '/tmp/platypush-test-procedure-tg6i83hy.txt', 'content': 'Procedure test'}} __________________________ test_procedure_from_event ___________________________ app = base_url = 'http://localhost:8123' def test_procedure_from_event(app, base_url): """ Test the result of a procedure triggered by an event. """ output_text = 'Procedure from event test' event_type = 'test_procedure' # noinspection PyUnresolvedReferences app.bus.post(CustomEvent(subtype=event_type, file=tmp_files[1], content=output_text)) > check_file_content(expected_content=output_text, tmp_file=tmp_files[1]) tests/test_procedure.py:75: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_procedure.py:49: in check_file_content raise error _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ expected_content = 'Procedure from event test' tmp_file = '/tmp/platypush-test-procedure-6cjgprvw.txt', timeout = 10 def check_file_content(expected_content: str, tmp_file: str, timeout: int = 10): error = None start_time = time.time() while time.time() - start_time < timeout: try: assert os.path.isfile(tmp_file), 'The expected output file was not created' with open(tmp_file, 'r') as f: content = f.read() > assert content == expected_content, 'The output file did not contain the expected text' E AssertionError: The output file did not contain the expected text E assert '' == 'Procedure from event test' E - Procedure from event test tests/test_procedure.py:42: AssertionError --------------------------- Captured stdout teardown --------------------------- INFO:root:Stopping Platypush test service ---------------------------- Captured log teardown ----------------------------- INFO root:conftest.py:40 Stopping Platypush test service =============================== warnings summary =============================== ../../../../../../../../usr/lib/python3.10/site-packages/redis/connection.py:58 /usr/lib/python3.10/site-packages/redis/connection.py:58: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. hiredis_version = LooseVersion(hiredis.__version__) ../../../../../../../../usr/lib/python3.10/site-packages/redis/connection.py:60 /usr/lib/python3.10/site-packages/redis/connection.py:60: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. hiredis_version >= LooseVersion('0.1.3') ../../../../../../../../usr/lib/python3.10/site-packages/redis/connection.py:62 /usr/lib/python3.10/site-packages/redis/connection.py:62: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. hiredis_version >= LooseVersion('0.1.4') ../../../../../../../../usr/lib/python3.10/site-packages/redis/connection.py:64 /usr/lib/python3.10/site-packages/redis/connection.py:64: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. hiredis_version >= LooseVersion('1.0.0') tests/test_cron.py::test_cron_execution /usr/lib/python3.10/site-packages/marshmallow/__init__.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. __version_info__ = tuple(LooseVersion(__version__).version) tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution :572: DeprecationWarning: find_module() is deprecated and slated for removal in Python 3.12; use find_spec() instead tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution :1523: DeprecationWarning: FileFinder.find_loader() is deprecated and slated for removal in Python 3.12; use find_spec() instead tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution tests/test_cron.py::test_cron_execution :283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead tests/test_cron.py::test_cron_execution /usr/lib/python3.10/site-packages/_pytest/threadexception.py:73: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-1 () Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context self.dialect.do_execute( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: index (no name) already exists The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/tests/conftest.py", line 35, in Thread(target=lambda: app.run()).start() File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/__init__.py", line 246, in run self.entities_engine = init_entities_engine() File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/entities/__init__.py", line 15, in init_entities_engine init_entities_db() File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/entities/_base.py", line 131, in init_entities_db db.create_all(engine, Base) File "/var/lib/gitlab-runner/builds/UmwmPxhA/0/platypush/platypush/platypush/plugins/db/__init__.py", line 359, in create_all base.metadata.create_all(engine) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 4889, in create_all bind._run_ddl_visitor( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3147, in _run_ddl_visitor conn._run_ddl_visitor(visitorcallable, element, **kwargs) File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2130, in _run_ddl_visitor visitorcallable(self.dialect, self, **kwargs).traverse_single(element) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single return meth(obj, **kw) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 851, in visit_metadata self.traverse_single( File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single return meth(obj, **kw) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 907, in visit_table self.traverse_single(index, create_ok=True) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single return meth(obj, **kw) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 938, in visit_index self.connection.execute(CreateIndex(index)) File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1306, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/usr/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection return connection._execute_ddl( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1398, in _execute_ddl ret = self._execute_context( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context self._handle_dbapi_exception( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception util.raise_( File "/usr/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 207, in raise_ raise exception File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context self.dialect.do_execute( File "/usr/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) index (no name) already exists [SQL: CREATE INDEX "(no name)" ON entity (type, plugin)] (Background on this error at: https://sqlalche.me/e/14/e3q8) warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg)) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ FAILED tests/test_cron.py::test_cron_execution - AssertionError: The expected... FAILED tests/test_cron.py::test_cron_execution_upon_system_clock_change - Ass... FAILED tests/test_http.py::test_authorized_request_with_registered_user - tes... FAILED tests/test_procedure.py::test_procedure_call - tests.utils.TimeoutExce... FAILED tests/test_procedure.py::test_procedure_from_event - AssertionError: T... ================== 5 failed, 5 passed, 24 warnings in 59.28s ===================