...
1#ex: .\scripts\Test-LCOW-UVM.ps1 -vb -Count 2 -Benchtime '3s'
2# benchstat via `go install golang.org/x/perf/cmd/benchstat@latest`
3
4[CmdletBinding()]
5param (
6 [ValidateSet('Test', 'Bench', 'List', 'Shell')]
7 [alias('a')]
8 [string]
9 $Action = 'Bench',
10
11 [string]
12 $Note = '',
13
14 # test parameters
15 [switch]
16 $Shuffle,
17
18 [int]
19 $Count = 1,
20
21 [string]
22 $BenchTime = '5s',
23
24 [string]
25 $Timeout = '10m',
26
27 [alias('tv')]
28 [switch]
29 $TestVerbose,
30
31 [string]
32 $Run,
33
34 [string]
35 $OutDirectory = '.\test\results',
36
37 # uvm parameters
38
39 [string]
40 $UVMBootPath = '.\bin\cmd\uvmboot.exe',
41
42 [string]
43 $BootFilesPath = 'C:\ContainerPlat\LinuxBootFiles',
44
45 [ValidateSet('vhd', 'initrd')]
46 [string]
47 $BootFSType = 'vhd',
48
49 [switch]
50 $DisableTimeSync,
51
52 # gcs test/container options
53
54 # we can no longer specify the guest/destination path for SCSI mounts, so hope the rootfs is the first
55 # path to be SCSI-mounted
56 [string]
57 $ContainerRootFSMount = '/run/mounts/scsi/m0',
58
59 [string]
60 $ContainerRootFSPath = (Join-Path $BootFilesPath 'rootfs.vhd'),
61
62 [string]
63 $GCSTestMount = '/run/bin',
64
65 [string]
66 $GCSTestPath = '.\bin\test\gcs.test',
67
68 [switch]
69 $SkipGCSTestMount,
70
71 [string[]]
72 $Features
73)
74$ErrorActionPreference = 'Stop'
75Import-Module ( Join-Path $PSScriptRoot Testing.psm1 ) -Force
76
77$BootFilesPath = Resolve-Path $BootFilesPath
78$ContainerRootFSPath = Resolve-Path $ContainerRootFSPath
79$GCSTestPath = Resolve-Path $GCSTestPath
80$UVMBootPath = Resolve-Path $UVMBootPath
81
82$shell = ( $Action -eq 'Shell' )
83
84$date = Get-Date
85if ( $shell ) {
86 $cmd = 'ash'
87} else {
88 $waitfiles = "$ContainerRootFSMount"
89 $gcspath = 'gcs.test'
90 if ( -not $SkipGCSTestMount ) {
91 $waitfiles += ",$GCSTestMount"
92 $gcspath = "$GCSTestMount/gcs.test"
93 }
94
95 $pre = "wait-paths -p $waitfiles -t 5 ; " + `
96 'echo nproc: `$(nproc) ; ' + `
97 'echo kernel: `$(uname -a) ; ' + `
98 'echo gcs.commit: `$(cat /info/gcs.commit 2>/dev/null) ; ' + `
99 'echo gcs.branch: `$(cat /info/gcs.branch 2>/dev/null) ; ' + `
100 'echo tar.date: `$(cat /info/tar.date 2>/dev/null) ; ' + `
101 'echo image.name: `$(cat /info/image.name 2>/dev/null) ; ' + `
102 'echo build.date: `$(cat /info/build.date 2>/dev/null) ; '
103
104 $testcmd, $out = New-TestCommand `
105 -Action $Action `
106 -Path $gcspath `
107 -Name gcstest `
108 -OutDirectory $OutDirectory `
109 -Date $date `
110 -Note $Note `
111 -Shuffle:$Shuffle `
112 -TestVerbose:$TestVerbose `
113 -Count $Count `
114 -BenchTime $BenchTime `
115 -Timeout $Timeout `
116 -Run $Run `
117 -Features $Features `
118 -Verbose:$Verbose
119
120 $testcmd += " `'-rootfs-path=$ContainerRootFSMount`' "
121 $cmd = $pre + $testcmd
122}
123
124$boot = "$UVMBootPath -gcs lcow " + `
125 '-fwd-stdout -fwd-stderr -output-handling stdout ' + `
126 "-boot-files-path $BootFilesPath " + `
127 "-root-fs-type $BootFSType " + `
128 '-kernel-file vmlinux ' + `
129 "-mount-scsi `"$ContainerRootFSPath`" "
130
131if ( -not $SkipGCSTestMount ) {
132 $boot += "-share `"$GCSTestPath,$GCSTestMount`" "
133}
134
135if ( $DisableTimeSync ) {
136 $boot += ' -disable-time-sync '
137}
138
139if ( $shell ) {
140 $boot += ' -t '
141}
142
143$boot += " -exec `"$cmd`" "
144
145Invoke-TestCommand `
146 -TestCmd $boot `
147 -TestCmdPreamble $testcmd `
148 -OutputFile (& { if ( $Action -ne 'Shell' ) { $out } }) `
149 -OutputCmd (& { if ( $Action -eq 'Bench' ) { 'benchstat' } }) `
150 -Preamble `
151 -Date $Date `
152 -Note $Note `
153 -Verbose:$Verbose
View as plain text