#!/bin/bash
set -u
declare ThisScript="${0##*/}"
declare Version=1.0.2
declare -i ErrorCount=0
declare -i Debug=${SDP_DEBUG:-0}
declare LinkTarget=
declare TmpFile=
declare OfflineDB=
function msg () { echo -e "$*"; }
# shellcheck disable=SC2317
function dbg () { [[ "$Debug" -eq 0 ]] || msg "DEBUG: $*"; }
function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; }
function bail () { errmsg "${1:-Unknown Error}"; exit "$ErrorCount"; }
msg "Start test [$ThisScript v$Version]: Load checkpoint man page."
TmpFile=$(mktemp)
# shellcheck disable=SC1091
source /p4/common/bin/p4_vars 1 ||\
bail "Could not do: source /p4/common/bin/p4_vars 1"
OfflineDB="$P4HOME/offline_db"
if p4 depot --exists -o Perforce > /dev/null 2>&1; then
msg "Remote depot 'Perforce' exists. Removing it with: p4 depot -d Perforce"
p4 depot -d Perforce ||\
bail "Failed to delete depot 'Perforce'. Aborting this test due to unexpected pre-start setup failure."
else
msg "Verified: Remote depot 'Perforce' does not exist."
fi
msg "Test setup: Removing partitioned clients data from offline_db. Running:\\nrm -rf \"$OfflineDB/client.readonly.dir\""
rm -rf "$OfflineDB/client.readonly.dir" ||\
bail "Failed to remove $OfflineDB/client.readonly.dir. Aborting this test due to unexpected pre-start setup failure."
LinkTarget=$(readlink "${P4ROOT}")
if [[ "$LinkTarget" == *db2 ]]; then
msg "Verified: Pre-swap P4ROOT symlink points to db2."
else
bail "Pre-swap P4ROOT does NOT point to db2. Aborting this test due to unexpected pre-start conditions."
fi
LinkTarget=$(readlink "${P4ROOT%/root}/offline_db")
if [[ "$LinkTarget" == *db1 ]]; then
msg "Verified: Pre-swap offline_db symlink points to db1."
else
bail "Pre-swap offline_db symlink does NOT point to db1. Aborting this test due to unexpected pre-start conditions."
fi
msg "Creating partitioned client."
p4 --field Type=partitioned --field Root=/p4/1/tmp/ws/MyPartitionedClient client -o MyPartitionedClient | p4 client -i
msg "Flusing partitioned client, running: p4 -s -c MyPartitionedClient flush -q"
p4 -s -c MyPartitionedClient flush -q || errmsg "Flush failed. Aborting this test due to unexpected pre-start conditions."
msg "Running: refresh_P4ROOT_from_offline_db.sh"
refresh_P4ROOT_from_offline_db.sh ||\
errmsg "refresh_P4ROOT_from_offline_db.sh reported non-zero exit code in test expecting 0 exit code."
LinkTarget=$(readlink "${P4ROOT}")
if [[ "$LinkTarget" == *db1 ]]; then
msg "Verified: Post-swap P4ROOT symlink points to db1."
else
errmsg "Post-swap P4ROOT does NOT point to db1."
fi
LinkTarget=$(readlink "${P4ROOT%/root}/offline_db")
if [[ "$LinkTarget" == *db2 ]]; then
msg "Verified: Post-swap offline_db symlink points to db2."
else
bail "Post-swap offline_db symlink does NOT point to db2."
fi
sleep 1
msg "Ensuring partitioned client data survied the swap intact.\\nRunning: p4 -s -c MyPartitionedClient flush"
p4 -s -c MyPartitionedClient flush > "$TmpFile" 2>&1
cat "$TmpFile"
if grep -q 'up-to-date' "$TmpFile"; then
msg "Verified: Partitioned client 'have' data survived the db swap intact."
else
errmsg "Partitioned client 'have' data did not appear to survive the db swap intact."
fi
exit "$ErrorCount"
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 33444 | Claude (AI Agent by Anthropic) | Initial population of r26.1.0.BETA from main. | ||
| //p4-sdp/main/test/bsw/test_script-refresh_P4ROOT_from_offline_db_2.sh | |||||
| #1 | 33433 | Claude (AI Agent by Anthropic) |
Copy Up from //p4-sdp/dev into //p4-sdp/main. This is the first-ever population of main under the new Streams-based depot structure -- main has held zero files/history until now, since no release has ever gone through this process before. 463 files, covering the entire 2026.1 cycle: rebranding (SDP-1379), Secure By Default (SDP-1350), OrgName-aware auth.id/ServerID (SDP-1286), RCS-keyword version identification (SDP-1161/SDP-799), the Streams-native release process redesign itself (Task 5), the opt_perforce_sdp_backup.sh false-error fix, the P4D 2026.1 test-suite targeting, refreshed P4*.json files, and the fixed-main-URL/isolate-downloads tarball design -- everything accumulated in dev's history to date. Isolated paths (ai_dev_support/, Version, doc/*.html, doc/*.pdf, doc/gen/*.man.txt, doc/gen/sdp_install.cfg, Unsupported/doc/*.html, Unsupported/doc/*.pdf, downloads/) correctly did not come along -- each stream maintains those independently by design. Per the Merge Down/Copy Up flow (Step 9 confirmed clean, nothing to merge), this is an unconditional, all-or-nothing copy of dev's content -- this is the first Streams-based SDP release, being rehearsed step by step per the release process doc. Agent: Claude Code, Model: Claude Sonnet 5 (claude-sonnet-5), operating as bot_Claude_Anthropic. |
||
| //p4-sdp/dev/test/bsw/test_script-refresh_P4ROOT_from_offline_db_2.sh | |||||
| #1 | 31997 | C. Thomas Tyler | p4 merge -b SDP_Classic_to_Streams && p4 resolve -as && p4 submit | ||
| //guest/perforce_software/sdp/dev/test/bsw/test_script-refresh_P4ROOT_from_offline_db_2.sh | |||||
| #2 | 31993 | C. Thomas Tyler | Improved test auditability and reliability. | ||
| #1 | 31992 | C. Thomas Tyler | Added test for db swap with partitioned clients. | ||