[Ubuntu] Migrate tests for common tools to Pester (part 3) (#2337)

* add test for Git

* Add Heroku

* Add hhvm

* Add Homebrew

* Add Julia

* Add kind

* Add Kubernetes Tools

* Remove kind and homebrew validate

* replace capital letter

* Add Leiningen

* add source to Leiningen

* Add Mercurial

* Add conda

* Add Netlify

* Add packer

* Add pollinate

* Add Pulumi

* Add Phantomjs

* Add Haveged

* Fix for kubectl

* Fix julia installation

* Add installer_script_folder env variable to run tests in brew provisioner

* Add delay after reboot

* Adjust pause settings
This commit is contained in:
Mikhail Timofeev
2020-12-25 18:03:35 +03:00
committed by GitHub
parent f30f928378
commit 64c9751269
22 changed files with 227 additions and 238 deletions

View File

@@ -5,7 +5,8 @@
################################################################################
# Source the helpers for use with the script
source "$HELPER_SCRIPTS"/install.sh
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/invoke-tests.sh
## Install git
add-apt-repository ppa:git-core/ppa -y
@@ -20,23 +21,6 @@ apt-get install -y --no-install-recommends git-lfs
# Install git-ftp
apt-get install git-ftp -y
# Run tests to determine that the software installed as expected
echo "Testing git installation"
if ! command -v git; then
echo "git was not installed"
exit 1
fi
echo "Testing git-lfs installation"
if ! command -v git-lfs; then
echo "git-lfs was not installed"
exit 1
fi
echo "Testing git-ftp installation"
if ! command -v git-ftp; then
echo "git-ftp was not installed"
exit 1
fi
#Install hub
tmp_hub="/tmp/hub"
mkdir -p "$tmp_hub"
@@ -45,13 +29,8 @@ download_with_retries "$url" "$tmp_hub"
tar xzvf "$tmp_hub"/hub-linux-amd64-*.tgz --strip-components 1 -C "$tmp_hub"
mv "$tmp_hub"/bin/hub /usr/local/bin
if command -v hub; then
echo "hub CLI was installed successfully"
else
echo "[!] Hub CLI was not installed"
exit 1
fi
# Add well-known SSH host keys to known_hosts
ssh-keyscan -t rsa github.com >> /etc/ssh/ssh_known_hosts
ssh-keyscan -t rsa ssh.dev.azure.com >> /etc/ssh/ssh_known_hosts
invoke_tests "Tools" "Git"

View File

@@ -4,11 +4,9 @@
## Desc: Installs Heroku CLI
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Heroku CLI
curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v heroku; then
exit 1
fi
invoke_tests "Tools" "Heroku"

View File

@@ -4,29 +4,11 @@
## Desc: Installs hhvm
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/invoke-tests.sh
hhvm_package=hhvm
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
add-apt-repository https://dl.hhvm.com/ubuntu
apt-get update
apt-get -qq install -y hhvm
# Test to see if the software in question is already installed, if not install it
echo "Checking to see if the installer script has already been run"
if ! IsPackageInstalled ${hhvm_package}; then
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
add-apt-repository https://dl.hhvm.com/ubuntu
apt-get update
apt-get -qq install -y hhvm
else
echo "${hhvm_package} already installed"
fi
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! IsPackageInstalled ${hhvm_package}; then
echo "${hhvm_package} was not installed"
exit 1
fi
if ! command -v hhvm; then
exit 1
fi
invoke_tests "Tools" "HHVM"

View File

@@ -1,14 +0,0 @@
#!/bin/bash -e
################################################################################
## File: homebrew-validate.sh
## Desc: Validate the Homebrew can run after reboot without extra configuring
################################################################################
# Validate the installation
echo "Validate the Homebrew can run after reboot"
if ! command -v brew; then
echo "brew executable not found after reboot"
exit 1
fi

View File

@@ -7,6 +7,7 @@
# Source the helpers
source $HELPER_SCRIPTS/etc-environment.sh
source $HELPER_SCRIPTS/invoke-tests.sh
# Install the Homebrew on Linux
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
@@ -23,7 +24,4 @@ prependEtcEnvironmentPath "$brew_path"
echo "Validate the installation reloading /etc/environment"
reloadEtcEnvironment
if ! command -v brew; then
echo "brew was not installed"
exit 1
fi
invoke_tests "Tools" "Homebrew"

View File

@@ -4,6 +4,8 @@
## Desc: Installs Julia, and adds Julia to the path
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# This function fetches the latest Julia release from the GitHub API
# Based on https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
function GetLatestJuliaRelease () {
@@ -13,44 +15,15 @@ function GetLatestJuliaRelease () {
sed 's/v//' # remove v prefix
}
juliaVersion="$(GetLatestJuliaRelease)"
juliaMajorAndMinorVersion="$(cut -d. -f1,2 <<< $juliaVersion)"
juliaInstallationPath="/usr/local/julia$juliaVersion"
# This function installs Julia using the specified arguments:
# $1=MajorAndMinorVersion (1.3.1)
# $2=IsDefaultVersion (true or false)
curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/$juliaMajorAndMinorVersion/julia-$juliaVersion-linux-x86_64.tar.gz" -o "julia-$juliaVersion-linux-x86_64.tar.gz"
mkdir -p "$juliaInstallationPath"
tar -C "$juliaInstallationPath" -xzf "julia-$juliaVersion-linux-x86_64.tar.gz" --strip-components=1
rm "julia-$juliaVersion-linux-x86_64.tar.gz"
function InstallJulia () {
# Extract Major and Minor version from full version string
juliaMajorAndMinorVersion="$(cut -d. -f1,2 <<< $1)"
juliaInstallationPath="/usr/local/julia$1"
ln -s "$juliaInstallationPath/bin/julia" /usr/bin/julia
curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/$juliaMajorAndMinorVersion/julia-$1-linux-x86_64.tar.gz" -o "julia-$1-linux-x86_64.tar.gz"
mkdir -p "$juliaInstallationPath"
tar -C "$juliaInstallationPath" -xzf "julia-$1-linux-x86_64.tar.gz" --strip-components=1
rm "julia-$1-linux-x86_64.tar.gz"
# If this version of Julia is to be the default version,
# symlink it into the path
if [ "$2" = true ]; then
ln -s "$juliaInstallationPath/bin/julia" /usr/bin/julia
fi
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
# If this version of Julia is to be the default version,
# check that it has been added to PATH
if [ "$2" = true ]; then
if ! command -v julia; then
echo "Julia was not installed or found on PATH"
exit 1
fi
fi
# Verify output of julia --version
if [ ! "$($juliaInstallationPath/bin/julia --version)" = "julia version $1" ]; then
echo "Julia was not installed correctly"
exit 1
fi
}
InstallJulia "$(GetLatestJuliaRelease)" true
invoke_tests "Tools" "Julia"

View File

@@ -1,17 +0,0 @@
#!/bin/bash -e
################################################################################
## File: kind.sh
## Desc: Installs kind
################################################################################
# Install KIND
URL=$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r '.assets[].browser_download_url | select(contains("kind-linux-amd64"))')
curl -L -o /usr/local/bin/kind $URL
chmod +x /usr/local/bin/kind
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v kind; then
echo "Kind was not installed or found on PATH"
exit 1
fi

View File

@@ -4,6 +4,13 @@
## Desc: Installs kubectl, helm, kustomize
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install KIND
URL=$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r '.assets[].browser_download_url | select(contains("kind-linux-amd64"))')
curl -L -o /usr/local/bin/kind $URL
chmod +x /usr/local/bin/kind
## Install kubectl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
touch /etc/apt/sources.list.d/kubernetes.list
@@ -25,27 +32,4 @@ download_url="https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master
curl -s "$download_url" | bash
mv kustomize /usr/local/bin
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v kubectl; then
echo "kubectl was not installed"
exit 1
fi
if ! command -v helm; then
echo "helm was not installed"
exit 1
fi
# Run tests to determine that the software installed as expected
echo "Testing to make sure that minikube was installed"
if ! command -v minikube; then
echo "minikube was not installed"
exit 1
fi
echo "Testing to make sure that kustomize was installed"
if ! command -v kustomize; then
echo "kustomize was not installed"
exit 1
fi
invoke_tests "Tools" "Kubernetes tools"

