Skip to content

Commit 5ba0dcd

Browse files
genednaclaude
andcommitted
v0.41.7: BB-10 OCI client smoke framework
Add scripts/oci_client_smoke_storage_only.sh (plan-20261001 BB-10), the OCI /v2 black-box framework for the interop-smoke runner: sources the shared runner, builds a RUN_ID, and exits 2 on a missing tool (curl, jq, oras, sha256sum, mktemp, date, rm, perl), an empty push token or an unreachable registry (bounded preflight). No cases yet. Documents the single-case command in deploy-trunk §10.4 and lists the script in docs/refactoring/oci.md. Marks BB-07 done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018bJDjze83ToyPysYzmxxWS Signed-off-by: Eli Ma <eli@patch.sh>
1 parent 84f5f31 commit 5ba0dcd

6 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mega2"
3-
version = "0.41.6"
3+
version = "0.41.7"
44
edition = "2024"
55
license = "MIT OR Apache-2.0"
66
description = "Monorepo engine and Git hosting server for AI agents: trunk-based storage, Git Smart HTTP, Git LFS, OCI registry, and Agent Session Capture"

‎docs/deploy-trunk.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,15 @@ HTTP 明文 registry(如本机 compose `http://127.0.0.1:9000`)需在客户
385385

386386
manifest/blob `DELETE` 路由存在但恒返回 OCI `UNSUPPORTED`(405)。`_catalog` / referrers 未实现。
387387

388+
### 10.4 Compose 黑盒(oras / curl)
389+
390+
[plan-20261001](plan/plan-20261001.md) 的 OCI 黑盒脚本 `scripts/oci_client_smoke_storage_only.sh` 在 `interop-smoke` 容器内运行(客户端为 `oras` 与 `curl`,不用 libra),经容器内环回中继访问 `http://127.0.0.1:9000/v2/`。先按 §8 启动栈与 `interop-smoke`,单 case 运行并把结果 tee 到本地(输出与退出码契约:`==> / PASS: / FAIL: / SKIP:`,末行 `oci client smoke storage_only summary: …`;0 通过,1 有失败,2 前置错误或 case 名未匹配):
391+
392+
```bash
393+
mkdir -p target/tmp; set -o pipefail
394+
CASE='OCI ping' # 换成要跑的 case 名
395+
docker compose -p mega2-trunk -f docker/docker-compose-storage-only.yml --profile interop exec -T -e MEGA2_SMOKE_CASE="$CASE" interop-smoke bash /repo/scripts/oci_client_smoke_storage_only.sh 2>&1 | tee target/tmp/bb-oci-case.log
396+
```
397+
398+
不设 `MEGA2_SMOKE_CASE` 时整跑全部默认栈 case;opt-in case(auth-none)只经 `scripts/bb_optin_run.sh none oci_client_smoke_storage_only.sh '<case>' <log>` 运行。
399+

‎docs/plan/plan-20261001.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@
874874
### Task BB-07: opt-in helper 输入校验与错误退出码
875875

876876
**Task type:** `implementation`
877-
**Lifecycle / Acceptance:** `in-progress` / `remote-pending`(v0.41.6;Codex R3 PASS;C 组 2023 测试通过;待 D 组 `docker` job)
877+
**Lifecycle / Acceptance:** `done` / `complete`(v0.41.6;Codex R3 PASS;C 组 2023 测试通过;D 组 docker run 36914117376 success)
878878
**Description:** 给 `scripts/bb_optin_run.sh` 加入切栈前的输入校验:未知模式或所需 env-file 缺失时退出 2 且不触碰 mega2;恢复失败(hash 不符或 mega2 不健康)时退出 3,并提供仅测试用的故障注入开关 `MEGA2_OPTIN_FAULT_RESTORE=hash|unhealthy`(把恢复后的 hash 比对或健康等待强制判为失败)与 env-file 目录覆盖 `MEGA2_OPTIN_CONFIG_DIR`(默认 `config/`);在 `docs/deploy-trunk.md` §8 写明退出码 2 与 3。唯一行为轴:helper 的错误路径。
879879
**Out of scope:** 正常切换与恢复(BB-03);任何 case。
880880
**Current evidence:**
@@ -952,7 +952,7 @@
952952
### Task BB-10: OCI client smoke 脚本骨架
953953

