From 0e4e1cf65e2fb579710e98481a5f30518ba831c3 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 11 Feb 2026 15:47:03 +0100 Subject: [PATCH] Correct test of init --- .../test-stack-reusable-workflow.yml | 24 +++++++------------ changedetectionio/__init__.py | 10 +++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-stack-reusable-workflow.yml b/.github/workflows/test-stack-reusable-workflow.yml index 9b2f1bdfb..c1f7b2c9e 100644 --- a/.github/workflows/test-stack-reusable-workflow.yml +++ b/.github/workflows/test-stack-reusable-workflow.yml @@ -546,29 +546,21 @@ jobs: pip install 'pyOpenSSL>=23.2.0' echo "=== Running version 0.49.1 to create datastore ===" - timeout 20 python3 ./changedetection.py -C -d /tmp/data || { - echo "Failed to start old version" - exit 1 - } + TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD=1 python3 ./changedetection.py -C -d /tmp/data + echo "✓ Version 0.49.1 datastore created successfully" # Upgrade to current version git checkout ${{ github.ref_name }} pip install -r requirements.txt echo "=== Running current version ${{ github.ref_name }} with old datastore ===" - timeout 20 python3 ./changedetection.py -d /tmp/data > /tmp/upgrade-test.log 2>&1 || { - echo "Failed to start current version" - cat /tmp/upgrade-test.log - exit 1 - } + TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD=1 python3 ./changedetection.py -d /tmp/data > /tmp/upgrade-test.log 2>&1 - # Verify success - echo "=== Verifying upgrade succeeded ===" - grep -q "Loading existing datastore" /tmp/upgrade-test.log || { - echo "ERROR: Datastore not loaded" - cat /tmp/upgrade-test.log - exit 1 - } + echo "=== Upgrade test output ===" + cat /tmp/upgrade-test.log + + echo "" + echo "✓ Upgrade test passed: 0.49.1 → ${{ github.ref_name }}" echo "✓ Upgrade test passed: 0.49.1 → ${{ github.ref_name }}" diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index f8f8c834f..a172e6287 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -371,7 +371,15 @@ def main(): # Dont' start if the JSON DB looks corrupt logger.critical(f"ERROR: JSON DB or Proxy List JSON at '{app_config['datastore_path']}' appears to be corrupt, aborting.") logger.critical(str(e)) - return + sys.exit(1) + + # Testing mode: Exit cleanly after datastore initialization (for CI/CD upgrade tests) + if os.environ.get('TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD'): + logger.success(f"TESTING MODE: Datastore loaded successfully from {app_config['datastore_path']}") + logger.success(f"TESTING MODE: Schema version: {datastore.data['settings']['application'].get('schema_version', 'unknown')}") + logger.success(f"TESTING MODE: Loaded {len(datastore.data['watching'])} watches") + logger.success("TESTING MODE: Exiting cleanly (TESTING_SHUTDOWN_AFTER_DATASTORE_LOAD is set)") + sys.exit(0) # Apply all_paused setting if specified via CLI if all_paused is not None: