From af233335edefbfb1a1e581be89a6e658e353b464 Mon Sep 17 00:00:00 2001 From: "Jack He (Github)" Date: Thu, 11 Jan 2024 17:34:22 -0800 Subject: [PATCH] Update SQL strings to conform to new format. (#4049) * adjust SQL strings * remove old testId array * json is not pass by reference in powershell :( --------- Co-authored-by: Jack He --- scripts/secnetperf-helpers.psm1 | 44 ++++++++++++++++++++++----------- scripts/secnetperf.ps1 | 30 +++++----------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/scripts/secnetperf-helpers.psm1 b/scripts/secnetperf-helpers.psm1 index cb27395acb..129776b727 100644 --- a/scripts/secnetperf-helpers.psm1 +++ b/scripts/secnetperf-helpers.psm1 @@ -68,7 +68,7 @@ function Stop-RemoteServer { } # Invokes all the secnetperf tests. -function Invoke-SecnetperfTest($testIds, $commands, $exe, $json, $LogProfile) { +function Invoke-SecnetperfTest($MsQuicCommit, $commands, $exe, $start, $LogProfile) { Write-Host "Running Secnetperf tests..." @@ -76,9 +76,15 @@ function Invoke-SecnetperfTest($testIds, $commands, $exe, $json, $LogProfile) { "@ $json = @{} + for ($i = 0; $i -lt $commands.Count; $i++) { for ($tcp = 0; $tcp -lt 2; $tcp++) { + $testid = $i + 1 + $start + $SQL += @" + +INSERT OR IGNORE INTO Secnetperf_tests (Secnetperf_test_ID, Kernel_mode, Run_arguments) VALUES ($testid, 0, "$($commands[$i]) -tcp:$tcp") +"@ $command = "$exe -target:netperf-peer $($commands[$i]) -tcp:$tcp -trimout" Write-Host "> $command" @@ -110,41 +116,49 @@ function Invoke-SecnetperfTest($testIds, $commands, $exe, $json, $LogProfile) { continue } + $env = 2 + if ($isWindows) { + $env = 1 + } + Write-Host $rawOutput - if ($testIds[$i].Contains("rps")) { + $transport = "quic" + + if ($tcp -eq 1) { + $transport = "tcp" + } + + if ($command.Contains("lowlat")) { $latency_percentiles = '(?<=\d{1,3}(?:\.\d{1,2})?th: )\d+' $Perc = [regex]::Matches($rawOutput, $latency_percentiles) | ForEach-Object {$_.Value} - $json[$testIds[$i]] = $Perc + $json["latency-$transport"] = $Perc # TODO: SQL += ... continue } $throughput = '@ (\d+) kbps' - $testId = $testIds[$i] - if ($tcp -eq 1) { - $testId += "-tcp" - } else { - $testId += "quic" + $metric = "download" + if ($command.Contains("-up")) { + $metric = "upload" } - $testId += "-$MsQuicCommit" foreach ($line in $rawOutput) { if ($line -match $throughput) { $num = $matches[1] - # Generate SQL statement + # Generate SQL statement. Assume LAST_INSERT_ROW_ID() $SQL += @" -INSERT INTO Secnetperf_test_runs (Secnetperf_test_ID, Client_environment_ID, Server_environment_ID, Result, Latency_stats_ID, Units) -VALUES ('$($testIds[$i])', 'azure_vm', 'azure_vm', $num, NULL, 'kbps'); +INSERT INTO Secnetperf_test_runs (Secnetperf_test_ID, Secnetperf_commit, Client_environment_ID, Server_environment_ID, Result, Latency_stats_ID) +VALUES ($testid, '$MsQuicCommit', $env, $env, $num, NULL); "@ - # Generate JSON - $json[$testIds[$i]] = $num + # Generate JSON as intermediary file for dashboard + $json["throughput-$metric-$transport"] = $num break } } @@ -161,5 +175,5 @@ VALUES ('$($testIds[$i])', 'azure_vm', 'azure_vm', $num, NULL, 'kbps'); }} - return $SQL + return $SQL, $json } diff --git a/scripts/secnetperf.ps1 b/scripts/secnetperf.ps1 index 584dc30b55..bbab511d57 100644 --- a/scripts/secnetperf.ps1 +++ b/scripts/secnetperf.ps1 @@ -140,34 +140,12 @@ $SQL = @" INSERT OR IGNORE INTO Secnetperf_builds (Secnetperf_Commit, Build_date_time, TLS_enabled, Advanced_build_config) VALUES ('$MsQuicCommit', '$(Get-Date -Format "yyyy-MM-dd HH:mm:ss")', 1, 'TODO'); -INSERT OR IGNORE INTO Secnetperf_tests (Secnetperf_test_ID, Secnetperf_build_ID, Kernel_mode, Run_arguments, Test_name) -VALUES ('throughput-upload-quic-$MsQuicCommit', '$MsQuicCommit', 0, '-target:netperf-peer -exec:maxtput -upload:10s', 'throughput-upload-quic'); - -INSERT OR IGNORE INTO Secnetperf_tests (Secnetperf_test_ID, Secnetperf_build_ID, Kernel_mode, Run_arguments, Test_name) -VALUES ('throughput-upload-tcp-$MsQuicCommit', '$MsQuicCommit', 0, '-target:netperf-peer -exec:maxtput -upload:10s -tcp:1', 'throughput-upload-tcp'); - -INSERT OR IGNORE INTO Secnetperf_tests (Secnetperf_test_ID, Secnetperf_build_ID, Kernel_mode, Run_arguments, Test_name) -VALUES ('throughput-download-quic-$MsQuicCommit', '$MsQuicCommit', 0, '-target:netperf-peer -exec:maxtput -download:10s', 'throughput-download-quic'); - -INSERT OR IGNORE INTO Secnetperf_tests (Secnetperf_test_ID, Secnetperf_build_ID, Kernel_mode, Run_arguments, Test_name) -VALUES ('throughput-download-tcp-$MsQuicCommit', '$MsQuicCommit', 0, '-target:netperf-peer -exec:maxtput -download:10s -tcp:1', 'throughput-download-tcp'); - "@ $exe = "./$SecNetPerfPath" $json = @{} -$maxtputIds = @( - "throughput-upload", - "throughput-download", - "hps" -) - -$lowlatIds = @( - "rps-1conn-1stream" -) - $maxtput = @( "-exec:maxtput -up:10s -ptput:1", "-exec:maxtput -down:10s -ptput:1", @@ -178,14 +156,18 @@ $lowlat = @( "-exec:lowlat -rstream:1 -up:512 -down:4000 -run:10s -plat:1" ) -$SQL += Invoke-SecnetperfTest $maxtputIds $maxtput $exe $json $LogProfile +$res = Invoke-SecnetperfTest $MsQuicCommit $maxtput $exe 0 $LogProfile +$SQL += $res[0] +$json += $res[1] # Start and restart the SecNetPerf server without maxtput. Write-Host "Restarting server without maxtput..." Stop-RemoteServer $Job $RemoteName $Job = Start-RemoteServer $Session "$RemoteDir/$SecNetPerfPath -exec:lowlat" -$SQL += Invoke-SecnetperfTest $lowlatIds $lowlat $exe $json $LogProfile +$res = Invoke-SecnetperfTest $MsQuicCommit $lowlat $exe 3 $LogProfile +$SQL += $res[0] +$json += $res[1] ####################################################################################################