Skip to content

Commit f5fef6e

Browse files
committed
test(e2e): cover repeated up sync reuse
1 parent dfe3e0c commit f5fef6e

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

scripts/e2e_kind_smoke.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,44 @@ if [[ "$SYNC_OK" != "true" ]]; then
194194
exit 1
195195
fi
196196

197+
echo "Verifying repeated okdev up reuses active sync"
198+
SYNC_PID_BEFORE=$(printf '%s' "$STATUS_OUTPUT" | sync_pid_from_status)
199+
if [[ -z "$SYNC_PID_BEFORE" ]]; then
200+
echo "ERROR: expected status to include running sync pid before repeated up" >&2
201+
echo "$STATUS_OUTPUT" >&2
202+
exit 1
203+
fi
204+
SYNC_LOG_LINES_BEFORE=$(wc -l <"$SYNC_HOME/local.log")
205+
REPEAT_UP_OUTPUT=$("$OKDEV_BIN" --config "$CFG_PATH" --session "$SESSION_NAME" up --wait-timeout 5m)
206+
echo "$REPEAT_UP_OUTPUT"
207+
if [[ "$REPEAT_UP_OUTPUT" != *"reused existing workload"* ]]; then
208+
echo "ERROR: expected repeated up to reuse existing pod workload" >&2
209+
exit 1
210+
fi
211+
if [[ "$REPEAT_UP_OUTPUT" != *"sync: already active"* ]]; then
212+
echo "ERROR: expected repeated up to report already-active sync" >&2
213+
exit 1
214+
fi
215+
REPEAT_STATUS=$("$OKDEV_BIN" --config "$CFG_PATH" --session "$SESSION_NAME" status --details)
216+
echo "$REPEAT_STATUS"
217+
SYNC_PID_AFTER=$(printf '%s' "$REPEAT_STATUS" | sync_pid_from_status)
218+
if [[ "$SYNC_PID_AFTER" != "$SYNC_PID_BEFORE" ]]; then
219+
echo "ERROR: expected sync pid to remain $SYNC_PID_BEFORE after repeated up, got ${SYNC_PID_AFTER:-missing}" >&2
220+
exit 1
221+
fi
222+
if [[ "$REPEAT_STATUS" != *"health: active"* ]]; then
223+
echo "ERROR: expected sync health to remain active after repeated up" >&2
224+
exit 1
225+
fi
226+
SYNC_LOG_LINES_AFTER=$(wc -l <"$SYNC_HOME/local.log")
227+
if [[ $((SYNC_LOG_LINES_AFTER - SYNC_LOG_LINES_BEFORE)) -gt 5 ]]; then
228+
echo "ERROR: expected repeated up not to restart or churn sync log" >&2
229+
tail -20 "$SYNC_HOME/local.log" >&2
230+
exit 1
231+
fi
232+
STATUS_OUTPUT="$REPEAT_STATUS"
233+
echo "Repeated okdev up sync reuse verified"
234+
197235
echo "Verifying remote shell and logs"
198236
"$OKDEV_BIN" --config "$CFG_PATH" --session "$SESSION_NAME" ssh --setup-key --cmd 'test -f /workspace/hello.txt'
199237
LOG_OUTPUT=$("$OKDEV_BIN" --config "$CFG_PATH" --session "$SESSION_NAME" logs --all --follow=false --tail 10)

scripts/e2e_lib.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,15 @@ assert_no_local_sync_processes() {
111111
echo "$matches" >&2
112112
return 1
113113
}
114+
115+
sync_pid_from_status() {
116+
python3 - <<'PY'
117+
import re
118+
import sys
119+
120+
status = sys.stdin.read()
121+
match = re.search(r"background: running \(pid ([0-9]+)\)", status)
122+
if match:
123+
print(match.group(1))
124+
PY
125+
}

0 commit comments

Comments
 (0)