зеркало из https://github.com/microsoft/msquic.git
Switch to using SQL database for performance results rather then files (#505)
* Switch performance tests to use SQL and ASP.NET Core server
This commit is contained in:
Родитель
06eb034621
Коммит
902c7f2f31
|
@ -2,27 +2,15 @@
|
|||
$RootDir = Split-Path $PSScriptRoot -Parent
|
||||
$RootDir = Split-Path $RootDir -Parent
|
||||
|
||||
$GitPath = Join-Path $RootDir "artifacts/PerfDataGit"
|
||||
$ResultsPath = Join-Path $RootDir "artifacts/PerfDataResults/*"
|
||||
$ResultsPath = Join-Path $RootDir "artifacts/PerfDataResults"
|
||||
|
||||
$env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
git clone --single-branch --branch data/performance https://github.com/microsoft/msquic $GitPath
|
||||
$currentLoc = Get-Location
|
||||
Set-Location -Path $GitPath
|
||||
# Enumerate files
|
||||
$Files = Get-ChildItem -Path $ResultsPath -Recurse -File
|
||||
|
||||
Copy-Item -Path $ResultsPath -Destination $GitPath -Recurse -Force
|
||||
$Files | ForEach-Object {
|
||||
$DataToWrite = Get-Content $_ | ConvertFrom-Json
|
||||
$DataToWrite | Add-Member -NotePropertyName "AuthKey" -NotePropertyValue $env:MAPPED_DEPLOYMENT_KEY
|
||||
$JsonToWrite = $DataToWrite | ConvertTo-Json
|
||||
|
||||
git config user.email "quicdev@microsoft.com"
|
||||
git config user.name "QUIC Dev Bot"
|
||||
|
||||
git config --global credential.helper store
|
||||
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:MAPPED_DEPLOYMENT_KEY):x-oauth-basic@github.com`n"
|
||||
|
||||
git add .
|
||||
git status
|
||||
|
||||
git commit -m "Update latest perf results"
|
||||
|
||||
git push
|
||||
|
||||
Set-Location -Path $currentLoc
|
||||
Invoke-RestMethod -Uri "https://msquicperformanceresults.azurewebsites.net/performance" -Body $JsonToWrite -Method 'Post' -ContentType "application/json"
|
||||
}
|
||||
|
|
|
@ -34,4 +34,4 @@ jobs:
|
|||
pwsh: true
|
||||
filePath: .azure/scripts/publish-performance-results.ps1
|
||||
env:
|
||||
MAPPED_DEPLOYMENT_KEY: $(GitHubDeploymentKey)
|
||||
MAPPED_DEPLOYMENT_KEY: $(DatabaseDeploymentKey)
|
||||
|
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
inputs:
|
||||
pwsh: true
|
||||
filePath: scripts/performance.ps1
|
||||
arguments: -Config ${{ parameters.config }} -Arch ${{ parameters.arch }} -Tls ${{ parameters.tls }} -WriteResults
|
||||
arguments: -Config ${{ parameters.config }} -Arch ${{ parameters.arch }} -Tls ${{ parameters.tls }}
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: Move Performance Results
|
||||
|
|
|
@ -12,9 +12,6 @@ This script runs performance tests locally for a period of time.
|
|||
.PARAMETER Tls
|
||||
The TLS library use.
|
||||
|
||||
.PARAMETER WriteResults
|
||||
Write results
|
||||
|
||||
#>
|
||||
|
||||
param (
|
||||
|
@ -28,10 +25,7 @@ param (
|
|||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[ValidateSet("schannel", "openssl", "stub", "mitls")]
|
||||
[string]$Tls = "",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$WriteResults = $false
|
||||
[string]$Tls = ""
|
||||
)
|
||||
|
||||
Set-StrictMode -Version 'Latest'
|
||||
|
@ -49,6 +43,12 @@ if ("" -eq $Tls) {
|
|||
# Root directory of the project.
|
||||
$RootDir = Split-Path $PSScriptRoot -Parent
|
||||
|
||||
$OsPlat = "Linux"
|
||||
if ($IsWindows) {
|
||||
$OsPlat = "Windows"
|
||||
}
|
||||
$Platform = "$($OsPlat)_$($Arch)_$($Tls)"
|
||||
|
||||
# Path to the spinquic exectuable.
|
||||
$PingClient = $null
|
||||
if ($IsWindows) {
|
||||
|
@ -94,33 +94,40 @@ function Run-Foreground-Executable($File, $Arguments) {
|
|||
return $p.StandardOutput.ReadToEnd()
|
||||
}
|
||||
|
||||
$GitPath = Join-Path $RootDir "artifacts/PerfDataGit"
|
||||
|
||||
function Clone-Data-Repo() {
|
||||
# Redirect stderr to stdout for git.
|
||||
$env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
git clone --single-branch --branch data/performance https://github.com/microsoft/msquic $GitPath
|
||||
$currentLoc = Get-Location
|
||||
Set-Location -Path $GitPath
|
||||
git clean -d -x -f
|
||||
git reset --hard
|
||||
git pull
|
||||
Set-Location -Path $currentLoc
|
||||
}
|
||||
|
||||
function Get-Last-Result($Path) {
|
||||
$FullLatestResult = Get-Item -Path $Path | Get-Content -Tail 1
|
||||
$SplitLatestResult = $FullLatestResult -split ','
|
||||
$LatestResult = $SplitLatestResult[$SplitLatestResult.Length - 1].Trim()
|
||||
return $LatestResult
|
||||
}
|
||||
|
||||
function Parse-Loopback-Results($Results) {
|
||||
#Unused variable on purpose
|
||||
$m = $Results -match "Total rate.*\(TX.*bytes @ (.*) kbps \|"
|
||||
return $Matches[1]
|
||||
}
|
||||
|
||||
function Get-Latest-Test-Results($Platform, $Test) {
|
||||
$Uri = "https://msquicperformanceresults.azurewebsites.net/performance/$Platform/$Test"
|
||||
Write-Host $Uri
|
||||
$LatestResult = Invoke-RestMethod -Uri $Uri
|
||||
|
||||
Write-Host $LatestResult
|
||||
|
||||
return $LatestResult
|
||||
}
|
||||
|
||||
function Median-Test-Results($FullResults) {
|
||||
$sorted = $FullResults | Sort-Object
|
||||
return $sorted[[int](($sorted.Length - 1) / 2)]
|
||||
}
|
||||
|
||||
class TestPublishResult {
|
||||
[string]$PlatformName
|
||||
[string]$TestName
|
||||
[string]$CommitHash
|
||||
[double[]]$IndividualRunResults
|
||||
}
|
||||
|
||||
$currentLoc = Get-Location
|
||||
Set-Location -Path $RootDir
|
||||
$env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
$CurrentCommitHash = git rev-parse HEAD
|
||||
Set-Location -Path $currentLoc
|
||||
|
||||
function Run-Loopback-Test() {
|
||||
Write-Host "Running Loopback Test"
|
||||
$proc = Start-Background-Executable -File $PingClient -Arguments "-listen:* -selfsign:1 -peer_uni:1"
|
||||
|
@ -137,50 +144,30 @@ function Run-Loopback-Test() {
|
|||
|
||||
Stop-Background-Executable -Process $proc
|
||||
|
||||
$sum = 0
|
||||
$allRunsResults | ForEach-Object { $sum += $_ }
|
||||
$average = $sum / $allRunsResults.Length
|
||||
$MedianCurrentResult = Median-Test-Results -FullResults $allRunsResults
|
||||
|
||||
$combinedResults = [System.String]::Join(", ", $allRunsResults)
|
||||
$fullLastResult = Get-Latest-Test-Results -Platform $Platform -Test "loopback"
|
||||
|
||||
$osPath = "linux"
|
||||
if ($IsWindows) {
|
||||
$osPath = "windows"
|
||||
}
|
||||
$MedianLastResult = Median-Test-Results -FullResults $fullLastResult.individualRunResults
|
||||
|
||||
$ResultsFolderRoot = "$osPath/loopback"
|
||||
$ResultsFileName = "/results.csv"
|
||||
$ResultsFileNamePath = "$ResultsFolderRoot/$ResultsFileName"
|
||||
$LastResultsPath = Join-Path $GitPath $ResultsFileNamePath
|
||||
$LastResult = Get-Last-Result -Path $LastResultsPath
|
||||
$ToPublishResults = [TestPublishResult]::new()
|
||||
|
||||
if ($WriteResults) {
|
||||
# Redirect stderr to stdout for git.
|
||||
$env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
$time = [DateTime]::UtcNow.ToString("u")
|
||||
$currentLoc = Get-Location
|
||||
Set-Location -Path $RootDir
|
||||
$fullHash = git rev-parse HEAD
|
||||
$hash = $fullHash.Substring(0, 7)
|
||||
$ToPublishResults.CommitHash = $CurrentCommitHash.Substring(0, 7)
|
||||
$ToPublishResults.PlatformName = $Platform
|
||||
$ToPublishResults.TestName = "loopback"
|
||||
$ToPublishResults.IndividualRunResults = $allRunsResults
|
||||
|
||||
$newResult = "$time, $hash, $combinedResults, $average"
|
||||
$ResultsFolderRoot = "$Platform/loopback"
|
||||
$ResultsFileName = "/results.json"
|
||||
|
||||
$NewFilePath = Join-Path $RootDir "artifacts/PerfDataResults/$ResultsFolderRoot"
|
||||
$NewFileLocation = Join-Path $NewFilePath $ResultsFileName
|
||||
New-Item $NewFilePath -ItemType Directory -Force
|
||||
Copy-Item $LastResultsPath -Destination $NewFileLocation -Force
|
||||
$NewFilePath = Join-Path $RootDir "artifacts/PerfDataResults/$ResultsFolderRoot"
|
||||
$NewFileLocation = Join-Path $NewFilePath $ResultsFileName
|
||||
New-Item $NewFilePath -ItemType Directory -Force
|
||||
|
||||
Add-Content -Path $NewFileLocation -Value $newResult
|
||||
Set-Location -Path $currentLoc
|
||||
}
|
||||
$ToPublishResults | ConvertTo-Json | Out-File $NewFileLocation
|
||||
|
||||
Write-Host "Current Run: $average kbps"
|
||||
Write-Host "Last Master Run: $LastResult kbps"
|
||||
Write-Host "All Results: $combinedResults"
|
||||
Write-Host "Current Run: $MedianCurrentResult kbps"
|
||||
Write-Host "Last Master Run: $MedianLastResult kbps"
|
||||
}
|
||||
|
||||
|
||||
Clone-Data-Repo
|
||||
|
||||
|
||||
Run-Loopback-Test
|
||||
|
|
Загрузка…
Ссылка в новой задаче