11#! /usr/bin/env bash
22set -Eeuo pipefail
3+ # Signal traps inherit the foreground command's redirections. Keep harness stdout separate so the
4+ # final summary location cannot corrupt a command artifact when the run is interrupted.
5+ exec 3>&1
36
47source scripts/lib/openclaw-e2e-instance.sh
58
@@ -38,7 +41,7 @@ export TELEGRAM_BOT_TOKEN="123456:upgrade-survivor-telegram-token"
3841if [ " $SCENARIO " = " feishu-channel" ]; then
3942 export FEISHU_APP_SECRET=" upgrade-survivor-feishu-secret"
4043fi
41- if [ " $SCENARIO " = " configured-plugin-installs" ]; then
44+ if [ " $SCENARIO " = " configured-plugin-installs" ] || [ " $SCENARIO " = " sqlite-volume " ] ; then
4245 export MATRIX_ACCESS_TOKEN=" upgrade-survivor-matrix-token"
4346 export BRAVE_API_KEY=" BSA_upgrade_survivor_brave_key"
4447fi
@@ -85,6 +88,9 @@ status_seconds=""
8588healthz_seconds=" "
8689readyz_seconds=" "
8790update_restart_seconds=" "
91+ migration_seconds=" "
92+ idempotence_seconds=" "
93+ run_completed=" 0"
8894
8995BASELINE_INSTALL_LOG=" $ARTIFACT_ROOT /baseline-install.log"
9096UPDATE_JSON=" $ARTIFACT_ROOT /update.json"
@@ -197,6 +203,8 @@ write_summary() {
197203 SUMMARY_UPDATE_RESTART_MODE=" $UPDATE_RESTART_MODE " \
198204 SUMMARY_START_SECONDS=" $start_seconds " \
199205 SUMMARY_UPDATE_RESTART_SECONDS=" $update_restart_seconds " \
206+ SUMMARY_MIGRATION_SECONDS=" $migration_seconds " \
207+ SUMMARY_IDEMPOTENCE_SECONDS=" $idempotence_seconds " \
200208 SUMMARY_HEALTHZ_SECONDS=" $healthz_seconds " \
201209 SUMMARY_READYZ_SECONDS=" $readyz_seconds " \
202210 SUMMARY_STATUS_SECONDS=" $status_seconds " \
@@ -234,6 +242,8 @@ const summary = {
234242 timings: {
235243 startupSeconds: numberOrNull(process.env.SUMMARY_START_SECONDS),
236244 updateRestartSeconds: numberOrNull(process.env.SUMMARY_UPDATE_RESTART_SECONDS),
245+ migrationSeconds: numberOrNull(process.env.SUMMARY_MIGRATION_SECONDS),
246+ idempotenceSeconds: numberOrNull(process.env.SUMMARY_IDEMPOTENCE_SECONDS),
237247 healthzSeconds: numberOrNull(process.env.SUMMARY_HEALTHZ_SECONDS),
238248 readyzSeconds: numberOrNull(process.env.SUMMARY_READYZ_SECONDS),
239249 statusSeconds: numberOrNull(process.env.SUMMARY_STATUS_SECONDS),
@@ -281,24 +291,40 @@ on_error() {
281291 return " $status "
282292}
283293
294+ on_signal () {
295+ local signal=" $1 "
296+ local status=" $2 "
297+ trap - HUP INT TERM
298+ FAILURE_PHASE=" ${CURRENT_PHASE:- unknown} "
299+ FAILURE_MESSAGE=" phase ${FAILURE_PHASE} interrupted by ${signal} "
300+ exit " $status "
301+ }
302+
284303on_exit () {
285304 local status=" $1 "
305+ trap - ERR EXIT HUP INT TERM
286306 set +e
287307 cleanup
288- if [ " $status " -eq 0 ]; then
308+ if [ " $status " -eq 0 ] && [ " $run_completed " = " 1 " ] ; then
289309 write_summary passed " "
290310 else
311+ if [ " $status " -eq 0 ]; then
312+ status=1
313+ FAILURE_MESSAGE=" upgrade survivor exited before all phases completed"
314+ fi
291315 [ -n " $FAILURE_PHASE " ] || FAILURE_PHASE=" ${CURRENT_PHASE:- unknown} "
292316 [ -n " $FAILURE_MESSAGE " ] || FAILURE_MESSAGE=" upgrade survivor failed with status $status "
293317 write_summary failed " $FAILURE_MESSAGE "
294318 fi
295- echo " Upgrade survivor summary: $SUMMARY_JSON "
296- cat " $SUMMARY_JSON " 2> /dev/null || true
319+ echo " Upgrade survivor summary: $SUMMARY_JSON " >&3
297320 exit " $status "
298321}
299322
300323trap ' on_error $?' ERR
301324trap ' on_exit $?' EXIT
325+ trap ' on_signal SIGHUP 129' HUP
326+ trap ' on_signal SIGINT 130' INT
327+ trap ' on_signal SIGTERM 143' TERM
302328
303329phase () {
304330 local name=" $1 "
@@ -357,7 +383,7 @@ plugin_deps_cleanup_plugin_dirs() {
357383}
358384
359385configured_plugin_installs_enabled () {
360- [ " $SCENARIO " = " configured-plugin-installs" ]
386+ [ " $SCENARIO " = " configured-plugin-installs" ] || [ " $SCENARIO " = " sqlite-volume " ]
361387}
362388
363389source_only_plugin_shadow_enabled () {
@@ -1449,11 +1475,40 @@ assert_root_managed_vps_cli_usable() {
14491475}
14501476
14511477run_doctor () {
1478+ local started_at budget
1479+ started_at=" $( date +%s) "
14521480 if ! openclaw_e2e_maybe_timeout " $COMMAND_TIMEOUT " openclaw doctor --fix --non-interactive > " $DOCTOR_LOG " 2>&1 ; then
14531481 echo " openclaw doctor failed" >&2
14541482 openclaw_e2e_print_log " $DOCTOR_LOG " >&2
14551483 return 1
14561484 fi
1485+ if [ " $SCENARIO " = " sqlite-volume" ]; then
1486+ migration_seconds=$(( $(date +% s) - started_at))
1487+ budget=" $( openclaw_e2e_read_positive_int_env OPENCLAW_UPGRADE_SURVIVOR_VOLUME_MIGRATION_BUDGET_SECONDS 120) "
1488+ echo " SQLite volume migration doctor completed in ${migration_seconds} s (budget ${budget} s)."
1489+ if [ " $migration_seconds " -gt " $budget " ]; then
1490+ echo " SQLite volume migration exceeded budget: ${migration_seconds} s > ${budget} s" >&2
1491+ return 1
1492+ fi
1493+ fi
1494+ }
1495+
1496+ assert_volume_idempotence () {
1497+ local started_at budget
1498+ started_at=" $( date +%s) "
1499+ if ! openclaw_e2e_maybe_timeout " $COMMAND_TIMEOUT " openclaw doctor --fix --non-interactive >> " $DOCTOR_LOG " 2>&1 ; then
1500+ echo " openclaw idempotence doctor failed" >&2
1501+ openclaw_e2e_print_log " $DOCTOR_LOG " >&2
1502+ return 1
1503+ fi
1504+ idempotence_seconds=$(( $(date +% s) - started_at))
1505+ budget=" $( openclaw_e2e_read_positive_int_env OPENCLAW_UPGRADE_SURVIVOR_VOLUME_IDEMPOTENCE_BUDGET_SECONDS 60) "
1506+ echo " SQLite volume idempotence doctor completed in ${idempotence_seconds} s (budget ${budget} s)."
1507+ if [ " $idempotence_seconds " -gt " $budget " ]; then
1508+ echo " SQLite volume idempotence exceeded budget: ${idempotence_seconds} s > ${budget} s" >&2
1509+ return 1
1510+ fi
1511+ node scripts/e2e/lib/upgrade-survivor/assertions.mjs assert-state
14571512}
14581513
14591514validate_post_doctor_config () {
@@ -1601,6 +1656,9 @@ phase install-baseline-plugin-dependencies install_baseline_plugin_dependencies
16011656phase seed-legacy-plugin-dependency-debris seed_legacy_plugin_dependency_debris
16021657phase assert-legacy-plugin-dependency-debris assert_legacy_plugin_dependency_debris_present
16031658phase seed-source-only-plugin-shadow seed_source_only_plugin_shadow
1659+ if [ " $SCENARIO " = " sqlite-volume" ]; then
1660+ phase seed-volume-state node scripts/e2e/lib/upgrade-survivor/assertions.mjs seed-volume
1661+ fi
16041662phase assert-baseline assert_baseline_state
16051663phase seed-legacy-runtime-deps-symlink seed_legacy_runtime_deps_symlink
16061664phase resolve-candidate resolve_candidate_version
@@ -1611,7 +1669,7 @@ phase update-candidate update_candidate
16111669if [ -n " ${OPENCLAW_CLAWHUB_URL:- } " ]; then
16121670 clawhub_security_mode=" required"
16131671 prepublish_package=" @openclaw/whatsapp"
1614- if [ " $SCENARIO " = " configured-plugin-installs " ] ; then
1672+ if configured_plugin_installs_enabled ; then
16151673 prepublish_package=" @openclaw/matrix"
16161674 fi
16171675 # 2026.6.35 predates the release-security endpoint. The trusted fixture still
@@ -1630,11 +1688,15 @@ phase assert-legacy-plugin-dependency-debris-cleaned assert_legacy_plugin_depend
16301688phase assert-legacy-runtime-deps-symlink-repaired assert_legacy_runtime_deps_symlink_repaired
16311689phase validate-post-doctor-config validate_post_doctor_config
16321690phase assert-survival assert_survival
1691+ if [ " $SCENARIO " = " sqlite-volume" ]; then
1692+ phase assert-volume-idempotence assert_volume_idempotence
1693+ fi
16331694phase gateway-start ensure_gateway_started
16341695phase gateway-probes check_gateway_probes
16351696phase gateway-status check_gateway_status
16361697if [ " $LIVE_OPENAI " = " 1" ]; then
16371698 phase live-openai run_live_openai
16381699fi
16391700
1640- echo " Upgrade survivor Docker E2E passed baseline=${baseline_spec} scenario=${SCENARIO} candidate=${candidate_version} updateRestartMode=${UPDATE_RESTART_MODE} startup=${start_seconds} s updateRestart=${update_restart_seconds:- manual} s healthz=${healthz_seconds} s readyz=${readyz_seconds} s status=${status_seconds} s."
1701+ run_completed=" 1"
1702+ echo " Upgrade survivor Docker E2E passed baseline=${baseline_spec} scenario=${SCENARIO} candidate=${candidate_version} updateRestartMode=${UPDATE_RESTART_MODE} migration=${migration_seconds:- n/ a} s idempotence=${idempotence_seconds:- n/ a} s startup=${start_seconds} s updateRestart=${update_restart_seconds:- manual} s healthz=${healthz_seconds} s readyz=${readyz_seconds} s status=${status_seconds} s."
0 commit comments