#!/bin/bash
#------------------------------------------------------------------------------
# This wrapper to test_cbd.sh defines recommended flags for use with Vagrant
# VM testing, and in general handles the vagaries of operatring in a
# Vagrant VM environment.
set -u
function bail () { echo -e "\nError: ${1:-Unknown Error}\n"; exit ${2:-1}; }
export CBD_HOME=/p4/common/bin/cbd
declare SharedCBD=/shared/cbd
declare RunUser=perforce
declare RunGroup=perforce
declare RunHost=helix-01
declare SudoUser=vagrant
declare TestSuiteCmd=
declare CopyOfThisScript
if [[ `id -u` = 0 || "`id -u -n`" == $SudoUser ]]; then
CopyOfThisScript=/tmp/${0##*/}
sudo cp -p $0 $CopyOfThisScript
sudo chmod 740 $CopyOfThisScript
sudo chown $RunUser:$RunGroup $CopyOfThisScript
exec sudo su -l $RunUser -c "$CopyOfThisScript $*"
elif [[ "`id -u -n`" != $RunUser ]]; then
echo "$0 can only be run by root, $RunUser, or $SudoUser on host $RunHost."
exit 1
fi
if [[ ${HOSTNAME%%.*} != $RunHost ]]; then
echo "$0 can only be run by root, $RunUser, or $SudoUser on host $RunHost."
fi
echo "Running as user $USER on host ${HOSTNAME%%.*}."
echo "Updating CBD scripts from $SharedCBD."
for dir in test scripts triggers; do
if [[ ! -d $CBD_HOME/$dir ]]; then
mkdirCmd="mkdir -p $CBD_HOME/$dir"
echo "Running: $mkdirCmd"
$mkdirCmd
fi
rsyncCmd="rsync -a --delete $SharedCBD/$dir/ $CBD_HOME/$dir"
echo "Running: $rsyncCmd"
$rsyncCmd ||:
diffCmd="diff -qr $SharedCBD/$dir $CBD_HOME/$dir"
echo "Running: $diffCmd"
$diffCmd || bail "CBD files were not verified. Aborting."
done
echo "Verified: CBD files updated OK from $SharedCBD."
TestSuiteCmd="$CBD_HOME/test/test_cbd.sh -I -S"
echo -e "Running the Test Suite, executing:\n$TestSuiteCmd"
$TestSuiteCmd || bail "Test Suite Failed."
echo -e "SUCCESS: Test Suite Completed OK."
exit 0
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #17 | 21805 | C. Thomas Tyler | Routine merge down to dev from main. | ||
| #16 | 19264 | C. Thomas Tyler |
Tweaked CBD test suite to pull from specified branch; removing hard-coding to main branch. |
||
| #15 | 19253 | C. Thomas Tyler | Routine merge-down from main to dev. | ||
| #14 | 15359 | C. Thomas Tyler |
Routine Merge Down of cbd to dev from main using: p4 merge -b perforce_software-cbd-dev |
||
| #13 | 15320 | C. Thomas Tyler |
Routine Merge Down to dev from main using: p4 merge -b p4 -s merge -n -b perforce_software-cbd-dev. |
||
| #12 | 15274 | C. Thomas Tyler |
Merge Down of cbd to dev from main using: p4 merge -b perforce_software-cbd-dev |
||
| #11 | 15039 | C. Thomas Tyler |
Merge Down CBD to dev from main to pick up test suite improvements and an exception bug fix in Cbd.py. |
||
| #10 | 15006 | C. Thomas Tyler | Reversed rsync args. | ||
| #9 | 15004 | C. Thomas Tyler | Tweaked. | ||
| #8 | 15003 | C. Thomas Tyler | Sudo indirection correction. | ||
| #7 | 15002 | C. Thomas Tyler | Tweaked restart script. | ||
| #6 | 15001 | C. Thomas Tyler | Resolved a chicken-and-egg problem. | ||
| #5 | 14998 | C. Thomas Tyler | Added some sudo calls. | ||
| #4 | 14991 | C. Thomas Tyler | General VM envrionment testing improvements. | ||
| #3 | 14959 | C. Thomas Tyler |
Implemented '-S' and configured to work existing SDP, as set up by the Helix SDP Installer. Work in progress. |
||
| #2 | 14937 | C. Thomas Tyler |
Incorporated symlink trick used in manual test environment for use with Vagrant test environment. |
||
| #1 | 14928 | C. Thomas Tyler | Tweakes to Vagrant test flow. |