]> git.hungrycats.org Git - bees/commitdiff
test/integration/05: re-enable phase 10 as SubExtent-of-SuperExtent
authorZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 20:15:12 +0000 (16:15 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sun, 11 Oct 2026 00:48:00 +0000 (20:48 -0400)
Phase 10 built a SubExtent across both parts of a SuperExtent and was
disabled because the constructor rejects it.  That rejection is
correct: such a range has no single bytenr and no btrfs operation that
produces it.  Rewrite the phase to test what is valid now:

  - a SubExtent inside either part reads that part's blocks, reports
    two data blocks with hashes, and stays insertable;
  - a SubExtent across the parts is rejected.

Add it_assert_repl_out_grep to check the REPL's output, where command
errors are reported, for the rejection.

Assisted-by: Claude-Code:claude-opus-5-5
test/integration/cases/05-bees-repl.sh
test/integration/lib/testlib.sh

index 89145daebef88282003577ce8d8978bc9c3ce1ec..07bd444472a8673de18c541c071c78477447a3ef 100755 (executable)
 #     - flush-hash: write to disk
 #     - Assert: beeshash.dat exists and is non-empty
 #
-#   Phase 10: Nested extent-tree readback
-#     - Build a block-ID file
-#     - Construct SubExtent(SuperExtent(...)) trees in the REPL
-#     - Verify readback returns blocks in the expected remapped order
+#   Phase 10: SubExtent of a SuperExtent
+#     - Build SuperExtent { right, left } from two slices of the block-ID file
+#     - A SubExtent inside one part reads that part's blocks
+#     - A SubExtent across parts is rejected
 #
 #   Phase 11: Mixed materialized-source readback
 #     - Build a tree containing direct btrfs slices, a tempfile-backed copy,
@@ -273,7 +273,8 @@ PY
 EXPECT_COMP_COPY_HEX=$(it_hex_range "$COMP_SUBVOL/zstd-small" 1024 1024)
 EXPECT_COPY_HEX="${EXPECT_SHARED_HEX}${EXPECT_TAIL_HEX}"
 SIZE_COPY_BYTES=$(( 4096 + SIZE_TAIL_WINDOW ))
-EXPECT_TREE_NESTED_HEX=$(it_hex_concat_ranges "$RW_SUBVOL/blockids" 24576 8192 4096 8192)
+EXPECT_TREE_SUB_RIGHT_HEX=$(it_hex_concat_ranges "$RW_SUBVOL/blockids" 24576 8192)
+EXPECT_TREE_SUB_LEFT_HEX=$(it_hex_concat_ranges "$RW_SUBVOL/blockids" 8192 8192)
 EXPECT_TREE_MIXED_HEX_HEAD=$(it_hex_concat_ranges "$RW_SUBVOL/blockids" 0 8192 16384 8192)
 EXPECT_TREE_MIXED_HEX_TAIL=$(it_hex_concat_ranges "$RW_SUBVOL/blockids" 12288 4096)
 EXPECT_TREE_HOLE_HEX=$(python3 - <<'PY'
@@ -699,22 +700,14 @@ it_assert_repl_log_empty "phase9: repl stderr log is empty"
 it_assert_remote_file "$BEESHOME/beeshash.dat"
 it_assert_remote_file_nonempty "$BEESHOME/beeshash.dat"
 
-# ── Phase 10: nested extent-tree readback (DISABLED) ──────────────────────────
+# ── Phase 10: SubExtent of a SuperExtent ───────────────────────────────────────
 #
-# Exercises tree-subextent composed on top of tree-superextent (sub-of-super).
-# BeesSubExtentNode's constructor rejects super children (bees-extent-tree.cc
-# around 1764) because its bytenr() delegates to the child and a super has no
-# single bytenr.  Lifting that constraint requires design work on
-# BeesSubExtentNode (representative-part bytenr, or ctor-time flattening into
-# per-part sub slices).  Until that lands, phase10 cannot pass; leaving it
-# enabled makes every release run report a failure that is actually a
-# pending-feature marker.
-#
-# To re-enable: change `if false` to `if true` after the sub-of-super
-# constraint is relaxed.  Expected passing output is preserved below.
+# t_join = SuperExtent { t_right at [0, 12288), t_left at [12288, 24576) }.
+# A SubExtent inside one part narrows that part's child, so it has the
+# part's bytenr.  A SubExtent across parts has no btrfs counterpart and is
+# rejected; that case needs a TempExtent or MaterializedExtent (phase 11).
 
-if false; then
-echo "[phase10] nested extent-tree readback"
+echo "[phase10] subextent within one part of a superextent"
 it_repl "$BEESHOME" <<REPL
 set paths.home $BEESHOME
 open-root $TEST_MOUNT
@@ -725,27 +718,49 @@ tree-from-extent t_base e_blocks
 tree-subextent t_left t_base 4096 16384
 tree-subextent t_right t_base 20480 32768
 tree-superextent t_join t_right 0 12288 0 12288 t_left 0 12288 12288 24576
-tree-subextent t_nested t_join 4096 20480
-tree-read t_nested 0 16384
-tree-blocks t_nested 0 16384
+tree-subextent t_in_right t_join 4096 12288
+tree-read t_in_right 0 8192
+tree-subextent t_in_left t_join 16384 24576
+tree-read t_in_left 0 8192
+tree-blocks t_in_left 0 8192
 
 quit
 REPL
 
-it_assert_repl_line "phase10: nested tree reads four blocks" \
-    "value bytes 16384"
-it_assert_repl_line "phase10: nested tree remaps blocks in expected order" \
-    "value data 0 $EXPECT_TREE_NESTED_HEX"
-it_assert_repl_line "phase10: nested tree reports four logical blocks" \
-    "value blocks 4"
-it_assert_repl_line "phase10: nested tree sees four data blocks" \
-    "value data_blocks 4"
-it_assert_repl_line "phase10: nested tree sees four hashes" \
-    "value hashed_blocks 4"
-it_assert_repl_line "phase10: nested tree stays insertable" \
+it_assert_repl_line "phase10: sub within one part reads two blocks" \
+    "value bytes 8192"
+it_assert_repl_line "phase10: sub within the first part reads its blocks" \
+    "value data 0 $EXPECT_TREE_SUB_RIGHT_HEX"
+it_assert_repl_line "phase10: sub within the second part reads its blocks" \
+    "value data 0 $EXPECT_TREE_SUB_LEFT_HEX"
+it_assert_repl_line "phase10: sub within one part reports two logical blocks" \
+    "value blocks 2"
+it_assert_repl_line "phase10: sub within one part sees two data blocks" \
+    "value data_blocks 2"
+it_assert_repl_line "phase10: sub within one part sees two hashes" \
+    "value hashed_blocks 2"
+it_assert_repl_line "phase10: sub within one part stays insertable" \
     "value insertable yes"
 it_assert_repl_log_empty "phase10: repl stderr log is empty"
-fi
+
+echo "[phase10] subextent across superextent parts is rejected"
+it_repl "$BEESHOME" <<REPL
+set paths.home $BEESHOME
+open-root $TEST_MOUNT
+apply-config
+
+extent-create e_blocks $BYTENR_BLOCKIDS
+tree-from-extent t_base e_blocks
+tree-subextent t_left t_base 4096 16384
+tree-subextent t_right t_base 20480 32768
+tree-superextent t_join t_right 0 12288 0 12288 t_left 0 12288 12288 24576
+tree-subextent t_cross t_join 4096 20480
+
+quit
+REPL
+
+it_assert_repl_out_grep "phase10: sub across parts is rejected" \
+    "spans more than one part of a SuperExtent"
 
 # ── Phase 11: mixed materialized-source readback ─────────────────────────────
 
index c885b1a06fbc48f2b67f2bb9d0790cf1965e54a4..857b93a2450fc1b9ad8fedea38d52fa09864cd40 100755 (executable)
@@ -579,6 +579,22 @@ it_assert_repl_log_empty() {
     fi
 }
 
+it_assert_repl_out_grep() {
+    # Assert that the current REPL output (where command errors are
+    # reported) contains the substring.
+    local label="$1"
+    local pattern="$2"
+    if it_ssh "grep -qF -- $(printf '%q' "$pattern") '$IT_REPL_OUTFILE'"; then
+        echo "[pass] $label"
+        (( ++IT_PASS ))
+    else
+        echo "[FAIL] $label" >&2
+        (( ++IT_FAIL ))
+        it_repl_logfile_tail
+        exit 1
+    fi
+}
+
 it_assert_exit_zero() {
     local pid
     pid=$(it_bees_pid)