Commit 2b1641ac authored by Tomasz Maczukin's avatar Tomasz Maczukin

Parallelize windows test execution

parent a79a4d07
Pipeline #50162865 passed with stages
in 49 minutes and 2 seconds
......@@ -240,6 +240,7 @@ unit test with race:
.windows test:
extends: .except_docs
stage: test
parallel: 3
variables:
GOROOT: "C:\\Go"
PKG_NAMESPACE: gitlab.com\gitlab-org
......@@ -248,14 +249,12 @@ unit test with race:
PKG_BASE_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE"
PKG_BUILD_DIR: "$CI_PROJECT_DIR\\.gopath\\src\\$PKG_NAMESPACE\\$PKG_NAME"
before_script:
- cat testsdefinitions.txt
- if (Test-Path $GOPATH) { Remove-Item -Force -Recurse $GOPATH }
- New-Item $PKG_BASE_DIR -ItemType directory -Force
- New-Item -ItemType SymbolicLink -Path $PKG_BUILD_DIR -Value $CI_PROJECT_DIR
- cd $PKG_BUILD_DIR
script:
- $script = Join-Path -Path "ci" -ChildPath "test_windows.ps1"
- powershell -File $script
- .\ci\test_windows.ps1
after_script:
- if (Test-Path $PKG_BUILD_DIR) { $(Get-Item $PKG_BUILD_DIR).Delete() }
allow_failure: true
......
param([string]$testOpts = "")
param(
[string]$testsDefinitionsFile = ".\testsdefinitions.txt"
)
$InformationPreference = "Continue"
function Get-Line([string]$file) {
(Get-Content $file | Measure-Object -Line).Lines
}
$numberOfDefinitions = Get-Line -file $testsDefinitionsFile
$executionSize = [int]($numberOfDefinitions / $env:CI_NODE_TOTAL)
$nodeIndex = $env:CI_NODE_INDEX - 1
$executionOffset = ($nodeIndex * $executionSize)
Write-Information "Number of definitions: $numberOfDefinitions"
Write-Information "Suite size: $env:CI_NODE_TOTAL"
Write-Information "Suite index: $env:CI_NODE_INDEX"
Write-Information "Execution size: $executionSize"
Write-Information "Execution offset: $executionOffset"
$failed = @()
go list ./... | Select-String -Pattern "gitlab.com/gitlab-org/gitlab-runner/vendor/" -NotMatch | ForEach-Object {
$pkg = %{$_ -replace "\r\n", "" }
$testCmd = "go test $testOpts $pkg"
Invoke-Expression $testCmd
if ( $LASTEXITCODE -ne 0 ) { $failed += $pkg }
Get-Content $testsDefinitionsFile | Select-Object -skip $executionOffset -first $executionSize | ForEach-Object {
$pkg, $index, $tests = $_.Split(" ", 3)
Write-Information "`r`n`r`n--- Starting part $index of go tests of '$pkg' package:`r`n`r`n"
go test -v $pkg -run "$tests"
if ($LASTEXITCODE -ne 0) {
$failed += "$pkg-$index"
}
}
if ($failed.count -ne 0) {
Write-Host "Failed packages"
$failed | Out-String | Write-Host
Write-Output ""
Write-Warning "Failed packages:"
$failed | Out-String | Write-Warning
exit 1
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment