test_script-load_checkpoint_2.sh #2

  • //
  • p4-sdp/
  • dev_rebrand/
  • test/
  • bsw/
  • test_script-load_checkpoint_2.sh
  • View
  • Commits
  • Open Download .zip Download (4 KB)
#!/bin/bash
set -u

# Version ID Block. Relies on +k filetype modifier.
#------------------------------------------------------------------------------
# shellcheck disable=SC2016
declare VersionID='$Id: //p4-sdp/dev_rebrand/test/bsw/test_script-load_checkpoint_2.sh#2 $ $Change: 31752 $'
declare VersionStream=${VersionID#*//}; VersionStream=${VersionStream#*/}; VersionStream=${VersionStream%%/*};
declare VersionCL=${VersionID##*: }; VersionCL=${VersionCL%% *}
declare Version=${VersionStream}.${VersionCL}
[[ "$VersionStream" == r* ]] || Version="${Version^^}"

declare ThisScript="${0##*/}"
declare -i ErrorCount=0
declare -i Debug=${SDP_DEBUG:-0}
declare -i LocalLogCount=0
declare -a LocalLogList
declare -i RemoteLogCount=0
declare -a RemoteLogList
declare -a RemoteLogHost
declare StandbyHost=bos-helix-02
declare EdgeHost=syd-helix-04
declare RemoteHost=
declare RemoteLog=

function msg () { echo -e "$*"; }
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 version $Version]: Load latest serial checkpoint."

# Setup: Create site config dir if needed
mkdir -p /p4/common/site/config
ssh "$EdgeHost" mkdir -p /p4/common/site/config

msg "\\nConfigure for serial checkpoint ops on commit and edge."

{
   echo export DO_PARALLEL_CHECKPOINTS=0
   echo KEEPCKPS=2
   echo KEEPJNLS=2
   echo KEEPCKPS=2
} > /p4/common/site/config/p4_1.vars.local

msg "Pushing checkpoint config to edge."
rsync /p4/common/site/config/p4_1.vars.local "$EdgeHost:/p4/common/site/config/p4_1.vars.local" ||\
   errmsg "Failed to copy /p4/common/site/config/p4_1.vars.local to $EdgeHost."

msg "Do a live checkpoint on the commit."
live_checkpoint.sh 1
LocalLogList[LocalLogCount]="/p4/1/logs/checkpoint.log"
LocalLogCount+=1

msg "Pushing /p4/1/checkpoints to standby."
rsync -a /p4/1/checkpoints/ "$StandbyHost":/p4/1/checkpoints ||\
   errmsg "Test setup error pushing checkpoints to standby $StandbyHost."

msg "\\nLoad latest serial checkpoint on standby."

msg "Running: ssh $StandbyHost load_checkpoint.sh -latest -R -b -y -L /p4/1/logs/load.log"
ssh "$StandbyHost" "load_checkpoint.sh -latest -R -b -y -L /p4/1/logs/load.log"
RemoteLogHost[RemoteLogCount]="$StandbyHost"
RemoteLogList[RemoteLogCount]="/p4/1/logs/load.log"
RemoteLogCount+=1

msg "\\nTake serial checkpoint on edge."

msg "Running: ssh $EdgeHost request_replica_checkpoint.sh 1 -now"
ssh "$EdgeHost" "request_replica_checkpoint.sh 1 -now"
RemoteLogHost[RemoteLogCount]="$EdgeHost"
RemoteLogList[RemoteLogCount]="/p4/1/logs/request_checkpoint.log"
RemoteLogCount+=1

# Give the checkpoint time to complete. 3 secs should be enough ...
### TO DO: Come up with a more reliable way to give it time to complete
### (but also not hang if it doesn't complete for some reason).
sleep 3

msg "Running: ssh $EdgeHost load_checkpoint.sh -latest -R -b -y -L /p4/1/logs/load.log"
ssh "$EdgeHost" "load_checkpoint.sh -latest -R -b -y -L /p4/1/logs/load.log"
RemoteLogHost[RemoteLogCount]="$EdgeHost"
RemoteLogList[RemoteLogCount]="/p4/1/logs/load.log"
RemotLogCount+=1

msg "Checking for syntax and unbound errors in scripts used in this test."
for log in "${LocalLogList[@]}"; do
   msg "Checking for 'unbound variable' in: $log"
   grep ':unbound variable' "$log" && \
      errmsg "Found 'unbound variable' error in $log"
   msg "Checking for 'syntax error' in: $log"
   grep ':syntax error' "$log" && \
      errmsg "Found 'syntax error' in $log"
done

msg "Checking for syntax and unbound errors in scripts used in this test on remote hosts."
for ((i=0; i < RemoteLogCount; i++)); do
   RemoteHost="${RemoteLogHost[i]}"
   RemoteLog="${RemoteLogList[i]}"
   msg "Checking for 'unbound variable' in: $RemoteHost:$RemoteLog"
   ssh -q "$RemoteHost" "grep ':unbound variable' $RemoteLog" && \
      errmsg "Found 'unbound variable' error in $RemoteLog"
   msg "Checking for 'syntax error' in: $RemoteHost:$RemoteLog"
   ssh -q "$RemoteHost" "grep ':syntax error' $RemoteLog" && \
      errmsg "Found 'syntax error' in $RemoteLog"
done

exit "$ErrorCount"
# Change User Description Committed
#2 31752 C. Thomas Tyler In dev_rebrand, bringing in changes from dev_c2s ala:

p4 merge --from dev_c2s
p4 resolve -am

No interactive resolve was needed.
#1 31751 C. Thomas Tyler p4 stream convertsparse
//p4-sdp/dev/test/bsw/test_script-load_checkpoint_2.sh
#1 31397 C. Thomas Tyler Populate -b SDP_Classic_to_Streams -s //guest/perforce_software/sdp/...@31368.
//guest/perforce_software/sdp/dev/test/bsw/test_script-load_checkpoint_2.sh
#2 30680 C. Thomas Tyler For LoadCheckpiont test group, improve test efficiency improvement by
removing (rather than just moving) databases as checkpoints are loaded.
#1 30677 C. Thomas Tyler Added 13 tests for load_checkpoint.sh.
Added 'TestGroup' field to scripted_testse.cfg.