[Windows] Add more docker tests and move K8s tools into single provisioner (#2583)

* Add more docker tests

* Rework tools installation and test

* remove docker tests from tools

* get back kind installation

* transform kind download link to string

* add Add-MachinePathItem after kind installation
This commit is contained in:
Mikhail Timofeev
2021-01-29 11:38:57 +03:00
committed by GitHub
parent 0fa90a6df5
commit 2ee29eddc1
9 changed files with 64 additions and 81 deletions

View File

@@ -12,7 +12,4 @@ Start-Service docker
Write-Host "Install-Package Docker-Compose"
Choco-Install -PackageName docker-compose
Write-Host "Install Helm"
Choco-Install -PackageName kubernetes-helm
Invoke-PesterTests -TestFile "Tools" -TestName "Docker"
Invoke-PesterTests -TestFile "Docker" -TestName "Docker"

View File

@@ -1,42 +0,0 @@
################################################################################
## File: Install-Kind.ps1
## Desc: Install Kind
################################################################################
function Get-LatestRelease
{
$url = 'https://api.github.com/repos/kubernetes-sigs/kind/releases/latest'
(Invoke-RestMethod -Uri $url).assets.browser_download_url -match "kind-windows-amd64"
}
try
{
Write-Host "Starting Install kind.exe..."
$destFilePath = "C:\ProgramData\kind"
$null = New-Item -Path $destFilePath -ItemType Directory -Force
$kindUrl = Get-LatestRelease
$kindInstallerPath = Start-DownloadWithRetry -Url $kindUrl -Name "kind.exe" -DownloadPath $destFilePath
$process = Start-Process -FilePath $kindInstallerPath -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host 'Installation successful'
Add-MachinePathItem $destFilePath
}
else
{
Write-Host "Non zero exit code returned by the installation process : $exitCode."
exit $exitCode
}
}
catch
{
Write-Host "Failed to install the Executable kind.exe"
Write-Host $_.Exception.Message
exit 1
}
Invoke-PesterTests -TestFile "Tools" -TestName "Kind"

View File

@@ -1,9 +0,0 @@
################################################################################
## File: Install-KubernetesCli.ps1
## Desc: Install KubernetesCli
################################################################################
Choco-Install -PackageName kubernetes-cli
Choco-Install -PackageName minikube
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesCli"

View File

@@ -0,0 +1,24 @@
################################################################################
## File: Install-KubernetesTools.ps1
## Desc: Install tools for K8s.
################################################################################
Write-Host "Install Kind"
# Choco installation can't be used because it depends on docker-desktop
$url = 'https://api.github.com/repos/kubernetes-sigs/kind/releases/latest'
[System.String] $kindDownloadLink = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "kind-windows-amd64"
$destFilePath = "C:\ProgramData\kind"
$null = New-Item -Path $destFilePath -ItemType Directory -Force
Start-DownloadWithRetry -Url $kindDownloadLink -Name "kind.exe" -DownloadPath $destFilePath
Add-MachinePathItem $destFilePath
Write-Host "Install Kubectl"
Choco-Install -PackageName kubernetes-cli
Write-Host "Install Helm"
Choco-Install -PackageName kubernetes-helm
Write-Host "Install Minikube"
Choco-Install -PackageName minikube
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesTools"

View File

@@ -20,3 +20,5 @@ $dockerToolset = (Get-ToolsetContent).docker
foreach($dockerImage in $dockerToolset.images) {
DockerPull $dockerImage
}
Invoke-PesterTests -TestFile "Docker" -TestName "DockerImages"

View File

@@ -0,0 +1,22 @@
Describe "Docker" {
It "<ToolName>" -TestCases @(
@{ ToolName = "docker" }
@{ ToolName = "docker-compose" }
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
It "docker service is up" {
"docker images" | Should -ReturnZeroExitCode
}
}
Describe "DockerImages" {
Context "docker images" {
$testCases = (Get-ToolsetContent).docker.images | ForEach-Object { @{ ImageName = $_ } }
It "<ImageName>" -TestCases $testCases {
docker images "$ImageName" --format "{{.Repository}}" | Should -Not -BeNullOrEmpty
}
}
}

View File

@@ -64,25 +64,6 @@ Describe "DACFx" {
"${sqlPackagePath}" | Should -Exist
"${sqlLocalDBPath}" | Should -Exist
}
}
Describe "Docker" {
It "<ToolName>" -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
}
}
Describe "DotnetTLS" {
@@ -113,11 +94,19 @@ Describe "Mercurial" {
}
}
Describe "KubernetesCli" {
Describe "KubernetesTools" {
It "Kind" {
"kind version" | Should -ReturnZeroExitCode
}
It "kubectl" {
"kubectl version --client=true --short=true" | Should -ReturnZeroExitCode
}
It "Helm" {
"helm version --short" | Should -ReturnZeroExitCode
}
It "minikube" {
"minikube version --short" | Should -ReturnZeroExitCode
}

View File

@@ -139,7 +139,8 @@
"type": "powershell",
"environment_vars": [
"IMAGE_VERSION={{user `image_version`}}",
"IMAGEDATA_FILE={{user `imagedata_file`}}"
"IMAGEDATA_FILE={{user `imagedata_file`}}",
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
],
"scripts": [
"{{ template_dir }}/scripts/Installers/Update-ImageData.ps1",
@@ -162,6 +163,7 @@
],
"scripts": [
"{{ template_dir }}/scripts/Installers/Update-DockerImages.ps1",
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1",
"{{ template_dir }}/scripts/Installers/Windows2016/Install-SSDT.ps1"
@@ -313,8 +315,6 @@
"{{ template_dir }}/scripts/Installers/Install-NSIS.ps1",
"{{ template_dir }}/scripts/Installers/Install-CloudFoundryCli.ps1",
"{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1",
"{{ template_dir }}/scripts/Installers/Install-KubernetesCli.ps1",
"{{ template_dir }}/scripts/Installers/Install-Kind.ps1",
"{{ template_dir }}/scripts/Installers/Install-MongoDB.ps1",
"{{ template_dir }}/scripts/Installers/Install-GoogleCloudSDK.ps1",
"{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1"

View File

@@ -147,7 +147,8 @@
"type": "powershell",
"environment_vars": [
"IMAGE_VERSION={{user `image_version`}}",
"IMAGEDATA_FILE={{user `imagedata_file`}}"
"IMAGEDATA_FILE={{user `imagedata_file`}}",
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
],
"scripts": [
"{{ template_dir }}/scripts/Installers/Update-ImageData.ps1",
@@ -170,6 +171,7 @@
],
"scripts": [
"{{ template_dir }}/scripts/Installers/Update-DockerImages.ps1",
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1"
],
@@ -297,8 +299,6 @@
"{{ template_dir }}/scripts/Installers/Install-CloudFoundryCli.ps1",
"{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1",
"{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1",
"{{ template_dir }}/scripts/Installers/Install-KubernetesCli.ps1",
"{{ template_dir }}/scripts/Installers/Install-Kind.ps1",
"{{ template_dir }}/scripts/Installers/Install-Bazel.ps1",
"{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1",
"{{ template_dir }}/scripts/Installers/Install-RootCA.ps1",