View File

@@ -4,6 +4,8 @@
## Desc: Installs Leiningen
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
LEIN_BIN=/usr/local/bin/lein
curl -s https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > $LEIN_BIN
chmod 0755 $LEIN_BIN
@@ -16,11 +18,4 @@ LEIN_JAR=$(find $LEIN_HOME -name "leiningen-*-standalone.jar")
echo "LEIN_JAR=$LEIN_JAR" | tee -a /etc/environment
echo "LEIN_HOME=$LEIN_HOME" | tee -a /etc/environment
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v lein; then
echo "lein was not installed"
exit 1
else
lein new app testapp && rm -rf testapp
fi
invoke_tests "Tools" "Leiningen"

View File

@@ -4,6 +4,8 @@
## Desc: Installs Mercurial
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
@@ -16,8 +18,4 @@ fi
apt-get install -y --no-install-recommends mercurial
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v hg; then
exit 1
fi
invoke_tests "Tools" "Mercurial"

View File

@@ -4,6 +4,8 @@
## Desc: Installs miniconda
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Miniconda
curl -sL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh \
&& chmod +x miniconda.sh \
@@ -14,3 +16,5 @@ CONDA=/usr/share/miniconda
echo "CONDA=$CONDA" | tee -a /etc/environment
ln -s $CONDA/bin/conda /usr/bin/conda
invoke_tests "Tools" "Conda"

