diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 496fe3c2f..eaa2131e8 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -167,12 +167,6 @@ "type": "windows-restart", "restart_timeout": "30m" }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Docker.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -483,12 +477,6 @@ "{{ template_dir }}/scripts/Installers/Install-AWS.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-AWS-SAM.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -656,70 +644,12 @@ "type": "windows-restart", "restart_timeout": "30m" }, - { - "type": "powershell", - "environment_vars":[ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", - "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureModules.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AWS-SAM.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureDevOpsCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Svn.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-DACFx.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-DotnetSDK.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -738,12 +668,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Stack.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -781,6 +705,7 @@ ], "environment_vars":[ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", + "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}", "ROOT_FOLDER={{user `root_folder`}}" ] }, diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 53e06aca6..fc42df2ab 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -175,12 +175,6 @@ "type": "windows-restart", "restart_timeout": "10m" }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Docker.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -458,12 +452,6 @@ "{{ template_dir }}/scripts/Installers/Install-AWS.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-AWS-SAM.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -655,58 +643,12 @@ "type": "windows-restart", "restart_timeout": "10m" }, - { - "type": "powershell", - "environment_vars":[ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", - "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureModules.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AWS-SAM.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureDevOpsCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Svn.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-DACFx.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-DotnetSDK.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -725,12 +667,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Stack.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -749,18 +685,6 @@ "{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -780,6 +704,7 @@ ], "environment_vars":[ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}", + "PSMODULES_ROOT_FOLDER={{user `psmodules_root_folder`}}", "ROOT_FOLDER={{user `root_folder`}}" ] }, diff --git a/images/win/scripts/Installers/Install-AWS-SAM.ps1 b/images/win/scripts/Installers/Install-AWS-SAM.ps1 deleted file mode 100644 index 43469901a..000000000 --- a/images/win/scripts/Installers/Install-AWS-SAM.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -################################################################################ -## File: Install-AWS-SAM.ps1 -## Desc: Install aws sam cli -## https://aws.amazon.com/serverless/sam/ -################################################################################ - -Install-Binary -Url "https://github.com/awslabs/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi" -Name "AWS_SAM_CLI_64_PY3.msi" diff --git a/images/win/scripts/Installers/Install-AWS.ps1 b/images/win/scripts/Installers/Install-AWS.ps1 index 59feea232..d15d90d53 100644 --- a/images/win/scripts/Installers/Install-AWS.ps1 +++ b/images/win/scripts/Installers/Install-AWS.ps1 @@ -1,28 +1,18 @@ ################################################################################ -## File: Install-awscli.ps1 -## Desc: Install awscli +## File: Install-AWS.ps1 +## Desc: Install AWS tools(AWS CLI, Session Manager Plugin for the AWS CLI, AWS SAM CLI) ################################################################################ +# Install AWS CLI Choco-Install -PackageName awscli -$env:Path = $env:Path + ";$env:ProgramFiles\Amazon\AWSCLIV2" -if (Get-Command -Name 'aws') -{ - Write-Host 'awscli on path' -} -else -{ - Write-Host 'awscli is not on path' - exit 1 -} - +# Install Session Manager Plugin for the AWS CLI $sessionManagerName = "SessionManagerPluginSetup.exe" $sessionManagerUrl = "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/$sessionManagerName" Install-Binary -Url $sessionManagerUrl -Name $sessionManagerName -ArgumentList ("/silent", "/install") $env:Path = $env:Path + ";$env:ProgramFiles\Amazon\SessionManagerPlugin\bin" -$sessionMessage = session-manager-plugin -Write-Host "$sessionMessage" -if ($sessionMessage -notmatch "*plugin was installed successfully*") { - exit 1 -} \ No newline at end of file +# Install AWS SAM CLI +Install-Binary -Url "https://github.com/awslabs/aws-sam-cli/releases/latest/download/AWS_SAM_CLI_64_PY3.msi" -Name "AWS_SAM_CLI_64_PY3.msi" + +Invoke-PesterTests -TestFile "Tools" -TestName "AWS" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AliyunCli.ps1 b/images/win/scripts/Installers/Install-AliyunCli.ps1 index b46eb8a60..37650046c 100644 --- a/images/win/scripts/Installers/Install-AliyunCli.ps1 +++ b/images/win/scripts/Installers/Install-AliyunCli.ps1 @@ -3,4 +3,6 @@ ## Desc: Install Alibaba Cloud CLI ################################################################################ -Choco-Install -PackageName aliyun-cli \ No newline at end of file +Choco-Install -PackageName aliyun-cli + +Invoke-PesterTests -TestFile "Tools" -TestName "AliyunCli" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AzCopy.ps1 b/images/win/scripts/Installers/Install-AzCopy.ps1 index 035edee25..7e2e5c141 100644 --- a/images/win/scripts/Installers/Install-AzCopy.ps1 +++ b/images/win/scripts/Installers/Install-AzCopy.ps1 @@ -3,4 +3,6 @@ ## Desc: Install AzCopy10 ################################################################################ -Choco-Install -PackageName azcopy10 \ No newline at end of file +Choco-Install -PackageName azcopy10 + +Invoke-PesterTests -TestFile "Tools" -TestName "AzCopy" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AzureCli.ps1 b/images/win/scripts/Installers/Install-AzureCli.ps1 index 790fc6a51..ea823a1dc 100644 --- a/images/win/scripts/Installers/Install-AzureCli.ps1 +++ b/images/win/scripts/Installers/Install-AzureCli.ps1 @@ -10,3 +10,4 @@ New-Item -ItemType "directory" -Path $AzureCliExtensionPath [Environment]::SetEnvironmentVariable("AZURE_EXTENSION_DIR", $AzureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine) +Invoke-PesterTests -TestFile "Tools" -TestName "AzureCli" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 b/images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 index b16149328..52c99f267 100644 --- a/images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 +++ b/images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 @@ -8,4 +8,6 @@ Import-Module -Name ImageHelpers -Force $InstallerName = "AzureCosmosDBEmulator.msi" $InstallerUrl = "https://aka.ms/cosmosdb-emulator" -Install-Binary -Url $InstallerUrl -Name $InstallerName \ No newline at end of file +Install-Binary -Url $InstallerUrl -Name $InstallerName + +Invoke-PesterTests -TestFile "Tools" -TestName "Azure Cosmos DB Emulator" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 b/images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 index 5054e9a5d..d9757ecc4 100644 --- a/images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 +++ b/images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 @@ -4,3 +4,5 @@ ################################################################################ az extension add -n azure-devops + +Invoke-PesterTests -TestFile "Tools" -TestName "Azure DevOps CLI" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-AzureModules.ps1 b/images/win/scripts/Installers/Install-AzureModules.ps1 index fa33710fa..8d3a4fe56 100644 --- a/images/win/scripts/Installers/Install-AzureModules.ps1 +++ b/images/win/scripts/Installers/Install-AzureModules.ps1 @@ -52,4 +52,6 @@ foreach ($module in $modules) # Add modules to the PSModulePath $psModuleMachinePath += $env:PSModulePath -[Environment]::SetEnvironmentVariable("PSModulePath", $psModuleMachinePath, "Machine") \ No newline at end of file +[Environment]::SetEnvironmentVariable("PSModulePath", $psModuleMachinePath, "Machine") + +Invoke-PesterTests -TestFile "PowerShellModules" -TestName "AzureModules" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Bazel.ps1 b/images/win/scripts/Installers/Install-Bazel.ps1 index fabbecd01..7d5479fdf 100644 --- a/images/win/scripts/Installers/Install-Bazel.ps1 +++ b/images/win/scripts/Installers/Install-Bazel.ps1 @@ -5,4 +5,6 @@ Choco-Install -PackageName bazel -npm install -g @bazel/bazelisk \ No newline at end of file +npm install -g @bazel/bazelisk + +Invoke-PesterTests -TestFile "Tools" -TestName "Bazel" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-DACFx.ps1 b/images/win/scripts/Installers/Install-DACFx.ps1 index 7a470cbf5..92db0e4ef 100644 --- a/images/win/scripts/Installers/Install-DACFx.ps1 +++ b/images/win/scripts/Installers/Install-DACFx.ps1 @@ -8,4 +8,6 @@ Import-Module -Name ImageHelpers -Force $InstallerName = "DacFramework.msi" $InstallerUrl = "https://go.microsoft.com/fwlink/?linkid=2128142" -Install-Binary -Url $InstallerUrl -Name $InstallerName \ No newline at end of file +Install-Binary -Url $InstallerUrl -Name $InstallerName + +Invoke-PesterTests -TestFile "Tools" -TestName "DACFx" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Docker.ps1 b/images/win/scripts/Installers/Install-Docker.ps1 index 35e988ada..00e665172 100644 --- a/images/win/scripts/Installers/Install-Docker.ps1 +++ b/images/win/scripts/Installers/Install-Docker.ps1 @@ -17,4 +17,6 @@ Write-Host "Install-Package Docker-Compose" Choco-Install -PackageName docker-compose Write-Host "Install Helm" -Choco-Install -PackageName kubernetes-helm \ No newline at end of file +Choco-Install -PackageName kubernetes-helm + +Invoke-PesterTests -TestFile "Tools" -TestName "Docker" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-DotnetSDK.ps1 b/images/win/scripts/Installers/Install-DotnetSDK.ps1 index 394a73412..7a4207e5b 100644 --- a/images/win/scripts/Installers/Install-DotnetSDK.ps1 +++ b/images/win/scripts/Installers/Install-DotnetSDK.ps1 @@ -113,3 +113,5 @@ function RunPostInstallationSteps() InstallAllValidSdks RunPostInstallationSteps + +Invoke-PesterTests -TestFile "DotnetSDK" \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-AWS-SAM.ps1 b/images/win/scripts/Installers/Validate-AWS-SAM.ps1 deleted file mode 100644 index ac18ab5d9..000000000 --- a/images/win/scripts/Installers/Validate-AWS-SAM.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-AWS-SAM.ps1 -## Desc: Validate aws sam cli -################################################################################ - -if (Get-Command -Name 'sam') -{ - Write-Host 'AWS SAM CLI on path' -} -else -{ - Write-Host 'AWS SAM CLI is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-AliyunCli.ps1 b/images/win/scripts/Installers/Validate-AliyunCli.ps1 deleted file mode 100644 index cb3cad4d5..000000000 --- a/images/win/scripts/Installers/Validate-AliyunCli.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-AliyunCli.ps1 -## Desc: Validate Alibaba Cloud CLI -################################################################################ - -if (Get-Command -Name 'aliyun') -{ - Write-Host 'Alibaba Cloud CLI on path' -} -else -{ - Write-Host 'Alibaba Cloud CLI is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-AzCopy.ps1 b/images/win/scripts/Installers/Validate-AzCopy.ps1 deleted file mode 100644 index dd090297a..000000000 --- a/images/win/scripts/Installers/Validate-AzCopy.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -################################################################################ -## File: Validate-AzCopy.ps1 -## Desc: Validate AzCopy10 -################################################################################ -if (Get-Command -Name 'azcopy') { - Write-Host "$(azcopy --version) on path" -} else { - Write-Error "azcopy not on path" - exit 1 -} \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1 b/images/win/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1 deleted file mode 100644 index b2d8d4a34..000000000 --- a/images/win/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -################################################################################ -## File: Validate-AzureCosmosDbEmulator.ps1 -## Desc: Validate Azure CosmosDb Emulator installation. -################################################################################ - -$SoftwareName = 'Azure CosmosDb Emulator' -$regKey = gci HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | gp | ? { $_.DisplayName -eq 'Azure Cosmos DB Emulator' } - -if ($regKey -eq $null) -{ - Write-Host "The $regKey registry key is not set" - exit 1 -} -else -{ - Write-Host "The $regKey registry key is set" -} - -$installDir = $regKey.InstallLocation -if ($installDir -eq $null) -{ - Write-Host "The $SoftwareName installation directory registry value is not set" - exit 1 -} -else -{ - Write-Host "The $SoftwareName installation directory registry value is set to: $installDir" -} - -$exeFilePath = Join-Path $installDir 'CosmosDB.Emulator.exe' -if (!(Test-Path $exeFilePath)) -{ - Write-Host "$SoftwareName is not installed" - exit 1 -} - -$fileVersion = (Get-Item $exeFilePath).VersionInfo.FileVersion -Write-Host "$SoftwareName is successfully installed: $fileVersion" diff --git a/images/win/scripts/Installers/Validate-AzureDevOpsCli.ps1 b/images/win/scripts/Installers/Validate-AzureDevOpsCli.ps1 deleted file mode 100644 index 17a934919..000000000 --- a/images/win/scripts/Installers/Validate-AzureDevOpsCli.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -################################################################################ -## File: Validate-AzureDevOpsCli.ps1 -## Desc: Validate Azure DevOps CLI -################################################################################ - -az devops -h - -if ($LastExitCode -ne 0) -{ - Write-Error "Azure DevOps Cli extension not present" - exit 1 -} -else -{ - Write-Host "Azure DevOps Cli extension is present" -} - diff --git a/images/win/scripts/Installers/Validate-AzureModules.ps1 b/images/win/scripts/Installers/Validate-AzureModules.ps1 deleted file mode 100644 index 39f1a2ea4..000000000 --- a/images/win/scripts/Installers/Validate-AzureModules.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -################################################################################ -## File: Validate-AzureModules.ps1 -## Desc: Validate Azure PowerShell modules -################################################################################ - -$ErrorActionPreference = "Stop" - -$modulesRootPath = $env:PSMODULES_ROOT_FOLDER - -# Get modules content from toolset -$modules = (Get-ToolsetContent).azureModules - -foreach ($module in $modules) -{ - foreach ($version in $module.versions) - { - $moduleName = $module.name - $modulePath = Join-Path -Path $modulesRootPath -ChildPath "$($module.name)_${version}" - - Write-Host "Trying to import ${moduleName}_${version}..." - $testJob = Start-Job -ScriptBlock { - param ( - $modulePath, - $moduleName - ) - - $env:PsModulePath = "$modulePath;$env:PsModulePath" - Import-Module -Name $moduleName - Get-Module -Name $moduleName - - } -ArgumentList $modulePath, $moduleName - - $isError = $testJob | Wait-Job | Foreach-Object ChildJobs | Where-Object { $_.Error } - if ($isError) - { - Write-Host "Required ${moduleName} module ${version} version is not present" - - exit 1 - } - - $testJob | Receive-Job | Select-Object Name,Version,Path - Remove-Job $testJob - } -} \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-Bazel.ps1 b/images/win/scripts/Installers/Validate-Bazel.ps1 deleted file mode 100644 index 20d3d7685..000000000 --- a/images/win/scripts/Installers/Validate-Bazel.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -################################################################################ -## File: Validate-Bazel.ps1 -## Desc: Validate Bazel and Bazelisk (A user-friendly launcher for Bazel) -################################################################################ - -if (Get-Command -Name 'bazel') -{ - Write-Host 'bazel on path' -} -else -{ - Write-Host 'bazel is not on path' - exit 1 -} - -if (Get-Command -Name 'bazelisk') -{ - Write-Host 'bazelisk on path' -} -else -{ - Write-Host 'bazelisk is not on path' - exit 1 -} - - diff --git a/images/win/scripts/Installers/Validate-DACFx.ps1 b/images/win/scripts/Installers/Validate-DACFx.ps1 deleted file mode 100644 index 3dd18a1cf..000000000 --- a/images/win/scripts/Installers/Validate-DACFx.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -#################################################################################### -## File: Validate-DACFx.ps1 -## Desc: Validate SQL ServerĀ® Data-Tier Application Framework (DACFx) for Windows -#################################################################################### - -$env:PATH = $env:Path + ';C:\Program Files\Microsoft SQL Server\120\DAC\bin;C:\Program Files\Microsoft SQL Server\130\DAC\bin;C:\Program Files\Microsoft SQL Server\140\DAC\bin;C:\Program Files\Microsoft SQL Server\150\DAC\bin' - -if (Get-Command -Name 'SqlPackage') -{ - Write-Host "DACFx is installed at path" (Get-Command -Name 'SqlPackage').Source -} -else -{ - throw "DACFx is not installed!" -} - -if (Get-Command -Name 'SqlLocalDB') -{ - Write-Host "SQL Server Express LocalDB is available at " (Get-Command -Name SqlLocalDB).Source -} -else -{ - throw "SqlLocalDB is not installed!" -} diff --git a/images/win/scripts/Installers/Validate-Docker.ps1 b/images/win/scripts/Installers/Validate-Docker.ps1 deleted file mode 100644 index e2b7571fa..000000000 --- a/images/win/scripts/Installers/Validate-Docker.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -################################################################################ -## File: Validate-Docker.ps1 -## Desc: Validate Docker. -################################################################################ - -if ((Get-Command -Name 'docker') -and (Get-Command -Name 'docker-compose')) -{ - Write-Host "docker $(docker version) on path" - Write-Host "docker-compose $(docker-compose version) on path" -} -else -{ - Write-Host "docker or docker-compose are not on path" - exit 1 -} - -# Validate helm -if (Get-Command -Name 'helm') -{ - Write-Host "helm on path" -} -else -{ - Write-Host 'helm is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-DotnetSDK.ps1 b/images/win/scripts/Installers/Validate-DotnetSDK.ps1 deleted file mode 100644 index 6d7c104aa..000000000 --- a/images/win/scripts/Installers/Validate-DotnetSDK.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -################################################################################ -## File: Validate-DotnetSDK.ps1 -## Desc: Validate dotnet -################################################################################ - -if (Get-Command -Name 'dotnet') -{ - Write-Host "dotnet $(dotnet --version) on path" -} -else -{ - Write-Host "dotnet is not on path" - exit 1 -} - - diff --git a/images/win/scripts/Tests/DotnetSDK.Tests.ps1 b/images/win/scripts/Tests/DotnetSDK.Tests.ps1 new file mode 100644 index 000000000..1598b337c --- /dev/null +++ b/images/win/scripts/Tests/DotnetSDK.Tests.ps1 @@ -0,0 +1,26 @@ +$releaseIndexUrl = "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json" +$dotnetChannels = (New-Object system.net.webclient).DownloadString($releaseIndexUrl) | ConvertFrom-Json +$dotnetVersions = $dotnetChannels.'releases-index' | Where-Object { (!$_."support-phase".Equals('preview') -and !$_."support-phase".Equals('eol')) } | Select-Object -ExpandProperty "channel-version" + +Describe "Dotnet SDK" { + + Context "Default" { + It "Default Dotnet SDK is available" { + "dotnet --version" | Should -ReturnZeroExitCode + } + } + + foreach ($version in $dotnetVersions) { + Context "Dotnet $version" { + $dotnet = @{ dotnetVersion = $version } + + It "SDK $version is available" -TestCases $dotnet { + (dotnet --list-sdks | Where-Object { $_ -match "${dotnetVersion}\.[0-9]*" }).Count | Should -BeGreaterThan 0 + } + + It "Runtime $version is available" -TestCases $dotnet { + (dotnet --list-runtimes | Where-Object { $_ -match "${dotnetVersion}\.[0-9]*" }).Count | Should -BeGreaterThan 0 + } + } + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/PowerShellModules.Tests.ps1 b/images/win/scripts/Tests/PowerShellModules.Tests.ps1 new file mode 100644 index 000000000..bd1113301 --- /dev/null +++ b/images/win/scripts/Tests/PowerShellModules.Tests.ps1 @@ -0,0 +1,44 @@ +Describe "AzureModules" { + $modules = (Get-ToolsetContent).azureModules + $modulesRootPath = $env:PSMODULES_ROOT_FOLDER + + foreach ($module in $modules) { + $moduleName = $module.name + + Context "$moduleName" { + + foreach ($version in $module.versions) { + $modulePath = Join-Path -Path $modulesRootPath -ChildPath "${moduleName}_${version}" + $moduleInfo = @{ moduleName = $moduleName; modulePath = $modulePath; expectedVersion = $version } + It " exists in modules directory" -TestCases $moduleInfo { + $testJob = Start-Job -ScriptBlock { + param ( + $modulePath, + $moduleName + ) + + # Disable warning messages to prevent additional warnings about Az and Azurerm modules in the same session + $WarningPreference = "SilentlyContinue" + + $env:PsModulePath = "$modulePath;$env:PsModulePath" + Import-Module -Name $moduleName + (Get-Module -Name $moduleName).Version.ToString() + + } -ArgumentList $modulePath, $moduleName + + $moduleVersion = $testJob | Wait-Job | Receive-Job + Remove-Job $testJob + $moduleVersion | Should -Match $expectedVersion + } + } + + if ($module.default) { + $moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default } + It " set as default" -TestCases $moduleInfo { + $moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString() + $moduleVersion | Should -Match $moduleDefault + } + } + } + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 index fda74d4bb..87595450d 100644 --- a/images/win/scripts/Tests/Tools.Tests.ps1 +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -6,12 +6,96 @@ Describe "7-Zip" { } } +Describe "AliyunCli" { + It "AliyunCli" { + "aliyun version" | Should -ReturnZeroExitCode + } +} + +Describe "AWS" { + It "AWS CLI" { + "aws --version" | Should -ReturnZeroExitCode + } + + It "Session Manager Plugin for the AWS CLI" { + session-manager-plugin | Out-String | Should -Match "plugin was installed successfully" + } + + It "AWS SAM CLI" { + "sam --version" | Should -ReturnZeroExitCode + } +} + +Describe "AzCopy" { + It "AzCopy" { + "azcopy --version" | Should -ReturnZeroExitCode + } +} + +Describe "Azure Cosmos DB Emulator" { + $cosmosDbEmulatorRegKey = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -eq 'Azure Cosmos DB Emulator' } + $installDir = $cosmosDbEmulatorRegKey.InstallLocation + + It "Azure Cosmos DB Emulator install location registry key exists" -TestCases @{installDir = $installDir} { + $installDir | Should -Not -BeNullOrEmpty + } + + It "Azure Cosmos DB Emulator exe file exists" -TestCases @{installDir = $installDir} { + $exeFilePath = Join-Path $installDir 'CosmosDB.Emulator.exe' + $exeFilePath | Should -Exist + } +} + +Describe "AzureCli" { + It "AzureCli" { + "az --version" | Should -ReturnZeroExitCode + } +} + +Describe "Azure DevOps CLI" { + It "az devops" { + "az devops -h" | Should -ReturnZeroExitCode + } +} + +Describe "Bazel" { + It "" -TestCases @( + @{ ToolName = "bazel" } + @{ ToolName = "bazelisk" } + ) { + "$ToolName --version"| Should -ReturnZeroExitCode + } +} + Describe "CMake" { It "cmake" { "cmake --version" | Should -ReturnZeroExitCode } } +Describe "DACFx" { + It "DACFx" { + (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -Contains "Microsoft SQL Server Data-Tier Application Framework (x64)" | Should -BeTrue + $sqlPackagePath = 'C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe' + $sqlLocalDBPath = 'C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe' + "${sqlPackagePath}" | Should -Exist + "${sqlLocalDBPath}" | Should -Exist + } + } + +Describe "Docker" { + It "" -TestCases @( + @{ ToolName = "docker" } + @{ ToolName = "docker-compose" } + ) { + "$ToolName --version"| Should -ReturnZeroExitCode + } + + It "Helm" { + "helm version --short" | Should -ReturnZeroExitCode + } +} + Describe "Kind" { It "Kind" { "kind version" | Should -ReturnZeroExitCode