Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added LCOW functional tests and benchmarks
Split out utility functions from `test/functional` into an internal package, separate from functional tests. Updated code to use containerd instead of docker. Added new functional tests and benchmarks for LCOW uVM containers, and updated other LCOW tests as well. Not all (LCOW) functional tests were updated, and most others are now explicitly skipped. Updated `k8s.io/cri-api` to v0.22 to include `WindowsPodSandboxConfig` struct Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
- Loading branch information
Showing
60 changed files
with
2,427 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# ex: .\scripts\Test-Functional.ps1 -Action Bench -Count 2 -BenchTime "2x" | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[ValidateSet('Test', 'Bench', 'List')] | ||
[alias('a')] | ||
[string] | ||
$Action = 'Bench', | ||
|
||
[string] | ||
$Note = '', | ||
|
||
[string] | ||
$OutDirectory = '.\test\results', | ||
|
||
# test parameters | ||
[int] | ||
$Count = 1, | ||
|
||
[string] | ||
$BenchTime = '5s', | ||
|
||
[string] | ||
$Timeout = '10m', | ||
|
||
[alias('tv')] | ||
[switch] | ||
$TestVerbose, | ||
|
||
[string] | ||
$Run = '', | ||
|
||
[string] | ||
$Feature = '' | ||
) | ||
|
||
Import-Module ( Join-Path $PSScriptRoot Testing.psm1 ) -Force | ||
|
||
$date = Get-Date | ||
$testcmd, $out = New-TestCommand ` | ||
-Action $Action ` | ||
-Path .\bin\test\functional.exe ` | ||
-Name functional ` | ||
-OutDirectory $OutDirectory ` | ||
-Date $date ` | ||
-Note $Note ` | ||
-TestVerbose:$TestVerbose ` | ||
-Count $Count ` | ||
-BenchTime $BenchTime ` | ||
-Timeout $Timeout ` | ||
-Run $Run ` | ||
-Feature $Feature ` | ||
-Verbose:$Verbose | ||
|
||
Invoke-TestCommand ` | ||
-TestCmd $testcmd ` | ||
-OutputFile $out ` | ||
-OutputCmd (&{ if ( $Action -eq 'Bench' ) { 'benchstat' } }) ` | ||
-Preamble ` | ||
-Date $Date ` | ||
-Note $Note ` | ||
-Verbose:$Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
function New-TestCommand { | ||
[CmdletBinding()] | ||
param ( | ||
[ValidateSet('Test', 'Bench', 'List')] | ||
[alias('a')] | ||
[string] | ||
$Action = 'Bench', | ||
|
||
[Parameter(Mandatory)] | ||
[string] | ||
$Path, | ||
|
||
[Parameter(Mandatory)] | ||
[string] | ||
$Name, | ||
|
||
[Parameter(Mandatory)] | ||
[string] | ||
$OutDirectory , | ||
|
||
[DateTime] | ||
$Date = (Get-Date), | ||
|
||
[string] | ||
$Note = '', | ||
|
||
# test parameters | ||
[alias('tv')] | ||
[switch] | ||
$TestVerbose = $false, | ||
|
||
[int] | ||
$Count = 1, | ||
|
||
[string] | ||
$BenchTime = '5s', | ||
|
||
[string] | ||
$Timeout = '10m', | ||
|
||
[string] | ||
$Run = '', | ||
|
||
[string] | ||
$Feature = '' | ||
) | ||
|
||
$OutDirectory = Resolve-Path $OutDirectory | ||
Write-Verbose "creating $OutDirectory" | ||
|
||
New-Item -ItemType 'directory' -Path $OutDirectory -Force > $null | ||
|
||
$testcmd = "$Path `'-test.timeout=$Timeout`' `'-test.shuffle=on`' `'-test.count=$Count`' " | ||
|
||
if ( $TestVerbose ) { | ||
$testcmd += ' ''-test.v'' ' | ||
} | ||
|
||
switch ( $Action ) { | ||
'List' { | ||
if ( $Run -eq '' ) { | ||
$Run = '.' | ||
} | ||
$testcmd += " `'-test.list=$Run`' " | ||
} | ||
'Test' { | ||
if ( $Run -ne '' ) { | ||
$testcmd += " `'-test.run=$Run`' " | ||
} | ||
} | ||
'Bench' { | ||
if ( $Run -eq '' ) { | ||
$Run = '.' | ||
} | ||
$testcmd += ' ''-test.run=^#'' ''-test.benchmem'' ' + ` | ||
" `'-test.bench=$Run`' `'-test.benchtime=$BenchTime`' " | ||
} | ||
} | ||
|
||
if ( $Feature -ne '' ) { | ||
$testcmd += " `'-feature=$Feature`' " | ||
} | ||
|
||
$f = $Name + '-' + $Action | ||
if ($Note -ne '' ) { | ||
$f += '-' + $Note | ||
} | ||
$out = Join-Path $OutDirectory "$f-$(Get-Date -Date $date -Format FileDateTime).txt" | ||
|
||
return $testcmd, $out | ||
} | ||
|
||
function Invoke-TestCommand { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory)] | ||
[string] | ||
$TestCmd, | ||
|
||
[string] | ||
$TestCmdPreamble = $TestCmd, | ||
|
||
[string] | ||
$OutputFile = 'nul', | ||
|
||
[string] | ||
$OutputCmd, | ||
|
||
[switch] | ||
$Preamble, | ||
|
||
[DateTime] | ||
$Date = (Get-Date), | ||
|
||
[string] | ||
$Note | ||
) | ||
|
||
if ($OutputFile -eq '' ) { | ||
$OutputFile = 'nul' | ||
} | ||
|
||
Write-Verbose "Saving output to: $OutputFile" | ||
if ( $Preamble ) { | ||
& { | ||
Write-Output "test.date: $(Get-Date -Date $Date -UFormat '%FT%R%Z' -AsUTC)" | ||
if ( $Note -ne '' ) { | ||
Write-Output "note: $Note" | ||
} | ||
Write-Output "test.command: $TestCmdPreamble" | ||
Write-Output "pkg.commit: $(git rev-parse HEAD)" | ||
} | Tee-Object -Append -FilePath $OutputFile | ||
} | ||
|
||
Write-Verbose "Running command: $TestCmd" | ||
Invoke-Expression $TestCmd | Tee-Object -Append -FilePath $OutputFile | ||
|
||
if ( $OutputCmd -ne '' -and $OutputFile -ne 'nul' ) { | ||
$oc = "$OutputCmd $OutputFile" | ||
Write-Verbose "Running command: $oc" | ||
Invoke-Expression $oc | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
//go:build windows && functional | ||
// +build windows,functional | ||
|
||
package functional | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Microsoft/hcsshim/osversion" | ||
|
||
"github.com/Microsoft/hcsshim/test/internal/require" | ||
"github.com/Microsoft/hcsshim/test/internal/uvm" | ||
) | ||
|
||
func BenchmarkLCOW_UVM_Create(b *testing.B) { | ||
requireFeatures(b, featureLCOW) | ||
require.Build(b, osversion.RS5) | ||
|
||
ctx := context.Background() | ||
|
||
b.StopTimer() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
opts := defaultLCOWOptions(b, b.Name()) | ||
|
||
b.StartTimer() | ||
vm := uvm.CreateLCOW(ctx, b, opts) | ||
b.StopTimer() | ||
|
||
// vm.Close() hangs unless the vm was started | ||
cleanup := uvm.Start(ctx, b, vm) | ||
cleanup() | ||
} | ||
} | ||
|
||
func BenchmarkLCOW_UVM_Start(b *testing.B) { | ||
requireFeatures(b, featureLCOW) | ||
require.Build(b, osversion.RS5) | ||
|
||
ctx := context.Background() | ||
|
||
b.StopTimer() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
vm := uvm.CreateLCOW(ctx, b, defaultLCOWOptions(b, b.Name())) | ||
|
||
b.StartTimer() | ||
if err := vm.Start(ctx); err != nil { | ||
b.Fatalf("could not start UVM: %v", err) | ||
} | ||
b.StopTimer() | ||
|
||
vm.Close() | ||
} | ||
} | ||
|
||
func BenchmarkLCOW_UVM_Kill(b *testing.B) { | ||
requireFeatures(b, featureLCOW) | ||
require.Build(b, osversion.RS5) | ||
|
||
ctx := context.Background() | ||
|
||
b.StopTimer() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
vm := uvm.CreateLCOW(ctx, b, defaultLCOWOptions(b, b.Name())) | ||
cleanup := uvm.Start(ctx, b, vm) | ||
|
||
b.StartTimer() | ||
uvm.Kill(ctx, b, vm) | ||
if err := vm.Wait(); err != nil { | ||
b.Fatalf("could not kill uvm %q: %v", vm.ID(), err) | ||
} | ||
b.StopTimer() | ||
|
||
cleanup() | ||
} | ||
} | ||
|
||
func BenchmarkLCOW_UVM_Close(b *testing.B) { | ||
requireFeatures(b, featureLCOW) | ||
require.Build(b, osversion.RS5) | ||
|
||
ctx := context.Background() | ||
|
||
b.StopTimer() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
vm := uvm.CreateLCOW(ctx, b, defaultLCOWOptions(b, b.Name())) | ||
cleanup := uvm.Start(ctx, b, vm) | ||
|
||
b.StartTimer() | ||
if err := vm.Close(); err != nil { | ||
b.Fatalf("could not kill uvm %q: %v", vm.ID(), err) | ||
} | ||
b.StopTimer() | ||
|
||
cleanup() | ||
} | ||
} |
Oops, something went wrong.