#!/bin/bash set -u # $Id: //guest/tom_tyler/sw/main/test_sdp_ugprade/dev/bin/test_sdp_upgrade.sh#8 $ # This script test the 2024.2 version of the sdp_upgrade.sh script with the # legacy and new package structures. If the new structure is used, # /opt/perforce/helix-sdp will exist. Otherwise it will not. # Upgrades with the old structure are done as the perforce OS user. # Upgrades in the new package structure are done as the root user. # ONE TIME PER MACHINE SETUP # # Setup a Linux machine to be the test server. The box can be any supported OS, # e.g. Ubuntu 24, Ubuntu 22, Rocky 9, etc. # # STEP 1: Install SDP # # Install SDP with either the legacy method using reset_sdp.sh (aka the Helix # Installer) or the new install_sdp.sh script. The new script uses the package # structure. # # STEP 2: Get Support Scripts # # First, deploy this test_sdp_upgrade.sh script and dependencies on the new # machine. # # To setup to use this test_sdp_upgrade.sh script, do commands like these # samples as root, changing tom_tyler for your own P4USER for the Public # Depot server, public.perforce.com:1666: # # User=tom_tyler # mkdir -p /root/dev/bin # cd /root/dev/bin # p4 -u $User -p public.perforce.com:1666 login # p4 -u $User clone -p public.perforce.com:1666 -f //guest/tom_tyler/sw/main/test_sdp_ugprade/dev/bin/... # # STEP 3: Get SDP from Dev Branch # # This step produces a directory from which a tarball of the SDP dev branch can # be created. This allows us to simulate the standard install procedure without # having a released tarball that would normaly be curl'd from The Workshop. # Continuing as root: # # rm -rf /root/dev/sdp_dev /root/dev/sdp # mkdir /root/dev/sdp_dev # cd /root/dev/sdp_dev # p4 -u $User clone -p public.perforce.com:1666 -r perforce_software-sdp_dev # echo 'Rev. SDP/MultiArch/2024.2/99999 (2024/12/09).' > Version # ROUTINE USAGE # # With SDP ready to use with SDP 2024.1 Patch 1 (or any version since 2020.1) installed, # folllow this procedure. # cd /root/dev/bin # source ./env.sh # ./test_sdp_upgrade.sh 2>&1 | tee tlog # # And then review the results. declare -i ErrorCount=0 function msg () { echo -e "$*"; } function errmsg () { msg "\\nError: ${1:-Unkonwon Error}\\n"; ErrorCount+=1; } function bail () { errmsg "${1:-Unkonwon Error}"; exit "$ErrorCount"; } if [[ -d /opt/perforce/helix-sdp ]]; then cd /opt/perforce/helix-sdp || bail "Could not do: cd /opt/perforce/helix-sdp" [[ -d backup ]] || mkdir backup || bail "Could not do: mkdir backup (from $PWD)" [[ -e downloads/sdp.Unix.tgz ]] && mv downloads/sdp.Unix.tgz "backup/sdp.Unix.old.$(date +%Y%m%d-%H%M%S)" ### curl -L -O https://swarm.workshop.perforce.com/download/guest/perforce_software/sdp/downloads/sdp.Unix.tgz ### ls -l sdp.Unix.tgz cd /root/dev/sdp_dev || bail "Could not do: cd /root/dev/sdp_dev" export P4CONFIG=.p4config.local Cmd="p4 fetch" msg "Running: $Cmd" $Cmd || bail "Could not do: $Cmd" cd /root/dev || bail "Could not do: cd /root/dev" rm -rf sdp Cmd="rsync -a --exclude=.p4config.local --exclude=.p4root sdp_dev/ sdp" msg "Running: $Cmd" $Cmd || bail "Could not do: $Cmd" Cmd="tar -czf /opt/perforce/helix-sdp/downloads/sdp.Unix.tgz sdp" msg "Running: $Cmd" if $Cmd; then msg "SDP dev branch tarball created OK." else bail "Could not do: $Cmd (in $PWD)" fi cd /opt/perforce/helix-sdp || bail "Could not do: cd /opt/perforce/helix-sdp" tar -xzf /opt/perforce/helix-sdp/downloads/sdp.Unix.tgz chown -R root:root /opt/perforce/helix-sdp/sdp cd /opt/perforce/helix-sdp/sdp/Server/Unix/p4/common/sdp_upgrade ||\ bail "Could not do: cd /opt/perforce/helix-sdp/sdp/Server/Unix/p4/common/sdp_upgrade" msg "Usage check from $PWD:" ./sdp_upgrade.sh -h msg "\\nKicking off sdp_upgrade.sh in new structure as root in $PWD." if ./sdp_upgrade.sh; then msg "\\nPASS: SDP Upgrade Test (DRY RUN) is OK." else bail "\\nFAIL: SDP Upgrade Test (DRY RUN) was not entirely successful." fi sleep 1 if ./sdp_upgrade.sh -y; then msg "\\nPASS: SDP Upgrade Test (LIVE) is OK." else bail "\\nFAIL: SDP Upgrade Test (LIVE) was not entirely successful." fi else cd /hxdepots || bail "Could not do: cd /hxdepots" [[ -d downloads ]] || mkdir downloads cd downloads || bail "Could not do: cd downloads (from $PWD)." [[ -d new ]] && mv new "old.$(date +%Y%m%d-%H%M%S)" [[ -e sdp.Unix.tgz ]] && mv sdp.Unix.tgz "sdp.Unix.old.$(date +%Y%m%d-%H%M%S)" ### curl -L -O https://swarm.workshop.perforce.com/download/guest/perforce_software/sdp/downloads/sdp.Unix.tgz ### ls -l sdp.Unix.tgz cd /root/dev/sdp_dev || bail "Could not do: cd /root/dev/sdp_dev" export P4CONFIG=.p4config.local Cmd="p4 fetch" msg "Running: $Cmd" $Cmd || bail "Could not do: $Cmd" cd /root/dev || bail "Could not do: cd /root/dev" rm -rf sdp Cmd="rsync -a --exclude=.p4config.local --exclude=.p4root sdp_dev/ sdp" msg "Running: $Cmd" $Cmd || bail "Could not do: $Cmd" rm -f /hxdepots/downloads/sdp.Unix.tgz Cmd="tar -czf /hxdepots/downloads/sdp.Unix.tgz sdp" msg "Running: $Cmd" if $Cmd; then msg "SDP dev branch tarball created OK." else bail "Could not do: $Cmd (in $PWD)" fi cd /hxdepots/downloads || bail "Could not do: cd /hxdepots/downloads" mkdir new cd new || bail "Could not do: cd new (from $PWD)" Cmd="tar -xzf ../sdp.Unix.tgz" if $Cmd; then msg "SDP Tarball extracted OK." else bail "Could not do: $Cmd" fi Cmd="chown -R perforce: /hxdepots" $Cmd || bail "Could not do: $Cmd" cd /hxdepots/downloads/new/sdp/Server/Unix/p4/common/sdp_upgrade ||\ bail "Could not do: cd /hxdepots/downloads/new/sdp/Server/Unix/p4/common/sdp_upgrade" msg "Usage check from $PWD:" su perforce -c './sdp_upgrade.sh -h' msg "\\nKicking off sdp_upgrade.sh in legacy structure as perforce in $PWD." if su perforce -c './sdp_upgrade.sh'; then msg "\\nPASS: SDP Upgrade Test (DRY RUN) is OK." else errmsg "\\nFAIL: SDP Upgrade Test (DRY RUN) was not entirely successful." bail "Aborting due to SDP Upgrade Test (DRY RUN) failure." fi sleep 1 if su perforce -c './sdp_upgrade.sh -y'; then msg "\\nPASS: SDP Upgrade Test (LIVE) is OK." else errmsg "\\nFAIL: SDP Upgrade Test (LIVE) was not entirely successful." fi fi
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 31052 | C. Thomas Tyler | Extended test to do the real thing if the dry run was good. | ||
#7 | 31008 | C. Thomas Tyler | Accounted for running as root in new structure. | ||
#6 | 31007 | C. Thomas Tyler | Tweaked. | ||
#5 | 31004 | C. Thomas Tyler | Tweaked. | ||
#4 | 31003 | C. Thomas Tyler | Fixed bug, added ktext tag. | ||
#3 | 30999 | C. Thomas Tyler | Enhanced internal code doc. | ||
#2 | 30997 | C. Thomas Tyler |
Enhanced to test with legacy or new package structure. Added internal comments with usage notes. |
||
#1 | 30995 | C. Thomas Tyler |
Added environment file and test script. This test scripts tests the upgrades in the legacy structure. |