diff --git a/images/linux/scripts/installers/mono.sh b/images/linux/scripts/installers/mono.sh index bdce62484..f4481c1c8 100644 --- a/images/linux/scripts/installers/mono.sh +++ b/images/linux/scripts/installers/mono.sh @@ -4,6 +4,8 @@ ## Desc: Installs Mono ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + LSB_CODENAME=$(lsb_release -cs) # Test to see if the software in question is already installed, if not install it @@ -14,13 +16,4 @@ echo "deb https://download.mono-project.com/repo/ubuntu stable-$LSB_CODENAME mai apt-get update apt-get install -y --no-install-recommends apt-transport-https mono-complete nuget -# 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 mono; then - echo "mono was not installed" - exit 1 -fi -if ! command -v nuget; then - echo "nuget was not installed" - exit 1 -fi +invoke_tests "Tools" "Mono" diff --git a/images/linux/scripts/installers/mssql-cmd-tools.sh b/images/linux/scripts/installers/mssql-cmd-tools.sh index 3177dd38b..9461121b7 100644 --- a/images/linux/scripts/installers/mssql-cmd-tools.sh +++ b/images/linux/scripts/installers/mssql-cmd-tools.sh @@ -4,6 +4,8 @@ ## Desc: Install MS SQL Server client tools (https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017) ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + export ACCEPT_EULA=Y apt-get update @@ -11,8 +13,4 @@ apt-get install -y mssql-tools unixodbc-dev apt-get -f install ln -s /opt/mssql-tools/bin/* /usr/local/bin/ -echo "Testing to make sure that script performed as expected, and basic scenarios work" -if ! command -v sqlcmd; then - echo "sqlcmd was not installed" - exit 1 -fi \ No newline at end of file +invoke_tests "Tools" "MSSQLCommandLineTools" \ No newline at end of file diff --git a/images/linux/scripts/installers/mysql.sh b/images/linux/scripts/installers/mysql.sh index 778294777..95483107e 100644 --- a/images/linux/scripts/installers/mysql.sh +++ b/images/linux/scripts/installers/mysql.sh @@ -4,6 +4,8 @@ ## Desc: Installs MySQL Client ################################################################################ +source $HELPER_SCRIPTS/os.sh + export ACCEPT_EULA=Y if isUbuntu16 || isUbuntu18 ; then diff --git a/images/linux/scripts/installers/pipx-packages.sh b/images/linux/scripts/installers/pipx-packages.sh index 3b625fe41..a7442b890 100644 --- a/images/linux/scripts/installers/pipx-packages.sh +++ b/images/linux/scripts/installers/pipx-packages.sh @@ -4,6 +4,7 @@ ## Desc: Install tools via pipx ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh export PATH="$PATH:/opt/pipx_bin" @@ -21,10 +22,6 @@ for package in $pipx_packages; do pipx install $package fi - # Run tests to determine that the software installed as expected - cmd=$(jq -r ".pipx[] | select(.package == \"$package\") .cmd" $toolset) - if ! command -v $cmd; then - echo "$package was not installed" - exit 1 - fi done + +invoke_tests "Common" "PipxPackages" \ No newline at end of file diff --git a/images/linux/scripts/installers/r.sh b/images/linux/scripts/installers/r.sh index 86ad96bd6..3015090ce 100644 --- a/images/linux/scripts/installers/r.sh +++ b/images/linux/scripts/installers/r.sh @@ -2,6 +2,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/invoke-tests.sh # install R osLabel=$(getOSVersionLabel) @@ -11,4 +12,5 @@ sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $osLab sudo apt update sudo apt install r-base -version=$(R --version | grep "R version" | cut -d " " -f 3) + +invoke_tests "Tools" "R" \ No newline at end of file diff --git a/images/linux/scripts/installers/sbt.sh b/images/linux/scripts/installers/sbt.sh index a43115083..9f45f28f6 100644 --- a/images/linux/scripts/installers/sbt.sh +++ b/images/linux/scripts/installers/sbt.sh @@ -4,9 +4,13 @@ ## Desc: Installs sbt ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Install sbt # https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add apt-get -q update apt-get -y install sbt + +invoke_tests "Tools" "Sbt" \ No newline at end of file diff --git a/images/linux/scripts/installers/selenium.sh b/images/linux/scripts/installers/selenium.sh index d662fa009..43c07ebe6 100644 --- a/images/linux/scripts/installers/selenium.sh +++ b/images/linux/scripts/installers/selenium.sh @@ -4,6 +4,8 @@ ## Desc: Installs selenium server ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Determine latest selenium standalone server version SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2) @@ -14,12 +16,8 @@ echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..." SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar" wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME -echo "Testing to make sure that script performed as expected, and basic scenarios work" -if [ ! -f "$SELENIUM_JAR_NAME" ]; then - echo "Selenium server was not installed" - exit 1 -fi - SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar" mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment + +invoke_tests "Tools" "Selenium" \ No newline at end of file diff --git a/images/linux/scripts/installers/sphinx.sh b/images/linux/scripts/installers/sphinx.sh index 2ef22f46d..cfaeb0afa 100644 --- a/images/linux/scripts/installers/sphinx.sh +++ b/images/linux/scripts/installers/sphinx.sh @@ -4,5 +4,9 @@ ## Desc: Installs Sphinx ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Install Sphinx apt-get install -y sphinxsearch + +invoke_tests "Tools" "Sphinx" \ No newline at end of file diff --git a/images/linux/scripts/installers/subversion.sh b/images/linux/scripts/installers/subversion.sh index 77b2d0276..efc2551d7 100644 --- a/images/linux/scripts/installers/subversion.sh +++ b/images/linux/scripts/installers/subversion.sh @@ -4,12 +4,9 @@ ## Desc: Installs Subversion client ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Install Subversion apt-get install -y --no-install-recommends subversion -# 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 svn; then - echo "Subversion (svn) was not installed" - exit 1 -fi +invoke_tests "Tools" "SVN" diff --git a/images/linux/scripts/installers/swift.sh b/images/linux/scripts/installers/swift.sh index e4666a7c8..7b6dcceaa 100644 --- a/images/linux/scripts/installers/swift.sh +++ b/images/linux/scripts/installers/swift.sh @@ -4,6 +4,8 @@ ## Desc: Installs Swift ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Install image_label="$(lsb_release -rs)" swift_version=$(curl -s -L -N https://swift.org/download|awk -F"[ <]" '/id="swift-/ {print $4; exit}') @@ -20,14 +22,4 @@ ln -s "$SWIFT_BIN" /usr/local/bin/swift ln -s "$SWIFTC_BIN" /usr/local/bin/swiftc echo "SWIFT_PATH=$SWIFT_PATH" | 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 swift; then - echo "Swift was not installed" - exit 1 -fi - -if ! command -v swiftc; then - echo "Swiftc is not linked to swift binary" - exit 1 -fi +invoke_tests "Common" "Swift" \ No newline at end of file diff --git a/images/linux/scripts/installers/swig.sh b/images/linux/scripts/installers/swig.sh index b2e5a202e..30c0a5c0f 100644 --- a/images/linux/scripts/installers/swig.sh +++ b/images/linux/scripts/installers/swig.sh @@ -1,11 +1,8 @@ #!/bin/bash -e +source $HELPER_SCRIPTS/invoke-tests.sh + # Install Swig sudo apt-get install -y swig -# 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 swig; then - echo "Swig was not installed" - exit 1 -fi +invoke_tests "Tools" "Swig" diff --git a/images/linux/scripts/installers/terraform.sh b/images/linux/scripts/installers/terraform.sh index 90c25c65a..6361a5dd3 100644 --- a/images/linux/scripts/installers/terraform.sh +++ b/images/linux/scripts/installers/terraform.sh @@ -4,15 +4,12 @@ ## Desc: Installs terraform ################################################################################ +source $HELPER_SCRIPTS/invoke-tests.sh + # Install Terraform TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r .current_version) curl -LO "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -d /usr/local/bin rm -f "terraform_${TERRAFORM_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 terraform; then - echo "Terraform was not installed or found on PATH" - exit 1 -fi +invoke_tests "Tools" "Terraform" \ No newline at end of file diff --git a/images/linux/scripts/installers/vcpkg.sh b/images/linux/scripts/installers/vcpkg.sh index e2d9688ce..e41b8cb9b 100644 --- a/images/linux/scripts/installers/vcpkg.sh +++ b/images/linux/scripts/installers/vcpkg.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/invoke-tests.sh # Set env variable for vcpkg VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg @@ -29,9 +30,4 @@ if isUbuntu16; then ln -sf g++-5 /usr/bin/g++ 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 ! command -v vcpkg; then - echo "vcpkg was not installed" - exit 1 -fi +invoke_tests "Tools" "Vcpkg" \ No newline at end of file diff --git a/images/linux/scripts/tests/Common.Tests.ps1 b/images/linux/scripts/tests/Common.Tests.ps1 index c56edc23b..b65a18c38 100644 --- a/images/linux/scripts/tests/Common.Tests.ps1 +++ b/images/linux/scripts/tests/Common.Tests.ps1 @@ -27,4 +27,22 @@ Describe "PHP" { It "Pecl" { "pecl" | Should -ReturnZeroExitCode } -} \ No newline at end of file +} + +Describe "Swift" { + It "swift" { + "swift --version" | Should -ReturnZeroExitCode + } + + It "swiftc" { + "swiftc --version" | Should -ReturnZeroExitCode + } +} + +Describe "PipxPackages" -Skip:(Test-IsUbuntu16) { + [array]$testCases = (Get-ToolsetContent).pipx | ForEach-Object { @{cmd = $_.cmd} } + + It "" -TestCases $testCases { + "$cmd --version" | Should -ReturnZeroExitCode + } +} diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 2c0e8830c..e29d8458e 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -163,6 +163,70 @@ Describe "gfortran" { } } +Describe "Mono" { + It "mono" { + "mono --version" | Should -ReturnZeroExitCode + } + + It "nuget" { + "nuget" | Should -ReturnZeroExitCode + } +} + +Describe "MSSQLCommandLineTools" { + It "sqlcmd" { + "sqlcmd -?" | Should -ReturnZeroExitCode + } +} + +Describe "R" { + It "r" { + "R --version" | Should -ReturnZeroExitCode + } +} + +Describe "Sbt" { + It "sbt" { + "sbt --version" | Should -ReturnZeroExitCode + } +} + +Describe "Sphinx" { + It "sphinx" { + "searchd -h" | Should -ReturnZeroExitCode + } +} + +Describe "Selenium" { + It "Selenium Server 'selenium-server-standalone.jar' is installed" { + "/usr/share/java/selenium-server-standalone.jar" | Should -Exist + } +} + +Describe "SVN" { + It "svn" { + "svn --version" | Should -ReturnZeroExitCode + } +} + +Describe "Swig" { + It "swig" { + "swig -version" | Should -ReturnZeroExitCode + } +} + +Describe "Terraform" { + It "terraform" { + "terraform --version" | Should -ReturnZeroExitCode + } +} + +Describe "Vcpkg" { + It "vcpkg" { + "vcpkg version" | Should -ReturnZeroExitCode + } +} + Describe "Git" { It "git" { "git --version" | Should -ReturnZeroExitCode diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index b2fe43607..a1d0ebbdd 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -264,6 +264,7 @@ "{{template_dir}}/scripts/installers/pipx-packages.sh" ], "environment_vars": [ + "HELPER_SCRIPTS={{user `helper_script_folder`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index f9b00f8e7..84957d4e7 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -264,6 +264,7 @@ "{{template_dir}}/scripts/installers/pipx-packages.sh" ], "environment_vars": [ + "HELPER_SCRIPTS={{user `helper_script_folder`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"