Skip to content

Commit

Permalink
Update SQL strings to conform to new format. (#4049)
Browse files Browse the repository at this point in the history
* adjust SQL strings

* remove old testId array

* json is not pass by reference in powershell :(

---------

Co-authored-by: Jack He <[email protected]>
  • Loading branch information
ProjectsByJackHe and ProjectsByJackHe authored Jan 12, 2024
1 parent 1558e63 commit af23333
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 39 deletions.
44 changes: 29 additions & 15 deletions scripts/secnetperf-helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ 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..."

$SQL = @"
"@
$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"

Expand Down Expand Up @@ -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
}
}
Expand All @@ -161,5 +175,5 @@ VALUES ('$($testIds[$i])', 'azure_vm', 'azure_vm', $num, NULL, 'kbps');

}}

return $SQL
return $SQL, $json
}
30 changes: 6 additions & 24 deletions scripts/secnetperf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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]

####################################################################################################

Expand Down

0 comments on commit af23333

Please sign in to comment.