From 8aaa236a151c18b2f54a8d304df96dec2b2415bd Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 2 Jun 2026 13:59:50 -0700 Subject: [PATCH] test: stabilize archivebox ci shards --- ...1_cli_workflow_add_search_update_remove.py | 1 + archivebox/tests/test_config_SAVE_TITLE.py | 30 +++++++++++++------ archivebox/tests/test_machine_service.py | 4 ++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/archivebox/tests/test_api_v1_cli_workflow_add_search_update_remove.py b/archivebox/tests/test_api_v1_cli_workflow_add_search_update_remove.py index 1fd7eec3..9ba6a6fe 100644 --- a/archivebox/tests/test_api_v1_cli_workflow_add_search_update_remove.py +++ b/archivebox/tests/test_api_v1_cli_workflow_add_search_update_remove.py @@ -114,6 +114,7 @@ def test_cli_api_add_search_update_remove_over_server(tmp_path): "filter_patterns": [target_url], "batch_size": 1, "continuous": False, + "index_only": True, }, timeout=20, ) diff --git a/archivebox/tests/test_config_SAVE_TITLE.py b/archivebox/tests/test_config_SAVE_TITLE.py index fffe1a56..5ac31167 100644 --- a/archivebox/tests/test_config_SAVE_TITLE.py +++ b/archivebox/tests/test_config_SAVE_TITLE.py @@ -1,3 +1,5 @@ +import time + from archivebox.tests.conftest import run_archivebox_cmd, cli_env import pytest @@ -25,26 +27,36 @@ def _install_chrome(tmp_path, env): assert install_process.returncode == 0, install_process.stderr or install_process.stdout -def test_title_is_extracted(tmp_path, initialized_archive): +def _wait_for_snapshot_title(data_dir, *, timeout=30): + deadline = time.time() + timeout + title = None + while time.time() < deadline: + with use_archivebox_db(data_dir): + title = Snapshot.objects.values_list("title", flat=True).get() + if title: + return title + time.sleep(0.5) + return title + + +def test_title_is_extracted(tmp_path, initialized_archive, recursive_test_site): """Test that title is extracted from the page.""" env = cli_env(disable_extractors=True) env.update({"SAVE_TITLE": "true"}) _install_chrome(tmp_path, env) add_process = run_archivebox_cmd( - ["add", "--plugins=chrome,wget,title", "https://example.com"], + ["add", "--plugins=chrome,wget,title", recursive_test_site["root_url"]], cwd=tmp_path, env=env, ) assert add_process.returncode == 0, add_process.stderr or add_process.stdout - with use_archivebox_db(tmp_path): - title = Snapshot.objects.values_list("title", flat=True).get() - + title = _wait_for_snapshot_title(tmp_path) assert title is not None - assert "Example" in title + assert "Root" in title -def test_title_is_listed_by_search_alias(tmp_path, initialized_archive): +def test_title_is_listed_by_search_alias(tmp_path, initialized_archive, recursive_test_site): """ https://github.com/ArchiveBox/ArchiveBox/issues/330 Unencoded content should not be rendered as it facilitates xss injections @@ -54,7 +66,7 @@ def test_title_is_listed_by_search_alias(tmp_path, initialized_archive): env.update({"SAVE_TITLE": "true"}) _install_chrome(tmp_path, env) add_process = run_archivebox_cmd( - ["add", "--plugins=chrome,wget,title", "https://example.com"], + ["add", "--plugins=chrome,wget,title", recursive_test_site["root_url"]], cwd=tmp_path, env=env, ) @@ -67,4 +79,4 @@ def test_title_is_listed_by_search_alias(tmp_path, initialized_archive): assert list_process.returncode == 0, list_process.stderr or list_process.stdout output = list_process.stdout - assert "https://example.com" in output + assert recursive_test_site["root_url"] in output diff --git a/archivebox/tests/test_machine_service.py b/archivebox/tests/test_machine_service.py index 17afd6f4..64db4591 100644 --- a/archivebox/tests/test_machine_service.py +++ b/archivebox/tests/test_machine_service.py @@ -41,6 +41,8 @@ def _runtime_env(data_dir: Path, bin_dir: Path) -> dict[str, str]: "LIB_BIN_DIR": str(data_dir / "lib" / "bin"), "ABXPKG_LIB_DIR": str(data_dir / "lib"), "LITEPARSE_ENABLED": "True", + "TIMEOUT": "180", + "ABXPKG_INSTALL_TIMEOUT": "180", "PATH": os.pathsep.join(entry for entry in path_entries if entry), } @@ -55,7 +57,7 @@ def test_install_persists_machine_binary_config_and_recovers_stale_path(initiali _cmd_result = run_archivebox_cmd( ["install", "--binproviders=env", "liteparse"], cwd=initialized_archive, - timeout=120, + timeout=240, env=_runtime_env(initialized_archive, bootstrap_bin_dir), ) stdout, stderr, returncode = _cmd_result.stdout, _cmd_result.stderr, _cmd_result.returncode