Skip to content

Commit

Permalink
Merge pull request #10145 from sharifelgamal/windows-pr-test
Browse files Browse the repository at this point in the history
ci: add full integration tests for Docker on Windows
  • Loading branch information
sharifelgamal authored Jan 27, 2021
2 parents 597091d + 2a59bff commit c2d8249
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 9 deletions.
2 changes: 1 addition & 1 deletion hack/jenkins/minikube_set_pending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs=(
'Docker_Linux'
'Docker_Linux_containerd'
# 'Docker_macOS'
# 'Docker_Windows'
'Docker_Windows'
# 'Podman_Linux'
)

Expand Down
33 changes: 33 additions & 0 deletions hack/jenkins/setup_docker_desktop_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


$attempt = 10
while($attempt -ne 0) {
Write-Host "Attempt ", $attempt
Write-Host "Wait for 3 minutes"
& "C:\Program Files\Docker\Docker\Docker Desktop.exe"
Start-Sleep 180
$dockerInfo = docker info
Write-Host "Docker Info ", $dockerInfo
$serverVersion = $dockerInfo | Where-Object {$_ -Match "Server Version"}
Write-Host "Server Version ", $serverVersion
if (![System.String]::IsNullOrEmpty($serverVersion)) {
Write-Host "Docker successfully started!"
exit 0
}
Write-Host "Restarting Docker Desktop"
Get-Process "*Docker Desktop*" | Stop-Process
$attempt -= 1
}
57 changes: 49 additions & 8 deletions hack/jenkins/windows_integration_test_docker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,60 @@ mkdir -p out
gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/minikube-windows-amd64.exe out/
gsutil.cmd -m cp gs://minikube-builds/$env:MINIKUBE_LOCATION/e2e-windows-amd64.exe out/
gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/setup_docker_desktop_windows.ps1 out/

./out/setup_docker_desktop_windows.ps1

./out/minikube-windows-amd64.exe delete --all

out/e2e-windows-amd64.exe -minikube-start-args="--driver=docker" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
docker ps -aq | ForEach -Process {docker rm -fv $_}

$started=Get-Date -UFormat %s

out/e2e-windows-amd64.exe --minikube-start-args="--driver=docker" --binary=out/minikube-windows-amd64.exe --test.v --test.timeout=180m | Tee-Object -FilePath testout.txt
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
Else {$env:status="failure"}
If($env:result -eq 0){
$env:status="success"
echo "minikube: SUCCESS"
} Else {
$env:status="failure"
echo "minikube: FAIL"
}

$ended=Get-Date -UFormat %s
$elapsed=$ended-$started
$elapsed=$elapsed/60
$elapsed=[math]::Round($elapsed, 2)

Get-Content testout.txt -Encoding ASCII | go tool test2json -t | Out-File -FilePath testout.json -Encoding ASCII

$gopogh_status=gopogh --in testout.json --out testout.html --name "Docker_Windows" -pr $env:MINIKUBE_LOCATION --repo github.com/kubernetes/minikube/ --details $env:COMMIT

# $env:SHORT_COMMIT=$env:COMMIT.substring(0, 7)
# to be used later to implement https://github.com/kubernetes/minikube/issues/6593
$env:target_url="https://storage.googleapis.com/minikube-builds/logs/$env:MINIKUBE_LOCATION/Docker_Windows.txt"
$json = "{`"state`": `"$env:status`", `"description`": `"Jenkins`", `"target_url`": `"$env:target_url`", `"context`": `"Docker_Windows`"}"
$failures=echo $gopogh_status | jq '.NumberOfFail'
$tests=echo $gopogh_status | jq '.NumberOfTests'
$bad_status="$failures / $tests failures"

$description="$status in $elapsed minute(s)."
If($env:status -eq "failure") {
$description="completed with $bad_status in $elapsed minute(s)."
}
echo $description

$env:SHORT_COMMIT=$env:COMMIT.substring(0, 7)
$gcs_bucket="minikube-builds/logs/$env:MINIKUBE_LOCATION/$env:SHORT_COMMIT"
$env:target_url="https://storage.googleapis.com/$gcs_bucket/Docker_Windows.html"

#Upload logs to gcs
gsutil -qm cp testout.txt gs://$gcs_bucket/Docker_Windowsout.txt
gsutil -qm cp testout.json gs://$gcs_bucket/Docker_Windows.json
gsutil -qm cp testout.html gs://$gcs_bucket/Docker_Windows.html

# Update the PR with the new info
$json = "{`"state`": `"$env:status`", `"description`": `"Jenkins: $description`", `"target_url`": `"$env:target_url`", `"context`": `"Docker_Windows`"}"
Invoke-WebRequest -Uri "https://api.github.com/repos/kubernetes/minikube/statuses/$env:COMMIT`?access_token=$env:access_token" -Body $json -ContentType "application/json" -Method Post -usebasicparsing

Exit $env:result
# Just shutdown Docker, it's safer than anything else
Get-Process "*Docker Desktop*" | Stop-Process

Exit $env:result

0 comments on commit c2d8249

Please sign in to comment.