#!/bin/bash #------------------------------------------------------------------------------ set -u # Usage: # bootstrap-linux.sh [<FQDN>] [<SDPBranch>] # The <SDPBranch> parameter is optional. SDPBranch determines # the branch of the SDP to test with, 'main' by default but can # be 'dev'. # Bootstraps a new Linux server with requirements Helix Installer testing. function msg () { echo -e "$*"; } function errmsg () { msg "\\nBootstrap Error: ${1:-Unknown Error}\\n"; ErrorCount+=1; } function bail () { msg "\\nError: ${1:-Unknown Error}\\n"; exit "${2:-1}"; } declare ThisScript="${0##*/}" declare Version=1.6.1 declare SDPBranch="${2:-main}" declare HelixInstallerArgs= declare FQDN="${1:-Unset}" declare -i ErrorCount=0 msg "Starting $ThisScript v$Version as $USER@${HOSTNAME%%.*} at $(date) as:\\n$ThisScript $*" # Currently, RHEL/CentOS and Ubuntu flavors are supported. # See release notes for more specific details of which versions are # currently supported. if [[ -r "/etc/redhat-release" ]]; then msg "Verified: Running Red Hat or similar Linux OS." elif [[ -r "/etc/lsb-release" ]]; then msg "Verified: Running Ubuntu or similar Linux OS." else msg "Warning: Running on unknown OS. Hoping for the best." fi [[ -d /hxdepots/reset ]] && \ bail "Directory /hxdepots/reset unexpectedly exists at bootstrap!" if [[ -d /hxdepots ]]; then msg "Using existing /hxdepots volume provisioned at bootstrap." else msg "Initializing /hxdepots dir." if ! sudo mkdir /hxdepots; then errmsg "MKDIR of /hxepots failed." fi fi [[ -d /depotdata/reset ]] && \ bail "Directory /depotdata/reset unexpectedly exists at bootstrap!" if [[ -d /depotdata ]]; then msg "Using existing /depotdata volume provisioned at bootstrap." else msg "Initializing /depotdata dir." if ! sudo mkdir /depotdata; then errmsg "MKDIR of /depotdata failed." fi fi # Some tests use the default /hxdepots mount point directory, while # others test the ability to configure an alternative, /depotdata. # In this bootstrap script, we ensure both are available. if [[ -d /tmp/test-reset ]]; then msg "Testing files from local workspace." if sudo cp -pr /tmp/test-reset /hxdepots/reset; then msg "Copied /tmp/test-reset to /hxdepots/reset" else errmsg "Failed to copy /tmp/test-reset to /hxdepots/reset" fi if sudo cp -pr /tmp/test-reset /depotdata/reset; then msg "Copied /tmp/test-reset to /depotdata/reset" else errmsg "Failed to copy /tmp/test-reset to /depotdata/reset" fi cd /hxdepots/reset || errmsg "Failed to do 'cd /hxdepots/reset'. Aborting." cd /depotdata/reset || errmsg "Failed to do 'cd /depotdata/reset'. Aborting." else bail "Expected test support dir /tmp/test-reset does not exist. Check the Vagrantfile for the setting 'machine.vm.synced_folder'." fi if [[ "$FQDN" != "Unset" ]]; then if [[ -n "$(command -v hostnamectl)" ]]; then msg "Setting hostname using: hostnamectl set-hostname $FQDN" hostnamectl set-hostname "$FQDN" else msg "Setting hostname in /etc/sysconfig/network and calling: hostname $FQDN" echo -e "NETWORKING=yes\\nHOSTNAME=$FQDN\\n" > /etc/sysconfig/network hostname "$FQDN" fi fi HelixInstallerVersion=$(grep '^declare Version=' reset_sdp.sh) HelixInstallerVersion=${HelixInstallerVersion#declare } msg "Helix Installer version: $HelixInstallerVersion" HelixInstallerCmd="./reset_sdp.sh" HelixInstallerArgs="-fast -b $SDPBranch -M" #HelixInstallerArgs="-b $SDPBranch -M" msg "Calling Helix Installer: $HelixInstallerCmd $HelixInstallerArgs" #shellcheck disable=SC2086,SC2024 if ! sudo $HelixInstallerCmd $HelixInstallerArgs > log.reset_sdp.txt 2>&1; then errmsg "Sudo command failed: $HelixInstallerCmd $HelixInstallerArgs" fi exit "$ErrorCount"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#25 | 27288 | C. Thomas Tyler | Removed old Vagrant Test suite. | ||
#24 | 26965 | C. Thomas Tyler | Fixed typo in Redhat-like OS detection. | ||
#23 | 26922 | C. Thomas Tyler |
Narrowed workworkaround for CentOS 8 SELinux enforcing mode issue. The first iteration of this workaround disabled SELinux on all platforms. This disables SELinux on CentOS 8 only. This can be undone done when fixes for SDP-562 and/or HI-54 are released. |
||
#22 | 26829 | C. Thomas Tyler | Disabled SELinux to fix test failure on CentOS 8. | ||
#21 | 26799 | C. Thomas Tyler |
Added '-M' multi-run option to disable the 'run once' safety feature, to simplify multiple tests. |
||
#20 | 26795 | C. Thomas Tyler |
Fixed test suite issues: * Shell environment for test suite regression fixed. * Vagrantfile referred to SDP rather than Helix Installer (old Copy/Paste issue, harmless but wrong). * Updated baseline Vagrant image for CentOS6 box. * Fixed issue with setting hostname on CentOS6 by making hostname a paramter to the bootstrap script, and adjusting the bootstrap script. Along with this change, added missing hostmanager plugin on test machine. |
||
#19 | 26784 | C. Thomas Tyler |
reset_sdp.sh v3.17.0: Made /hx* mount points configurable in settings.cfg, and updated documentation accordingly. Added support for configuring /hxmetadata1 and /hxmetadata2 with different values. Added test coverage for changing /hxdepots from the default. Enhanced test suite. TEST FAIL NOTE: As of this change, tests are succeeding on all platforms except CentOS 6. Failures are in the test suite infrastructure, not related to this change. |
||
#18 | 26575 | C. Thomas Tyler | Switched back to SDP main branch. | ||
#17 | 26567 | C. Thomas Tyler | Changed default test branch from main to dev. | ||
#16 | 26023 | C. Thomas Tyler |
Removed obsolete HelixInstallerBranch refs due to new usage of machine.vm.synced_folder setting in Vagrantfile. |
||
#15 | 26005 | C. Thomas Tyler | Back to -fast. | ||
#14 | 25994 | C. Thomas Tyler | Change back to skipping '-fast'. | ||
#13 | 25990 | C. Thomas Tyler |
Refined test mechanism so local workspace dirs aren't modified by test operations. Changed logfile name to make it easier to find with prefix rather than suffix. |
||
#12 | 25987 | C. Thomas Tyler |
Enhanced test suite to mount the local dir with checked out files into the test VMs, rather than using 'curl' from a URL which can only get submitted revisions of reset_sdp.sh. |
||
#11 | 25882 | C. Thomas Tyler | Configured for a comprehensive test; removed '-fast'. | ||
#10 | 25820 | C. Thomas Tyler |
Enhanced bootstrap test to call Heilx Installer with '-i' to enable testing of scenarios involving newly added files. |
||
#9 | 25754 | C. Thomas Tyler |
Helix Installer test suite changes: Added new test outcome 'SKIP' to supplement 'PASS'/'FAIL'. Added logic to not bother running P4Perl/P4Python tests if '-fast' is specified in the bootstrap script, as in that case we don't expect those to have been installed. Changed bootstrap method back to '-fast' for now. |
||
#8 | 25727 | C. Thomas Tyler |
Removed '-fast' flag to Helix Installer reset_sdp.sh script for comprehensive (but slower) testing. |
||
#7 | 25675 | C. Thomas Tyler | Default changed from fast to comprehensive test. | ||
#6 | 25674 | C. Thomas Tyler | Code optional bypass of Perl/Python compiles to make it faster. | ||
#5 | 25670 | C. Thomas Tyler |
Gave each box its own IP. Added Ubuntu 16.10 and Ubuntu 18.10 to boxes to test. Adjusted bootstrap script to support Ubuntu 16.10 and 18.10. |
||
#4 | 25163 | C. Thomas Tyler | Corrected comment. | ||
#3 | 24879 | C. Thomas Tyler |
Made compliant with shellcheck. Added version id and message to display it. Addded 'sudo' for 'perforce' user. |
||
#2 | 24870 | C. Thomas Tyler |
Various test environment tweaks: * Adjusted host name to bos-helix-01 to be a simplified variant of the Battle School Lab. * Changed defalt SDP branch to pull to auto-detected, using SDP 'dev' branch if in the Helix Installer dev branch, and SDP 'main' branch if in the Helix Installer main branch. * Added host aliases in /etc/hosts. * Added niceties in ~perforce/.bashrc file. |
||
#1 | 24860 | C. Thomas Tyler |
Added basic Vagrant test suite for Helix Installer for testing on CentOS 6.10. |