954954
**Task type:** `implementation`
955-
**Lifecycle / Acceptance:** `pending` / (空)
955+
**Lifecycle / Acceptance:** `in-progress` / `remote-pending`(v0.41.7;Codex R4 PASS;C 组 2023 测试通过(`RUST_TEST_THREADS=4`、`NO_PROXY` 环境下;此前三次环境抖动);待 D 组 `docker` job)
956956
**Description:** 新建 `scripts/oci_client_smoke_storage_only.sh`:引入共享 runner 库、生成 `RUN_ID`(ADR-BB-07)、做前置检查、**零 case**;同步 `docs/deploy-trunk.md` §10.4。唯一行为轴:oci client smoke 运行框架。
957957
**Out of scope:** 任何 case(本域场景卡逐一承接);改既有 smoke 脚本(GC-BB-06)。
958958
**Current evidence:**

‎docs/refactoring/oci.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,5 @@ DELETE /uploads/{uuid} → 按 seq 删分片 + 删行 → 204
191191
| `src/jupiter/storage/oci_db_storage.rs` | 元数据 CRUD |
192192
| `config/config-storage-only.toml` `[oci]` | 样例启用 |
193193
| `scripts/oci_smoke_storage_only.sh` | 宿主机 docker CLI live smoke |
194+
| `scripts/oci_client_smoke_storage_only.sh` | compose 栈内 `interop-smoke` 的 oras / curl 黑盒 smoke([plan-20261001](../plan/plan-20261001.md);运行方式见 [`deploy-trunk.md`](../deploy-trunk.md) §10.4) |
194195
| `tests/integration_oci.rs` | 进程级黑盒 IT |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
# OCI Distribution (/v2) black-box smoke for the storage-only compose stack
3+
# (docs/plan/plan-20261001.md, OCI domain BB-10..BB-23). Runs inside the
4+
# `interop-smoke` service; clients are oras and curl (never libra, ADR-BB-03).
5+
#
6+
# docker compose -p mega2-trunk -f docker/docker-compose-storage-only.yml --profile interop \
7+
# exec -T [-e MEGA2_SMOKE_CASE='<case>'] interop-smoke bash /repo/scripts/oci_client_smoke_storage_only.sh
8+
#
9+
# Env: MEGA2_BASE_URL (default http://127.0.0.1:9000, the runner's loopback
10+
# relay to mega2), MEGA2_IT_SEED_TOKEN (push token), MEGA2_SMOKE_CASE
11+
# (exact case name), MEGA2_SMOKE_AUTH_NONE=1 (opt-in auth-none cases; use
12+
# scripts/bb_optin_run.sh). Output and exit codes: scripts/lib/smoke-runner.sh.
13+
set -uo pipefail
14+
15+
# Only bash builtins until require_tools has run, so a missing tool exits 2.
16+
SCRIPT_DIR="${BASH_SOURCE[0]%/*}"
17+
[ "$SCRIPT_DIR" = "${BASH_SOURCE[0]}" ] && SCRIPT_DIR=.
18+
# shellcheck source=scripts/lib/smoke-runner.sh disable=SC1091
19+
source "$SCRIPT_DIR/lib/smoke-runner.sh"
20+
21+
smoke_init "oci client"
22+
require_tools curl jq oras sha256sum mktemp date rm perl
23+
24+
MEGA2_BASE_URL="${MEGA2_BASE_URL:-http://127.0.0.1:9000}"
25+
MEGA2_BASE_URL="${MEGA2_BASE_URL%/}"
26+
TOKEN="${MEGA2_IT_SEED_TOKEN:-}"
27+
[ -n "$TOKEN" ] || smoke_die "MEGA2_IT_SEED_TOKEN is empty"
28+
REGISTRY="${MEGA2_BASE_URL#http://}"
29+
RUN_ID="$(date -u +%Y%m%dt%H%M%S)" || smoke_die "cannot build RUN_ID"
30+
RUN_ID="$RUN_ID$RANDOM"
31+
WORK="$(mktemp -d)" || smoke_die "cannot create a work directory"
32+
trap 'rm -rf "$WORK"' EXIT
33+
34+
# Preflight: any HTTP status from GET /v2/ means the registry is reachable.
35+
code=$(curl -sS --connect-timeout 3 --max-time 5 -o /dev/null -w '%{http_code}' "$MEGA2_BASE_URL/v2/" 2>/dev/null || true)
36+
[[ "$code" =~ ^[1-5][0-9][0-9]$ ]] || smoke_die "$MEGA2_BASE_URL/v2/ is not reachable"
37+
38+
export REGISTRY RUN_ID WORK TOKEN MEGA2_BASE_URL
39+
40+
finish

0 commit comments

Comments
 (0)