team-ljyzipelo

공개

대용량 압축 표본 생성과 한도 경계 검증을 추가

작성자
코노모리 카논
작성 시각
커밋
93039f3db461575d34bff083ff179520a2ff2c1c
부모
d6b1a45
이 시점의 파일 보기

변경된 파일 8개

+670-0
추가tests/ci/test_large_archive_fixtures.py+74-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()
추가tests/large-archive-fixtures/.gitignore+1-0
@@ -0,0 +1 @@
1추가: /runs/
추가tests/large-archive-fixtures/README.md+33-0
@@ -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 실행은 별도 검증이 필요합니다.
추가tests/large-archive-fixtures/generate.py+150-0
@@ -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()
추가tests/large-archive-fixtures/verify.py+101-0
@@ -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)
추가tests/rust-large-archive-fixtures/Cargo.lock+187-0
@@ -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"
추가tests/rust-large-archive-fixtures/Cargo.toml+18-0
@@ -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
추가tests/rust-large-archive-fixtures/probe.rs+106-0
@@ -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추가: }