대용량 압축 표본 생성과 한도 경계 검증을 추가
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
93039f3db461575d34bff083ff179520a2ff2c1c- 부모
- d6b1a45
변경된 파일 8개
+670-0| @@ -0,0 +1,74 @@ | ||
| 1 | 추가: import gzip | |
| 2 | 추가: import importlib.util | |
| 3 | 추가: import io | |
| 4 | 추가: from pathlib import Path | |
| 5 | 추가: import tarfile | |
| 6 | 추가: import tempfile | |
| 7 | 추가: import unittest | |
| 8 | 추가: import zipfile | |
| 9 | 추가: | |
| 10 | 추가: | |
| 11 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 12 | 추가: SPEC = importlib.util.spec_from_file_location( | |
| 13 | 추가: "large_fixture_generator", ROOT / "tests/large-archive-fixtures/generate.py" | |
| 14 | 추가: ) | |
| 15 | 추가: GENERATOR = importlib.util.module_from_spec(SPEC) | |
| 16 | 추가: SPEC.loader.exec_module(GENERATOR) | |
| 17 | 추가: | |
| 18 | 추가: | |
| 19 | 추가: class LargeArchiveFixtureTests(unittest.TestCase): | |
| 20 | 추가: def test_boundary_archives_are_valid_and_expectations_straddle_limit(self): | |
| 21 | 추가: with tempfile.TemporaryDirectory(dir=ROOT / "tests/ci") as scratch: | |
| 22 | 추가: directory = Path(scratch) / "corpus" | |
| 23 | 추가: manifest = GENERATOR.build(directory) | |
| 24 | 추가: self.assertEqual(len(manifest["cases"]), 6) | |
| 25 | 추가: self.assertFalse(manifest["worker_execution_verified"]) | |
| 26 | 추가: for name, artifact in manifest["artifacts"].items(): | |
| 27 | 추가: path = directory / name | |
| 28 | 추가: self.assertEqual(GENERATOR.digest(path), artifact["sha256"]) | |
| 29 | 추가: if name.endswith(".zip"): | |
| 30 | 추가: with zipfile.ZipFile(path) as archive: | |
| 31 | 추가: self.assertIsNone(archive.testzip()) | |
| 32 | 추가: payload = archive.read(GENERATOR.NAME) | |
| 33 | 추가: decoded = len(payload) | |
| 34 | 추가: else: | |
| 35 | 추가: data = gzip.decompress(path.read_bytes()) | |
| 36 | 추가: decoded = len(data) | |
| 37 | 추가: with tarfile.open(fileobj=io.BytesIO(data), mode="r:") as archive: | |
| 38 | 추가: payload = archive.extractfile(GENERATOR.NAME).read() | |
| 39 | 추가: self.assertEqual(payload, bytes(artifact["payload_bytes"])) | |
| 40 | 추가: self.assertEqual(decoded, artifact["decoded_bytes"]) | |
| 41 | 추가: self.assertEqual(decoded, 65536) | |
| 42 | 추가: self.assertGreater(decoded / artifact["archive_bytes"], 100) | |
| 43 | 추가: for case in manifest["cases"]: | |
| 44 | 추가: decoded = manifest["artifacts"][case["file"]]["decoded_bytes"] | |
| 45 | 추가: failed = decoded > case["limits"]["output"] | |
| 46 | 추가: self.assertEqual(case["expected"]["error"], "Limit" if failed else "None") | |
| 47 | 추가: self.assertEqual(case["expected"]["created_count"], 0 if failed else 1) | |
| 48 | 추가: | |
| 49 | 추가: def test_generator_rejects_existing_destination_without_changes(self): | |
| 50 | 추가: with tempfile.TemporaryDirectory(dir=ROOT / "tests/ci") as scratch: | |
| 51 | 추가: directory = Path(scratch) | |
| 52 | 추가: marker = directory / "keep" | |
| 53 | 추가: marker.write_bytes(b"preserve") | |
| 54 | 추가: with self.assertRaises(FileExistsError): | |
| 55 | 추가: GENERATOR.build(directory) | |
| 56 | 추가: self.assertEqual(list(directory.iterdir()), [marker]) | |
| 57 | 추가: self.assertEqual(marker.read_bytes(), b"preserve") | |
| 58 | 추가: | |
| 59 | 추가: def test_generator_requires_project_test_directory(self): | |
| 60 | 추가: with self.assertRaises(ValueError): | |
| 61 | 추가: GENERATOR.build(ROOT / "outside-tests") | |
| 62 | 추가: | |
| 63 | 추가: def test_payload_source_enforces_bounded_reads(self): | |
| 64 | 추가: source = GENERATOR.ZeroStream(GENERATOR.GIB) | |
| 65 | 추가: with self.assertRaises(ValueError): | |
| 66 | 추가: source.read() | |
| 67 | 추가: with self.assertRaises(ValueError): | |
| 68 | 추가: source.read(GENERATOR.CHUNK + 1) | |
| 69 | 추가: self.assertEqual(source.read(GENERATOR.CHUNK), bytes(GENERATOR.CHUNK)) | |
| 70 | 추가: self.assertEqual(source.remaining, GENERATOR.GIB - GENERATOR.CHUNK) | |
| 71 | 추가: | |
| 72 | 추가: | |
| 73 | 추가: if __name__ == "__main__": | |
| 74 | 추가: unittest.main() |
| @@ -0,0 +1 @@ | ||
| 1 | 추가: /runs/ |
| @@ -0,0 +1,33 @@ | ||
| 1 | 추가: # 대용량 압축파일 회귀 표본 | |
| 2 | 추가: | |
| 3 | 추가: Python 표준 라이브러리로 실행 시점에 표본을 생성합니다. 생성된 압축파일은 커밋하지 않습니다. 생성기는 64 KiB씩 읽고 쓰며 전체 입력이나 해제 데이터를 메모리에 보관하지 않습니다. 제품 코드와 통신 revision 2는 변경하지 않습니다. | |
| 4 | 추가: | |
| 5 | 추가: ## 현재 기대값 | |
| 6 | 추가: | |
| 7 | 추가: 기준은 main d6b1a45입니다. 기본 요청의 input=67108864, output=134217728, entries=10000을 사용합니다. 현재 작업자는 이보다 큰 요청 한도도 허용하지 않습니다. 별도 압축률 한도 필드는 없으므로 비율 기준으로 거부한다고 판정하지 않습니다. | |
| 8 | 추가: | |
| 9 | 추가: - large-input.zip: 1 GiB 단일 파일을 Store로 저장합니다. 압축파일 자체가 1 GiB 이상이므로 입력 한도에서 Failed/Limit이어야 합니다. | |
| 10 | 추가: - large-input.tar.gz: 1 GiB 단일 파일의 USTAR를 Gzip level 0으로 저장합니다. 압축파일 자체가 1 GiB 이상이며 입력 한도에서 Failed/Limit이어야 합니다. | |
| 11 | 추가: - large-expansion.zip과 large-expansion.tar.gz: 같은 1 GiB 영 바이트를 Deflate로 압축합니다. 입력은 64 MiB 미만이며 해제 한도로 Failed/Limit이어야 합니다. ZIP은 목록 메타데이터, TAR.GZ는 Gzip 해제 중 한도에 걸립니다. | |
| 12 | 추가: - boundary.zip: 실제 해제 크기는 65536바이트입니다. output 한도를 65537, 65536, 65535로 설정해 각각 Completed, Completed, Failed/Limit을 요구합니다. | |
| 13 | 추가: - boundary.tar.gz: 파일 내용은 64000바이트이고 USTAR 헤더, 패딩, 종료 블록까지 해제한 크기는 65536바이트입니다. 위와 같은 output 한도에서 같은 결과를 요구합니다. TAR.GZ 한도는 파일 내용만이 아니라 바깥 Gzip 해제 크기에도 적용됩니다. | |
| 14 | 추가: | |
| 15 | 추가: 경계 표본도 해제/입력 비율이 100배 이상인 유효한 고압축 스트림입니다. below/equal/above는 해제 크기가 요청 한도보다 작음/같음/큼을 뜻합니다. 스트리밍 변경 뒤에는 입력 크기 거부 기대값을 별도로 갱신해야 하며, 이 기준을 새 구현의 성공 기준으로 고정하지 않습니다. | |
| 16 | 추가: | |
| 17 | 추가: ## 생성과 검증 | |
| 18 | 추가: | |
| 19 | 추가: 저장소 루트에서 실행합니다. output은 tests 아래의 존재하지 않는 경로여야 합니다. 기존 경로나 파일을 덮어쓰지 않습니다. 큰 입력 2개를 위해 약 2.1 GiB의 디스크가 필요하고, 검증 중 작은 경계 표본만 실제 파일로 해제합니다. | |
| 20 | 추가: | |
| 21 | 추가: ```sh | |
| 22 | 추가: python3 tests/large-archive-fixtures/generate.py --large --output tests/large-archive-fixtures/runs/full | |
| 23 | 추가: python3 tests/ci/run_rust.py local | |
| 24 | 추가: python3 tests/large-archive-fixtures/verify.py --directory tests/large-archive-fixtures/runs/full --probe tests/ci/target/debug/zipelo-large-archive-probe --worker tests/ci/target/debug/zipelo-archive-worker | |
| 25 | 추가: ``` | |
| 26 | 추가: | |
| 27 | 추가: CARGO_TARGET_DIR을 별도로 지정했다면 probe와 worker 경로도 그 캐시에 맞춥니다. --large를 생략하면 작은 경계 표본만 생성합니다. 전체 생성 및 실제 작업자 검증은 명시적으로 실행하며, 기본 local 자체 검사에는 작은 표본의 무결성, 경계 기대값과 생성기 경로 및 버퍼 제약 검사가 포함됩니다. | |
| 28 | 추가: | |
| 29 | 추가: 생성된 expectations.json에는 각 표본의 실제 크기, 해제 크기, SHA-256, 요청 한도와 기대 결과를 기록합니다. worker_execution_verified=false는 생성만으로 작업자 검증을 주장하지 않음을 뜻하며 검증기는 이 파일을 바꾸지 않습니다. | |
| 30 | 추가: | |
| 31 | 추가: 검증기는 먼저 Python ZIP/Gzip 참조 판독기로 전체 표본을 64 KiB씩 읽어 CRC와 합성 내용, TAR 헤더 및 종료 블록을 확인합니다. 디스크에 참조 해제물을 쓰지 않습니다. 이어 실제 작업자를 별도 프로세스로 실행하고 exit 0, stderr 비어 있음, 정확히 한 번의 마지막 Terminal, outcome/error/publication, 생성 개수와 Output 이벤트를 확인합니다. 거부 시 최종 출력 폴더가 비어 있어야 하며 입력은 전후 SHA-256이 같아야 합니다. 성공 경계 표본은 해제 파일 길이와 모든 바이트가 0인지 확인합니다. 파일시스템 호출 추적은 하지 않으므로 일시적인 쓰기가 전혀 없었다고 증명하지는 않습니다. 표본의 payload는 모두 합성 데이터이며 사용자 압축파일은 사용하지 않습니다. | |
| 32 | 추가: | |
| 33 | 추가: 이 검증은 현재 크기 제한의 거부 동작을 확인합니다. 수 GB 해제 성공이나 작업자의 고정 메모리 상한, 디스크 고갈, 고아 프로세스 정리를 검증하는 시험은 아닙니다. Windows 실행은 별도 검증이 필요합니다. |
| @@ -0,0 +1,150 @@ | ||
| 1 | 추가: """고정 크기 버퍼로 합성 압축파일과 현재 main의 기대값을 생성함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import gzip | |
| 5 | 추가: import hashlib | |
| 6 | 추가: import io | |
| 7 | 추가: import json | |
| 8 | 추가: from pathlib import Path | |
| 9 | 추가: import tarfile | |
| 10 | 추가: import zipfile | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 14 | 추가: GIB = 1024 ** 3 | |
| 15 | 추가: CHUNK = 64 * 1024 | |
| 16 | 추가: INPUT_LIMIT = 64 * 1024 ** 2 | |
| 17 | 추가: OUTPUT_LIMIT = 128 * 1024 ** 2 | |
| 18 | 추가: BASELINE = "d6b1a45" | |
| 19 | 추가: NAME = "payload.bin" | |
| 20 | 추가: | |
| 21 | 추가: | |
| 22 | 추가: class ZeroStream(io.RawIOBase): | |
| 23 | 추가: def __init__(self, size): | |
| 24 | 추가: self.remaining = size | |
| 25 | 추가: | |
| 26 | 추가: def read(self, size=-1): | |
| 27 | 추가: if size < 0 or size > CHUNK: | |
| 28 | 추가: raise ValueError("표본 읽기는 64 KiB 이하로 제한함") | |
| 29 | 추가: count = min(size, self.remaining) | |
| 30 | 추가: self.remaining -= count | |
| 31 | 추가: return bytes(count) | |
| 32 | 추가: | |
| 33 | 추가: | |
| 34 | 추가: def write_zip(path, size, compressed): | |
| 35 | 추가: info = zipfile.ZipInfo(NAME, (1980, 1, 1, 0, 0, 0)) | |
| 36 | 추가: info.compress_type = zipfile.ZIP_DEFLATED if compressed else zipfile.ZIP_STORED | |
| 37 | 추가: info.create_system = 3 | |
| 38 | 추가: info.external_attr = 0o100600 << 16 | |
| 39 | 추가: info.file_size = size | |
| 40 | 추가: with zipfile.ZipFile(path, "x", compression=info.compress_type) as archive: | |
| 41 | 추가: with archive.open(info, "w") as output: | |
| 42 | 추가: source = ZeroStream(size) | |
| 43 | 추가: while chunk := source.read(CHUNK): | |
| 44 | 추가: output.write(chunk) | |
| 45 | 추가: | |
| 46 | 추가: | |
| 47 | 추가: def tar_size(size): | |
| 48 | 추가: return 512 + ((size + 511) // 512) * 512 + 1024 | |
| 49 | 추가: | |
| 50 | 추가: | |
| 51 | 추가: def write_targz(path, size, compressed): | |
| 52 | 추가: info = tarfile.TarInfo(NAME) | |
| 53 | 추가: info.size = size | |
| 54 | 추가: info.mode = 0o600 | |
| 55 | 추가: info.mtime = 0 | |
| 56 | 추가: with path.open("xb") as raw: | |
| 57 | 추가: with gzip.GzipFile( | |
| 58 | 추가: filename="", mode="wb", fileobj=raw, | |
| 59 | 추가: compresslevel=6 if compressed else 0, mtime=0, | |
| 60 | 추가: ) as output: | |
| 61 | 추가: output.write(info.tobuf(format=tarfile.USTAR_FORMAT)) | |
| 62 | 추가: source = ZeroStream(size) | |
| 63 | 추가: while chunk := source.read(CHUNK): | |
| 64 | 추가: output.write(chunk) | |
| 65 | 추가: output.write(bytes((-size) % 512 + 1024)) | |
| 66 | 추가: | |
| 67 | 추가: | |
| 68 | 추가: def digest(path): | |
| 69 | 추가: value = hashlib.sha256() | |
| 70 | 추가: with path.open("rb") as source: | |
| 71 | 추가: while chunk := source.read(CHUNK): | |
| 72 | 추가: value.update(chunk) | |
| 73 | 추가: return value.hexdigest() | |
| 74 | 추가: | |
| 75 | 추가: | |
| 76 | 추가: def build(directory, large=False): | |
| 77 | 추가: directory = Path(directory).resolve() | |
| 78 | 추가: directory.relative_to(ROOT / "tests") | |
| 79 | 추가: directory.mkdir(mode=0o700, parents=True, exist_ok=False) | |
| 80 | 추가: cases = [] | |
| 81 | 추가: artifacts = {} | |
| 82 | 추가: | |
| 83 | 추가: def add(name, size, compressed, category, limits): | |
| 84 | 추가: path = directory / name | |
| 85 | 추가: if name.endswith(".zip"): | |
| 86 | 추가: write_zip(path, size, compressed) | |
| 87 | 추가: expanded = size | |
| 88 | 추가: else: | |
| 89 | 추가: write_targz(path, size, compressed) | |
| 90 | 추가: expanded = tar_size(size) | |
| 91 | 추가: artifacts[name] = { | |
| 92 | 추가: "archive_bytes": path.stat().st_size, | |
| 93 | 추가: "payload_bytes": size, | |
| 94 | 추가: "decoded_bytes": expanded, | |
| 95 | 추가: "sha256": digest(path), | |
| 96 | 추가: } | |
| 97 | 추가: for suffix, output_limit, failed in limits: | |
| 98 | 추가: cases.append({ | |
| 99 | 추가: "id": name + "-" + suffix, | |
| 100 | 추가: "file": name, | |
| 101 | 추가: "category": category, | |
| 102 | 추가: "limits": {"input": INPUT_LIMIT, "output": output_limit, "entries": 10000}, | |
| 103 | 추가: "expected": { | |
| 104 | 추가: "outcome": "Failed" if failed else "Completed", | |
| 105 | 추가: "error": "Limit" if failed else "None", | |
| 106 | 추가: "publication": "None" if failed else "Complete", | |
| 107 | 추가: "created_count": 0 if failed else 1, | |
| 108 | 추가: "retained_partial_count": 0, | |
| 109 | 추가: "output_events": 0 if failed else 1, | |
| 110 | 추가: }, | |
| 111 | 추가: }) | |
| 112 | 추가: | |
| 113 | 추가: for name, size in (("boundary.zip", CHUNK), ("boundary.tar.gz", CHUNK - 1536)): | |
| 114 | 추가: add(name, size, True, "output-boundary", [ | |
| 115 | 추가: ("below", CHUNK + 1, False), | |
| 116 | 추가: ("equal", CHUNK, False), | |
| 117 | 추가: ("above", CHUNK - 1, True), | |
| 118 | 추가: ]) | |
| 119 | 추가: if large: | |
| 120 | 추가: for extension in ("zip", "tar.gz"): | |
| 121 | 추가: add("large-input." + extension, GIB, False, "input-limit", [ | |
| 122 | 추가: ("default", OUTPUT_LIMIT, True), | |
| 123 | 추가: ]) | |
| 124 | 추가: add("large-expansion." + extension, GIB, True, "output-limit", [ | |
| 125 | 추가: ("default", OUTPUT_LIMIT, True), | |
| 126 | 추가: ]) | |
| 127 | 추가: manifest = { | |
| 128 | 추가: "baseline_commit": BASELINE, | |
| 129 | 추가: "worker_execution_verified": False, | |
| 130 | 추가: "generator_chunk_bytes": CHUNK, | |
| 131 | 추가: "artifacts": artifacts, | |
| 132 | 추가: "cases": cases, | |
| 133 | 추가: } | |
| 134 | 추가: (directory / "expectations.json").write_text( | |
| 135 | 추가: json.dumps(manifest, ensure_ascii=False, indent=4) + "\n", encoding="utf-8" | |
| 136 | 추가: ) | |
| 137 | 추가: return manifest | |
| 138 | 추가: | |
| 139 | 추가: | |
| 140 | 추가: def main(): | |
| 141 | 추가: parser = argparse.ArgumentParser() | |
| 142 | 추가: parser.add_argument("--output", required=True, type=Path, help="tests 아래의 새 디렉터리") | |
| 143 | 추가: parser.add_argument("--large", action="store_true", help="1 GiB 표본 4개도 생성함") | |
| 144 | 추가: args = parser.parse_args() | |
| 145 | 추가: manifest = build(args.output, args.large) | |
| 146 | 추가: print(f"{len(manifest['cases'])} cases: {args.output / 'expectations.json'}") | |
| 147 | 추가: | |
| 148 | 추가: | |
| 149 | 추가: if __name__ == "__main__": | |
| 150 | 추가: main() |
| @@ -0,0 +1,101 @@ | ||
| 1 | 추가: """생성 표본을 실제 작업자 프로세스에 전달해 현재 main의 기대값을 검사함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import gzip | |
| 5 | 추가: import json | |
| 6 | 추가: import os | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import signal | |
| 9 | 추가: import subprocess | |
| 10 | 추가: import tempfile | |
| 11 | 추가: import tarfile | |
| 12 | 추가: import zipfile | |
| 13 | 추가: | |
| 14 | 추가: from generate import CHUNK, NAME, ROOT, digest | |
| 15 | 추가: | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def check_payload(source, size): | |
| 19 | 추가: remaining = size | |
| 20 | 추가: while remaining: | |
| 21 | 추가: chunk = source.read(min(CHUNK, remaining)) | |
| 22 | 추가: assert chunk and chunk == bytes(len(chunk)) | |
| 23 | 추가: remaining -= len(chunk) | |
| 24 | 추가: | |
| 25 | 추가: | |
| 26 | 추가: def check_reference(path, artifact): | |
| 27 | 추가: size = artifact["payload_bytes"] | |
| 28 | 추가: if path.name.endswith(".zip"): | |
| 29 | 추가: with zipfile.ZipFile(path) as archive: | |
| 30 | 추가: assert archive.namelist() == [NAME] | |
| 31 | 추가: assert archive.getinfo(NAME).file_size == size | |
| 32 | 추가: with archive.open(NAME) as source: | |
| 33 | 추가: check_payload(source, size) | |
| 34 | 추가: assert source.read(1) == b"" | |
| 35 | 추가: else: | |
| 36 | 추가: with gzip.open(path, "rb") as source: | |
| 37 | 추가: header = source.read(512) | |
| 38 | 추가: info = tarfile.TarInfo.frombuf(header, "utf-8", "strict") | |
| 39 | 추가: assert info.name == NAME and info.size == size and info.isfile() | |
| 40 | 추가: check_payload(source, size) | |
| 41 | 추가: tail_size = (-size) % 512 + 1024 | |
| 42 | 추가: assert source.read(tail_size) == bytes(tail_size) | |
| 43 | 추가: assert source.read(1) == b"" | |
| 44 | 추가: | |
| 45 | 추가: | |
| 46 | 추가: def verify(directory, probe, worker): | |
| 47 | 추가: directory = directory.resolve() | |
| 48 | 추가: directory.relative_to(ROOT / "tests") | |
| 49 | 추가: manifest = json.loads((directory / "expectations.json").read_text(encoding="utf-8")) | |
| 50 | 추가: for name, artifact in manifest["artifacts"].items(): | |
| 51 | 추가: assert (directory / name).stat().st_size == artifact["archive_bytes"] | |
| 52 | 추가: assert digest(directory / name) == artifact["sha256"] | |
| 53 | 추가: check_reference(directory / name, artifact) | |
| 54 | 추가: results = [] | |
| 55 | 추가: for case in manifest["cases"]: | |
| 56 | 추가: path = directory / case["file"] | |
| 57 | 추가: artifact = manifest["artifacts"][case["file"]] | |
| 58 | 추가: before = path.stat() | |
| 59 | 추가: with tempfile.TemporaryDirectory(prefix="extract-", dir=directory) as scratch: | |
| 60 | 추가: destination = Path(scratch) | |
| 61 | 추가: command = [ | |
| 62 | 추가: str(probe.resolve()), str(worker.resolve()), str(path), str(destination), | |
| 63 | 추가: str(case["limits"]["output"]), case["expected"]["outcome"], | |
| 64 | 추가: str(artifact["payload_bytes"]), | |
| 65 | 추가: ] | |
| 66 | 추가: process = subprocess.Popen( | |
| 67 | 추가: command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
| 68 | 추가: start_new_session=(os.name == "posix"), | |
| 69 | 추가: ) | |
| 70 | 추가: try: | |
| 71 | 추가: stdout, stderr = process.communicate(timeout=360) | |
| 72 | 추가: except subprocess.TimeoutExpired: | |
| 73 | 추가: if os.name == "posix": | |
| 74 | 추가: os.killpg(process.pid, signal.SIGKILL) | |
| 75 | 추가: else: | |
| 76 | 추가: process.kill() | |
| 77 | 추가: process.communicate() | |
| 78 | 추가: raise | |
| 79 | 추가: assert process.returncode == 0, (case["id"], stdout, stderr) | |
| 80 | 추가: if case["expected"]["outcome"] == "Completed": | |
| 81 | 추가: with (destination / "payload.bin").open("rb") as source: | |
| 82 | 추가: while chunk := source.read(65536): | |
| 83 | 추가: assert not any(chunk) | |
| 84 | 추가: else: | |
| 85 | 추가: assert not list(destination.iterdir()) | |
| 86 | 추가: after = path.stat() | |
| 87 | 추가: assert (before.st_size, before.st_mtime_ns) == (after.st_size, after.st_mtime_ns) | |
| 88 | 추가: results.append({"case": case["id"], "status": "passed"}) | |
| 89 | 추가: print(f"PASS {case['id']}", flush=True) | |
| 90 | 추가: for name, artifact in manifest["artifacts"].items(): | |
| 91 | 추가: assert digest(directory / name) == artifact["sha256"] | |
| 92 | 추가: return results | |
| 93 | 추가: | |
| 94 | 추가: | |
| 95 | 추가: if __name__ == "__main__": | |
| 96 | 추가: parser = argparse.ArgumentParser() | |
| 97 | 추가: parser.add_argument("--directory", required=True, type=Path) | |
| 98 | 추가: parser.add_argument("--probe", required=True, type=Path) | |
| 99 | 추가: parser.add_argument("--worker", required=True, type=Path) | |
| 100 | 추가: args = parser.parse_args() | |
| 101 | 추가: verify(args.directory, args.probe, args.worker) |
| @@ -0,0 +1,187 @@ | ||
| 1 | 추가: # This file is automatically @generated by Cargo. | |
| 2 | 추가: # It is not intended for manual editing. | |
| 3 | 추가: version = 4 | |
| 4 | 추가: | |
| 5 | 추가: [[package]] | |
| 6 | 추가: name = "aes" | |
| 7 | 추가: version = "0.8.4" | |
| 8 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 9 | 추가: checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" | |
| 10 | 추가: dependencies = [ | |
| 11 | 추가: "cfg-if", | |
| 12 | 추가: "cipher", | |
| 13 | 추가: "cpufeatures", | |
| 14 | 추가: "zeroize", | |
| 15 | 추가: ] | |
| 16 | 추가: | |
| 17 | 추가: [[package]] | |
| 18 | 추가: name = "block-buffer" | |
| 19 | 추가: version = "0.10.4" | |
| 20 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 21 | 추가: checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" | |
| 22 | 추가: dependencies = [ | |
| 23 | 추가: "generic-array", | |
| 24 | 추가: ] | |
| 25 | 추가: | |
| 26 | 추가: [[package]] | |
| 27 | 추가: name = "cfg-if" | |
| 28 | 추가: version = "1.0.5" | |
| 29 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 30 | 추가: checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" | |
| 31 | 추가: | |
| 32 | 추가: [[package]] | |
| 33 | 추가: name = "cipher" | |
| 34 | 추가: version = "0.4.4" | |
| 35 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 36 | 추가: checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" | |
| 37 | 추가: dependencies = [ | |
| 38 | 추가: "crypto-common", | |
| 39 | 추가: "inout", | |
| 40 | 추가: ] | |
| 41 | 추가: | |
| 42 | 추가: [[package]] | |
| 43 | 추가: name = "cpufeatures" | |
| 44 | 추가: version = "0.2.17" | |
| 45 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 46 | 추가: checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" | |
| 47 | 추가: dependencies = [ | |
| 48 | 추가: "libc", | |
| 49 | 추가: ] | |
| 50 | 추가: | |
| 51 | 추가: [[package]] | |
| 52 | 추가: name = "crypto-common" | |
| 53 | 추가: version = "0.1.7" | |
| 54 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 55 | 추가: checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" | |
| 56 | 추가: dependencies = [ | |
| 57 | 추가: "generic-array", | |
| 58 | 추가: "typenum", | |
| 59 | 추가: ] | |
| 60 | 추가: | |
| 61 | 추가: [[package]] | |
| 62 | 추가: name = "digest" | |
| 63 | 추가: version = "0.10.7" | |
| 64 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 65 | 추가: checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" | |
| 66 | 추가: dependencies = [ | |
| 67 | 추가: "block-buffer", | |
| 68 | 추가: "crypto-common", | |
| 69 | 추가: "subtle", | |
| 70 | 추가: ] | |
| 71 | 추가: | |
| 72 | 추가: [[package]] | |
| 73 | 추가: name = "generic-array" | |
| 74 | 추가: version = "0.14.7" | |
| 75 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 76 | 추가: checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" | |
| 77 | 추가: dependencies = [ | |
| 78 | 추가: "typenum", | |
| 79 | 추가: "version_check", | |
| 80 | 추가: ] | |
| 81 | 추가: | |
| 82 | 추가: [[package]] | |
| 83 | 추가: name = "hmac" | |
| 84 | 추가: version = "0.12.1" | |
| 85 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 86 | 추가: checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" | |
| 87 | 추가: dependencies = [ | |
| 88 | 추가: "digest", | |
| 89 | 추가: ] | |
| 90 | 추가: | |
| 91 | 추가: [[package]] | |
| 92 | 추가: name = "inout" | |
| 93 | 추가: version = "0.1.4" | |
| 94 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 95 | 추가: checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" | |
| 96 | 추가: dependencies = [ | |
| 97 | 추가: "generic-array", | |
| 98 | 추가: ] | |
| 99 | 추가: | |
| 100 | 추가: [[package]] | |
| 101 | 추가: name = "libc" | |
| 102 | 추가: version = "0.2.191" | |
| 103 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 104 | 추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" | |
| 105 | 추가: | |
| 106 | 추가: [[package]] | |
| 107 | 추가: name = "pbkdf2" | |
| 108 | 추가: version = "0.12.2" | |
| 109 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 110 | 추가: checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" | |
| 111 | 추가: dependencies = [ | |
| 112 | 추가: "digest", | |
| 113 | 추가: "hmac", | |
| 114 | 추가: ] | |
| 115 | 추가: | |
| 116 | 추가: [[package]] | |
| 117 | 추가: name = "sha1" | |
| 118 | 추가: version = "0.10.7" | |
| 119 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 120 | 추가: checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" | |
| 121 | 추가: dependencies = [ | |
| 122 | 추가: "cfg-if", | |
| 123 | 추가: "cpufeatures", | |
| 124 | 추가: "digest", | |
| 125 | 추가: ] | |
| 126 | 추가: | |
| 127 | 추가: [[package]] | |
| 128 | 추가: name = "sha2" | |
| 129 | 추가: version = "0.10.9" | |
| 130 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 131 | 추가: checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" | |
| 132 | 추가: dependencies = [ | |
| 133 | 추가: "cfg-if", | |
| 134 | 추가: "cpufeatures", | |
| 135 | 추가: "digest", | |
| 136 | 추가: ] | |
| 137 | 추가: | |
| 138 | 추가: [[package]] | |
| 139 | 추가: name = "subtle" | |
| 140 | 추가: version = "2.6.1" | |
| 141 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 142 | 추가: checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" | |
| 143 | 추가: | |
| 144 | 추가: [[package]] | |
| 145 | 추가: name = "typenum" | |
| 146 | 추가: version = "1.20.1" | |
| 147 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 148 | 추가: checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" | |
| 149 | 추가: | |
| 150 | 추가: [[package]] | |
| 151 | 추가: name = "version_check" | |
| 152 | 추가: version = "0.9.5" | |
| 153 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 154 | 추가: checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" | |
| 155 | 추가: | |
| 156 | 추가: [[package]] | |
| 157 | 추가: name = "zeroize" | |
| 158 | 추가: version = "1.9.1" | |
| 159 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 160 | 추가: checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" | |
| 161 | 추가: | |
| 162 | 추가: [[package]] | |
| 163 | 추가: name = "zipelo-archive-worker" | |
| 164 | 추가: version = "0.1.0" | |
| 165 | 추가: dependencies = [ | |
| 166 | 추가: "aes", | |
| 167 | 추가: "hmac", | |
| 168 | 추가: "pbkdf2", | |
| 169 | 추가: "sha1", | |
| 170 | 추가: "sha2", | |
| 171 | 추가: "subtle", | |
| 172 | 추가: "zeroize", | |
| 173 | 추가: "zlib-rs", | |
| 174 | 추가: ] | |
| 175 | 추가: | |
| 176 | 추가: [[package]] | |
| 177 | 추가: name = "zipelo-large-archive-probe" | |
| 178 | 추가: version = "0.1.0" | |
| 179 | 추가: dependencies = [ | |
| 180 | 추가: "zipelo-archive-worker", | |
| 181 | 추가: ] | |
| 182 | 추가: | |
| 183 | 추가: [[package]] | |
| 184 | 추가: name = "zlib-rs" | |
| 185 | 추가: version = "0.6.8" | |
| 186 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 187 | 추가: checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| @@ -0,0 +1,18 @@ | ||
| 1 | 추가: [package] | |
| 2 | 추가: name = "zipelo-large-archive-probe" | |
| 3 | 추가: version = "0.1.0" | |
| 4 | 추가: edition = "2024" | |
| 5 | 추가: license = "MIT" | |
| 6 | 추가: publish = false | |
| 7 | 추가: autotests = false | |
| 8 | 추가: | |
| 9 | 추가: [workspace] | |
| 10 | 추가: | |
| 11 | 추가: [dependencies] | |
| 12 | 추가: zipelo-archive-worker = { path = "../../experiments/rust-archive-worker" } | |
| 13 | 추가: | |
| 14 | 추가: [[bin]] | |
| 15 | 추가: name = "zipelo-large-archive-probe" | |
| 16 | 추가: path = "probe.rs" | |
| 17 | 추가: test = false | |
| 18 | 추가: bench = false |
| @@ -0,0 +1,106 @@ | ||
| 1 | 추가: use std::{ | |
| 2 | 추가: fs, | |
| 3 | 추가: io::Write, | |
| 4 | 추가: path::PathBuf, | |
| 5 | 추가: process::{Command, Stdio}, | |
| 6 | 추가: }; | |
| 7 | 추가: use zipelo_archive_worker::{ | |
| 8 | 추가: protocol::*, | |
| 9 | 추가: wire::{Reader, Writer}, | |
| 10 | 추가: }; | |
| 11 | 추가: | |
| 12 | 추가: fn main() { | |
| 13 | 추가: let args: Vec<_> = std::env::args_os().skip(1).collect(); | |
| 14 | 추가: assert_eq!( | |
| 15 | 추가: args.len(), | |
| 16 | 추가: 6, | |
| 17 | 추가: "worker archive destination output_limit outcome payload_size" | |
| 18 | 추가: ); | |
| 19 | 추가: let source = PathBuf::from(&args[1]); | |
| 20 | 추가: let destination = PathBuf::from(&args[2]); | |
| 21 | 추가: assert_eq!(fs::read_dir(&destination).unwrap().count(), 0); | |
| 22 | 추가: let failed = args[4] == "Failed"; | |
| 23 | 추가: assert!(failed || args[4] == "Completed"); | |
| 24 | 추가: let output_limit = args[3].to_str().unwrap().parse().unwrap(); | |
| 25 | 추가: let payload_size: u64 = args[5].to_str().unwrap().parse().unwrap(); | |
| 26 | 추가: let start = Start { | |
| 27 | 추가: action: Action::Extract { | |
| 28 | 추가: archive: NativePath::from_path(&source), | |
| 29 | 추가: destination: NativePath::from_path(&destination), | |
| 30 | 추가: selection: Selection::All, | |
| 31 | 추가: list_id: None, | |
| 32 | 추가: gzip_output_name: None, | |
| 33 | 추가: }, | |
| 34 | 추가: limits: Limits { | |
| 35 | 추가: output: output_limit, | |
| 36 | 추가: ..Limits::default() | |
| 37 | 추가: }, | |
| 38 | 추가: }; | |
| 39 | 추가: let mut request = Vec::new(); | |
| 40 | 추가: Writer::new(&mut request, 17) | |
| 41 | 추가: .send(&Message::Start(start)) | |
| 42 | 추가: .unwrap(); | |
| 43 | 추가: let mut child = Command::new(&args[0]) | |
| 44 | 추가: .stdin(Stdio::piped()) | |
| 45 | 추가: .stdout(Stdio::piped()) | |
| 46 | 추가: .stderr(Stdio::piped()) | |
| 47 | 추가: .spawn() | |
| 48 | 추가: .unwrap(); | |
| 49 | 추가: child.stdin.take().unwrap().write_all(&request).unwrap(); | |
| 50 | 추가: let output = child.wait_with_output().unwrap(); | |
| 51 | 추가: assert!(output.status.success(), "{:?}", output.stderr); | |
| 52 | 추가: assert!(output.stderr.is_empty()); | |
| 53 | 추가: let mut reader = Reader::new(output.stdout.as_slice()); | |
| 54 | 추가: let mut terminals = 0; | |
| 55 | 추가: let mut outputs = 0; | |
| 56 | 추가: while let Some((job, _, message)) = reader.read().unwrap() { | |
| 57 | 추가: assert_eq!(job, 17); | |
| 58 | 추가: assert_eq!(terminals, 0, "Terminal 뒤 이벤트가 있음"); | |
| 59 | 추가: match message { | |
| 60 | 추가: Message::Output { .. } => outputs += 1, | |
| 61 | 추가: Message::Terminal(t) => { | |
| 62 | 추가: terminals += 1; | |
| 63 | 추가: assert_eq!( | |
| 64 | 추가: t.outcome, | |
| 65 | 추가: if failed { | |
| 66 | 추가: Outcome::Failed | |
| 67 | 추가: } else { | |
| 68 | 추가: Outcome::Completed | |
| 69 | 추가: } | |
| 70 | 추가: ); | |
| 71 | 추가: assert_eq!( | |
| 72 | 추가: t.error, | |
| 73 | 추가: if failed { | |
| 74 | 추가: ErrorCode::Limit | |
| 75 | 추가: } else { | |
| 76 | 추가: ErrorCode::None | |
| 77 | 추가: } | |
| 78 | 추가: ); | |
| 79 | 추가: assert_eq!( | |
| 80 | 추가: t.publication, | |
| 81 | 추가: if failed { | |
| 82 | 추가: Publication::None | |
| 83 | 추가: } else { | |
| 84 | 추가: Publication::Complete | |
| 85 | 추가: } | |
| 86 | 추가: ); | |
| 87 | 추가: assert_eq!(t.created_count, if failed { 0 } else { 1 }); | |
| 88 | 추가: assert_eq!(t.retained_partial_count, 0); | |
| 89 | 추가: assert_eq!(t.cleanup, Cleanup::Complete); | |
| 90 | 추가: } | |
| 91 | 추가: _ => {} | |
| 92 | 추가: } | |
| 93 | 추가: } | |
| 94 | 추가: assert_eq!(terminals, 1); | |
| 95 | 추가: assert_eq!(outputs, if failed { 0 } else { 1 }); | |
| 96 | 추가: assert_eq!( | |
| 97 | 추가: fs::read_dir(&destination).unwrap().count(), | |
| 98 | 추가: if failed { 0 } else { 1 } | |
| 99 | 추가: ); | |
| 100 | 추가: if !failed { | |
| 101 | 추가: assert_eq!( | |
| 102 | 추가: fs::metadata(destination.join("payload.bin")).unwrap().len(), | |
| 103 | 추가: payload_size | |
| 104 | 추가: ); | |
| 105 | 추가: } | |
| 106 | 추가: } |