Add cooperative task recovery and persistent live status
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8
context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; }
name:ph… (push) Successful in 40s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18
POSTGIS_VERSION=3
VCHORD_VERSION=0.5.3
context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 49s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3
context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 1m37s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim
context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:linkki-tiedotus oci_labels:… (push) Successful in 36s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim
context:timepoll fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:timepoll oci_labels:org.opencontai… (push) Successful in 42s
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8
context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; }
name:ph… (push) Successful in 40s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18
POSTGIS_VERSION=3
VCHORD_VERSION=0.5.3
context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 49s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3
context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 1m37s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim
context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:linkki-tiedotus oci_labels:… (push) Successful in 36s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim
context:timepoll fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; }
name:timepoll oci_labels:org.opencontai… (push) Successful in 42s
This commit is contained in:
1 parent
034fecbd51
commit
3bfd199b9c
28 files changed
+2356
-172
No files matched your search
@@ -0,0 +1,56 @@
|
||||
from urllib.error import HTTPError, URLError
|
||||
|
||||
import pytest
|
||||
|
||||
from app.worker import service_unavailable
|
||||
from app import worker
|
||||
|
||||
|
||||
@pytest.mark.parametrize('error', [
|
||||
ConnectionRefusedError(), TimeoutError(), URLError(OSError('connection refused')),
|
||||
HTTPError('http://example.invalid',503,'unavailable',{},None),
|
||||
])
|
||||
def test_service_failures_can_retry_recovery(error):
|
||||
wrapped=RuntimeError('Service request failed')
|
||||
wrapped.__cause__=error
|
||||
assert service_unavailable(wrapped)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('error', [
|
||||
RuntimeError('Unrecognized file'), FileNotFoundError(), PermissionError(),
|
||||
HTTPError('http://example.invalid',401,'unauthorized',{},None),
|
||||
HTTPError('http://example.invalid',400,'bad input',{},None),
|
||||
])
|
||||
def test_task_and_authentication_errors_are_not_automatically_repeated(error):
|
||||
assert not service_unavailable(error)
|
||||
|
||||
|
||||
def test_database_starting_up_is_transient_but_authentication_is_not():
|
||||
error=RuntimeError('Database unavailable')
|
||||
error.sqlstate='57P03'
|
||||
assert service_unavailable(error)
|
||||
error.sqlstate='28P01'
|
||||
assert not service_unavailable(error)
|
||||
|
||||
|
||||
def test_recovery_rechecks_live_state_after_lost_service_response(tmp_path, monkeypatch):
|
||||
ledger = []
|
||||
calls = []
|
||||
waits = []
|
||||
|
||||
def recover():
|
||||
calls.append(list(ledger))
|
||||
if not ledger:
|
||||
ledger.append('applied')
|
||||
raise URLError(ConnectionResetError('response lost'))
|
||||
|
||||
monkeypatch.setattr(worker.sys, 'argv', ['worker', str(tmp_path/'task.py')])
|
||||
monkeypatch.setenv('SERVER_MAINTENANCE_RECOVER','1')
|
||||
monkeypatch.setattr(worker.runtime,'initialize',lambda:None)
|
||||
monkeypatch.setattr(worker.runtime,'progress',lambda *a,**kw:None)
|
||||
monkeypatch.setattr(worker.runtime,'sleep',waits.append)
|
||||
monkeypatch.setattr(worker.runpy,'run_path',lambda *a,**kw:{'recover':recover})
|
||||
worker.main()
|
||||
assert ledger==['applied']
|
||||
assert calls==[[],['applied']]
|
||||
assert waits==[2]
|
||||
Reference in new issue
Block a user