fix(logs): allow larger diagnostic uploads

This commit is contained in:
Your Name committed 2026-06-29 01:07:50 +08:00
1 parent 94e0c6432f
commit 9c8a037c4e
3 files changed
+23 -4

No files matched your search

+19
View File
@@ -16,7 +16,14 @@ def test_build_diagnostic_log_archive_tails_logs_only(tmp_path, monkeypatch):
(logs_dir / "unified.log").write_text("a" * 40, encoding="utf-8")
(logs_dir / "actions.log").write_text("action\n", encoding="utf-8")
(tmp_path / "license.dat").write_text("secret", encoding="utf-8")
pic_dir = tmp_path / "pic"
state_dir = tmp_path / "state"
pic_dir.mkdir()
state_dir.mkdir()
monkeypatch.setattr(path_config, "get_logs_dir", lambda: str(logs_dir))
monkeypatch.setattr(path_config, "get_pic_dir", lambda: str(pic_dir))
monkeypatch.setattr(path_config, "get_state_dir", lambda: str(state_dir))
monkeypatch.setattr(path_config, "get_config_path", lambda: str(tmp_path / "missing-config.json"))
archive = log_upload.build_diagnostic_log_archive(
output_dir=tmp_path,
@@ -139,6 +146,7 @@ def test_upload_diagnostic_logs_posts_signed_license_and_file(tmp_path, monkeypa
calls["url"] = url
calls["license_doc"] = license_doc
calls["file_path"] = file_path
calls["timeout_seconds"] = timeout_seconds
return {"ok": True, "message": "ok"}
result = log_upload.upload_diagnostic_logs(
@@ -149,3 +157,14 @@ def test_upload_diagnostic_logs_posts_signed_license_and_file(tmp_path, monkeypa
assert result.ok is True
assert calls["license_doc"]["payload"]["machine_fingerprint"] == "machine-a"
assert calls["file_path"].exists()
assert calls["file_path"].stat().st_size <= log_upload.DEFAULT_MAX_ARCHIVE_BYTES
assert calls["file_path"].stat().st_size <= 500 * 1024 * 1024
assert calls.get("timeout_seconds") == 120
def test_log_upload_defaults_allow_500mb_archives():
from douyin.diagnostics import log_upload
from license_server import api
assert log_upload.DEFAULT_MAX_ARCHIVE_BYTES == 500 * 1024 * 1024
assert api.DEFAULT_MAX_DIAGNOSTIC_LOG_UPLOAD_BYTES == 500 * 1024 * 1024