aboutsummaryrefslogtreecommitdiff
path: root/scripts/test_scripts/builds-download-upload-test.py
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-09 13:08:00 +0100
committerGitHub Enterprise <[email protected]>2026-03-09 13:08:00 +0100
commitf9d8cbcb3573b47b639b7bd73d3a4eed17653d71 (patch)
treedd295b2e929f050f292a6415fd0330da24b683a4 /scripts/test_scripts/builds-download-upload-test.py
parentadded auto-detection logic for console colour output (#817) (diff)
downloadzen-f9d8cbcb3573b47b639b7bd73d3a4eed17653d71.tar.xz
zen-f9d8cbcb3573b47b639b7bd73d3a4eed17653d71.zip
add fallback for zencache multirange (#816)
* clean up BuildStorageResolveResult to allow capabilities * add check for multirange request capability * add MaxRangeCountPerRequest capabilities * project export tests * add InMemoryBuildStorageCache * progress and logging improvements * fix ElapsedSeconds calculations in fileremoteprojectstore.cpp * oplogs/builds test script
Diffstat (limited to 'scripts/test_scripts/builds-download-upload-test.py')
-rw-r--r--scripts/test_scripts/builds-download-upload-test.py196
1 files changed, 196 insertions, 0 deletions
diff --git a/scripts/test_scripts/builds-download-upload-test.py b/scripts/test_scripts/builds-download-upload-test.py
new file mode 100644
index 000000000..f03528d98
--- /dev/null
+++ b/scripts/test_scripts/builds-download-upload-test.py
@@ -0,0 +1,196 @@
+#!/usr/bin/env python3
+"""Test script for builds download/upload operations."""
+
+from __future__ import annotations
+
+import argparse
+import platform
+import subprocess
+import sys
+from pathlib import Path
+from typing import NamedTuple
+
+_PLATFORM = "windows" if sys.platform == "win32" else "macosx" if sys.platform == "darwin" else "linux"
+_ARCH = "x64" if sys.platform == "win32" else platform.machine().lower()
+_EXE_SUFFIX = ".exe" if sys.platform == "win32" else ""
+
+
+class Build(NamedTuple):
+ name: str
+ bucket: str
+ id: str
+
+
+BUILDS = [
+ Build("XB1Client", "fortnitegame.staged-build.fortnite-main.xb1-client", "09a7616c1a388dfe6056aa57"),
+ Build("WindowsClient", "fortnitegame.staged-build.fortnite-main.windows-client", "09a762c81e2cf213142d0ce5"),
+ Build("SwitchClient", "fortnitegame.staged-build.fortnite-main.switch-client", "09a75bf9c3ce75bce09f644f"),
+ Build("LinuxServer", "fortnitegame.staged-build.fortnite-main.linux-server", "09a750ac155eb3e3b62e87e0"),
+ Build("Switch2Client", "fortnitegame.staged-build.fortnite-main.switch2-client", "09a78f3df07b289691ec5710"),
+ Build("PS4Client", "fortnitegame.staged-build.fortnite-main.ps4-client", "09a76ea92ad301d4724fafad"),
+ Build("IOSClient", "fortnitegame.staged-build.fortnite-main.ios-client", "09a7816fa26c23362fef0c5d"),
+ Build("AndroidClient", "fortnitegame.staged-build.fortnite-main.android-client", "09a76725f1620d62c6be06e4"),
+]
+
+ZEN_EXE: Path = Path(f"./build/{_PLATFORM}/{_ARCH}/release/zen{_EXE_SUFFIX}")
+ZEN_METADATA_DIR: Path = Path(__file__).resolve().parent / "metadatas"
+
+ZEN_PORT = 8558
+ZEN_CACHE_PORT = 8559
+ZEN_CACHE = f"http://127.0.0.1:{ZEN_CACHE_PORT}"
+ZEN_PARTIAL_REQUEST_MODE = "true"
+
+SERVER_ARGS: tuple[str, ...] = (
+ "--http", "asio",
+ "--gc-cache-duration-seconds", "1209600",
+ "--gc-interval-seconds", "21600",
+ "--gc-low-diskspace-threshold", "2147483648",
+ "--cache-bucket-limit-overwrites",
+)
+
+
+def run(cmd: list[str | Path]) -> None:
+ try:
+ subprocess.run(cmd, check=True)
+ except FileNotFoundError:
+ sys.exit(f"error: executable not found: {cmd[0]}")
+ except subprocess.CalledProcessError as e:
+ sys.exit(f"error: command failed with exit code {e.returncode}:\n {' '.join(str(x) for x in e.cmd)}")
+
+
+def stop_server(label: str, port: int) -> None:
+ """Stop a zen server. Tolerates failures so it is safe to call from finally blocks."""
+ print(f"--------- stopping {label}")
+ try:
+ subprocess.run([ZEN_EXE, "down", "--port", str(port)])
+ except OSError as e:
+ print(f"warning: could not stop {label}: {e}", file=sys.stderr)
+ print()
+
+
+def start_server(label: str, data_dir: Path, port: int, extra_args: list[str] | None = None) -> None:
+ print(f"--------- starting {label} {data_dir}")
+ run([
+ ZEN_EXE, "up", "--port", str(port), "--show-console", "--",
+ f"--data-dir={data_dir}",
+ *SERVER_ARGS,
+ *(extra_args or []),
+ ])
+ print()
+
+
+def wipe_or_create(label: str, path: Path) -> None:
+ if path.exists():
+ print(f"--------- cleaning {label} {path}")
+ run([ZEN_EXE, "wipe", "-y", path])
+ else:
+ print(f"--------- creating {label} {path}")
+ path.mkdir(parents=True, exist_ok=True)
+ print()
+
+
+def check_prerequisites() -> None:
+ if not ZEN_EXE.is_file():
+ sys.exit(f"error: zen executable not found: {ZEN_EXE}")
+ if not ZEN_METADATA_DIR.is_dir():
+ sys.exit(f"error: metadata directory not found: {ZEN_METADATA_DIR}")
+ for build in BUILDS:
+ metadata = ZEN_METADATA_DIR / f"{build.name}.json"
+ if not metadata.is_file():
+ sys.exit(f"error: metadata file not found: {metadata}")
+
+
+def main() -> None:
+ global ZEN_EXE
+
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "positional_path",
+ nargs="?",
+ default=None,
+ type=Path,
+ metavar="DATA_PATH",
+ help="root path for all data directories (positional shorthand for --data-path)",
+ )
+ parser.add_argument(
+ "zen_exe_positional",
+ nargs="?",
+ default=None,
+ type=Path,
+ metavar="ZEN_EXE_PATH",
+ help="path to zen executable (positional shorthand for --zen-exe-path)",
+ )
+ parser.add_argument(
+ "--data-path",
+ default=Path(Path(__file__).stem + "_datadir"),
+ type=Path,
+ metavar="PATH",
+ help=f"root path for all data directories (default: {Path(__file__).stem}_datadir)",
+ )
+ parser.add_argument(
+ "--zen-exe-path",
+ default=ZEN_EXE,
+ type=Path,
+ metavar="PATH",
+ help=f"path to zen executable (default: {ZEN_EXE})",
+ )
+ args = parser.parse_args()
+
+ data_path = args.positional_path
+ if data_path is None:
+ data_path = args.data_path
+
+ ZEN_EXE = args.zen_exe_positional
+ if ZEN_EXE is None:
+ ZEN_EXE = args.zen_exe_path
+ zen_system_dir = data_path / "system"
+ zen_download_dir = data_path / "Download"
+ zen_cache_data_dir = data_path / "ZenBuildsCache"
+ zen_upload_dir = data_path / "Upload"
+ zen_chunk_cache_path = data_path / "ChunkCache"
+
+ check_prerequisites()
+
+ start_server("cache zenserver", zen_cache_data_dir, ZEN_CACHE_PORT, ["--buildstore-enabled"])
+ try:
+ wipe_or_create("download folder", zen_download_dir)
+ wipe_or_create("system folder", zen_system_dir)
+
+ for build in BUILDS:
+ print(f"--------- importing {build.name} build")
+ run([
+ ZEN_EXE, "builds", "download",
+ "--host", "https://jupiter.devtools.epicgames.com",
+ "--namespace", "fortnite.oplog",
+ "--bucket", build.bucket,
+ "--build-id", build.id,
+ "--local-path", zen_download_dir / build.name,
+ f"--zen-cache-host={ZEN_CACHE}",
+ f"--allow-partial-block-requests={ZEN_PARTIAL_REQUEST_MODE}",
+ "--verify",
+ "--system-dir", zen_system_dir,
+ ])
+ print()
+
+ wipe_or_create("upload folder", zen_upload_dir)
+
+ for build in BUILDS:
+ print(f"--------- exporting {build.name} build")
+ run([
+ ZEN_EXE, "builds", "upload",
+ "--storage-path", zen_upload_dir,
+ "--build-id", build.id,
+ "--local-path", zen_download_dir / build.name,
+ "--verify",
+ "--system-dir", zen_system_dir,
+ "--metadata-path", str(ZEN_METADATA_DIR / f"{build.name}.json"),
+ "--create-build",
+ "--chunking-cache-path", zen_chunk_cache_path,
+ ])
+ print()
+ finally:
+ stop_server("cache zenserver", ZEN_CACHE_PORT)
+
+
+if __name__ == "__main__":
+ main()