Viewing files at commit 4f4412a18356Commit detailsView latest

suites/robustness/repro/pull-kill.sh 32 lines · 2.3 KB · bash
1
#!/bin/bash
2
# P4 finding (fb-535, pull variant): `oak pull` (fast-forward) SIGKILLed
3
# mid-materialization leaves some files with the incoming content while the
4
# store's head has not moved. Status lists them as the user's uncommitted
5
# changes (progress_state.in_progress=false), and re-running `oak pull` advises
6
# "run `oak commit` to keep them", which would record the pull's partial output
7
# as the user's own work.
8
# Usage: pull-kill.sh <oak> <outdir> [kill_after_seconds]
9
set -u
10
OAK=$1; OUT=$2; DELAY=${3:-0.8}
11
rm -rf "$OUT"; mkdir -p "$OUT/home" "$OUT/a"
12
export HOME=$OUT/home OAK_NO_UPDATE_CHECK=1 OAK_API_KEY=p4tok OAK_AUTHOR=p4
13
unset OAK_REMOTE OAK_REPO OAK_TOKEN
14
PORT=$(python3 -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1])')
15
"$OAK" serve --dir "$OUT/srv" --port $PORT --token p4tok >"$OUT/serve.log" 2>&1 & SP=$!
16
trap 'kill $SP 2>/dev/null' EXIT
17
for i in $(seq 1 100); do curl -s -o /dev/null http://127.0.0.1:$PORT/api/capabilities && break; sleep 0.05; done
18
cd "$OUT/a"; "$OAK" init . >/dev/null 2>&1
19
for i in $(seq 0 399); do mkdir -p d$((i%10)); printf 'base %s\n%.0s' $i $(seq 1 40) > d$((i%10))/f$i.txt; done
20
"$OAK" commit >/dev/null 2>&1; "$OAK" push --repo p4/r -r http://127.0.0.1:$PORT >/dev/null 2>&1 || { echo push failed; exit 2; }
21
BR=$(sqlite3 .oak/oak.db "select value from metadata where key='current_branch'")
22
cd "$OUT"; "$OAK" clone p4/r b -r http://127.0.0.1:$PORT --branch "$BR" >/dev/null 2>&1
23
cd "$OUT/b"; for i in $(seq 0 399); do printf 'theirs %s\n%.0s' $i $(seq 1 40) > d$((i%10))/f$i.txt; done
24
"$OAK" commit >/dev/null 2>&1; "$OAK" push >/dev/null 2>&1
25
cd "$OUT/a"; H0=$(sqlite3 .oak/oak.db "select value from metadata where key='head'")
26
"$OAK" pull >/dev/null 2>&1 & P=$!
27
python3 -c "import time;time.sleep($DELAY)"; kill -9 $P 2>/dev/null && echo "killed pull after ${DELAY}s"; wait $P 2>/dev/null
28
H1=$(sqlite3 .oak/oak.db "select value from metadata where key='head'")
29
echo "store head moved: $([ "$H0" = "$H1" ] && echo no || echo yes)"
30
echo "files with incoming content: $(grep -l '^theirs' d*/f*.txt | wc -l | tr -d ' ') / 400"
31
"$OAK" status --json | python3 -c 'import sys,json;d=json.load(sys.stdin);print("status changes:",len(d["working_changes"]["changes"]),"in_progress:",(d.get("progress_state") or {}).get("in_progress"))'
32
"$OAK" pull; echo "re-run pull exit=$?"