View File

@@ -4,12 +4,9 @@
## Desc: Installs the Netlify CLI
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install the Netlify CLI
npm i -g netlify-cli
# Validate the installation
echo "Validate the installation"
if ! command -v netlify; then
echo "Netlify CLI was not installed"
exit 1
fi
invoke_tests "Tools" "Netlify"

View File

@@ -4,15 +4,12 @@
## Desc: Installs packer
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Packer
PACKER_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r .current_version)
curl -LO "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d /usr/local/bin
rm -f "packer_${PACKER_VERSION}_linux_amd64.zip"
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v packer; then
echo "Packer was not installed or found on PATH"
exit 1
fi
invoke_tests "Tools" "Packer"

View File

@@ -4,6 +4,8 @@
## Desc: Installs PhantomJS
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install PhantomJS
apt-get install -y chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
PHANTOM_JS=phantomjs-2.1.1-linux-x86_64
@@ -12,9 +14,4 @@ tar xvjf $PHANTOM_JS.tar.bz2
mv $PHANTOM_JS /usr/local/share
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v phantomjs; then
echo "phantomjs was not installed"
exit 1
fi
invoke_tests "Tools" "Phantomjs"

View File

@@ -4,12 +4,9 @@
## Desc: Installs Pollinate
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Pollinate
apt-get install -y --no-install-recommends pollinate
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v pollinate; then
echo "pollinate was not installed"
exit 1
fi
invoke_tests "Tools" "Pollinate"

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/invoke-tests.sh
# Install Pulumi
VERSION=$(curl --fail --silent -L "https://www.pulumi.com/latest-version")
@@ -13,9 +14,4 @@ TARBALL_URL="https://get.pulumi.com/releases/sdk/pulumi-v${VERSION}-linux-x64.ta
download_with_retries ${TARBALL_URL} "/tmp" pulumi-v${VERSION}.tar.gz
tar --strip=1 -xvf /tmp/pulumi-v${VERSION}.tar.gz -C /usr/local/bin
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v pulumi ; then
echo "Pulumi was not installed"
exit 1
fi
invoke_tests "Tools" "Pulumi"

View File

@@ -4,14 +4,9 @@
## Desc: Install random number generator
################################################################################
source $HELPER_SCRIPTS/invoke-tests.sh
# Install haveged
apt-get -y install haveged
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in haveged; do
if ! command -v $cmd; then
echo "$cmd was not installed or not found on PATH"
exit 1
fi
done
invoke_tests "Tools" "Haveged"