-
Notifications
You must be signed in to change notification settings - Fork 1
/
PerformanceTestRunner.ps1
129 lines (107 loc) · 3.71 KB
/
PerformanceTestRunner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<#
.SYNOPSIS
Runs the set of performance tests in the test cases directory.
.PARAMETER resultsFolderPath
The results folder path
.PARAMETER nugetClientFilePaths
An array of NuGet clients to run the tests for. Supported are dotnet.exe and NuGet.exe clients.
.PARAMETER testRootFolderPath
The test root folder path. All temporary assets will be stored here. That includes the download of repos under a 'source' subfolder and the NuGet folders, under an 'np' subfolder.
.PARAMETER logsFolderPath
The logs folder path.
.PARAMETER iterationCount
How many times to run each test. The default is 3
.PARAMETER skipRepoCleanup
Whether to delete the checked out repos from the test cases.
.EXAMPLE
.\PerformanceTestRunner.ps1 -resultsFolderPath resultsFolder -nugetClientFilePaths F:\NuGetExe\NuGet.exe,"C:\Program Files\dotnet\dotnet.exe"
#>
Param(
[Parameter(Mandatory = $true)]
[string] $resultsFolderPath,
[Parameter(Mandatory = $true)]
[string[]] $nugetClientFilePaths,
[string] $testRootFolderPath,
[string] $logsFolderPath,
[int] $iterationCount = 3,
[switch] $skipRepoCleanup
)
. "$PSScriptRoot\PerformanceTestUtilities.ps1"
if([string]::IsNullOrEmpty($testRootFolderPath))
{
$testRootFolderPath = GetDefaultNuGetTestFolder
}
else
{
$testRootFolderPath = GetAbsolutePath $testRootFolderPath
}
$nugetFoldersPath = GetNuGetFoldersPath $testRootFolderPath
$resultsFolderPath = GetAbsolutePath $resultsFolderPath
$sourceRootFolderPath = [System.IO.Path]::Combine($testRootFolderPath, "source")
if([string]::IsNullOrEmpty($logsFolderPath))
{
$deleteLogs = $True
$logsFolderPath = [System.IO.Path]::Combine($testRootFolderPath, "logs")
}
else
{
$deleteLogs = $False
$logsFolderPath = GetAbsolutePath $logsFolderPath
}
If ([System.IO.Path]::GetDirectoryName($resultsFolderPath).StartsWith($nugetFoldersPath))
{
Log "$resultsFolderPath cannot be a subdirectory of $nugetFoldersPath" "red"
Exit 1
}
Log "Clients: $nugetClientFilePaths" "green"
Try
{
ForEach ($nugetClientFilePath In $nugetClientFilePaths)
{
Try
{
Log "Running tests for $nugetClientFilePath" "green"
If ([string]::IsNullOrEmpty($nugetClientFilePath) -Or !$(Test-Path $nugetClientFilePath))
{
Log "The NuGet client at '$nugetClientFilePath' cannot be resolved." "yellow"
Exit 1
}
Log "Discovering the test cases."
$testFiles = $(Get-ChildItem $PSScriptRoot\testCases "Test-*.ps1" ) | ForEach-Object { $_.FullName }
Log "Discovered test cases: $testFiles" "green"
$testFiles | ForEach-Object {
$testCase = $_
Try
{
. $_ `
-nugetClientFilePath $nugetClientFilePath `
-sourceRootFolderPath $sourceRootFolderPath `
-resultsFolderPath $resultsFolderPath `
-logsFolderPath $logsFolderPath `
-nugetFoldersPath $nugetFoldersPath `
-iterationCount $iterationCount
}
Catch
{
Log "Problem running the test case $testCase with error $_" "red"
}
}
}
Catch
{
Log "Problem running the tests with $nugetClientFilePath" "red"
}
}
}
Finally
{
Remove-Item -Recurse -Force $nugetFoldersPath -ErrorAction Ignore > $Null
if($deleteLogs)
{
Remove-Item -Recurse -Force $logsFolderPath -ErrorAction Ignore > $Null
}
If (!$skipRepoCleanup)
{
Remove-Item -Recurse -Force $sourceRootFolderPath -ErrorAction Ignore > $Null
}
}