Skip to content

Commit

Permalink
run api_tests as system (#3857)
Browse files Browse the repository at this point in the history
* add psexec tests

* update scripts

* update script, change store load order

* skip system tests from regression tests

* update test script
  • Loading branch information
saxena-anurag committed Sep 28, 2024
1 parent bc299eb commit 593b29d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
17 changes: 17 additions & 0 deletions scripts/config_test_vm.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ function Get-ZipFileFromUrl {
for ($i = 0; $i -lt 5; $i++) {
try {
Write-Log "Downloading $Url to $DownloadFilePath"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Url -OutFile $DownloadFilePath

Write-Log "Extracting $DownloadFilePath to $OutputDir"
Expand Down Expand Up @@ -678,7 +679,23 @@ function Get-VCRedistributable {
$DownloadPath = "$pwd\vc-redist"
mkdir $DownloadPath
Write-Host "Downloading Visual C++ Redistributable from $url to $DownloadPath"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $url -OutFile "$DownloadPath\vc_redist.x64.exe"
Move-Item -Path "$DownloadPath\vc_redist.x64.exe" -Destination $pwd -Force
Remove-Item -Path $DownloadPath -Force -Recurse
}

# Download and extract PSExec to run tests as SYSTEM.
function Get-PSExec {
$url = "https://download.sysinternals.com/files/PSTools.zip"
$DownloadPath = "$pwd\psexec"
mkdir $DownloadPath
Write-Host "Downloading PSExec from $url to $DownloadPath"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $url -OutFile "$DownloadPath\pstools.zip"
cd $DownloadPath
Expand-Archive -Path "$DownloadPath\pstools.zip" -Force
cd ..
Move-Item -Path "$DownloadPath\PSTools\PsExec64.exe" -Destination $pwd -Force
Remove-Item -Path $DownloadPath -Force -Recurse
}
7 changes: 1 addition & 6 deletions scripts/execute_ebpf_cicd_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ param ([parameter(Mandatory = $false)][string] $AdminTarget = "TEST_VM",

Push-Location $WorkingDirectory

# For test execution, "Regression" and "CI/CD" have same behavior.
if ($TestMode -eq "Regression") {
$TestMode = "CI/CD"
}

$AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction Stop
$StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop

Expand Down Expand Up @@ -56,7 +51,7 @@ foreach ($VM in $VMList) {

# This script is used to execute the various kernel mode tests. The required behavior is selected by the $TestMode
# parameter.
if ($TestMode -eq "CI/CD") {
if (($TestMode -eq "CI/CD") -or ($TestMode -eq "Regression")) {

# Run XDP Tests.
Invoke-XDPTestsOnVM `
Expand Down
13 changes: 13 additions & 0 deletions scripts/install_ebpf.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ function Install-eBPFComponents
}
}

# Export program info for the sample driver as SYSTEM.
Write-Log("Running 'export_program_info_sample.exe' as SYSTEM...")
if (Test-Path -Path "export_program_info_sample.exe") {
$TestCommand = "$pwd\PsExec64.exe"
$Arguments = "-accepteula -nobanner -s -w `"$pwd`" `"$pwd\export_program_info_sample.exe`""
Start-Process -NoNewWindow -Wait "$TestCommand" -ArgumentList "$Arguments"
if ($LASTEXITCODE -ne 0) {
throw ("Failed to run 'export_program_info_sample.exe as SYSTEM'.");
} else {
Write-Log "'export_program_info_sample.exe' succeeded." -ForegroundColor Green
}
}

# Print the status of the eBPF drivers and services after installation.
Print-eBPFComponentsStatus "Verifying the status of eBPF drivers and services after the installation..." | Out-Null

Expand Down
13 changes: 12 additions & 1 deletion scripts/run_driver_tests.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function Invoke-CICDTests
param([parameter(Mandatory = $true)][bool] $VerboseLogs,
[parameter(Mandatory = $false)][bool] $Coverage = $false,
[parameter(Mandatory = $false)][int] $TestHangTimeout = 3600,
[parameter(Mandatory = $false)][string] $UserModeDumpFolder = "C:\Dumps"
[parameter(Mandatory = $false)][string] $UserModeDumpFolder = "C:\Dumps",
[parameter(Mandatory = $true)][bool] $ExecuteSystemTests
)


Expand All @@ -103,10 +104,20 @@ function Invoke-CICDTests
"sample_ext_app.exe",
"socket_tests.exe")

$SystemTestList = @("api_test.exe")

foreach ($Test in $TestList) {
Invoke-Test -TestName $Test -VerboseLogs $VerboseLogs -Coverage $Coverage
}

# Now run the system tests. No coverage is needed for these tests.
if ($ExecuteSystemTests) {
foreach ($Test in $SystemTestList) {
$TestCommand = "PsExec64.exe -accepteula -nobanner -s -w `"$pwd`" `"$pwd\$Test`" `"-d yes`""
Invoke-Test -TestName $TestCommand -VerboseLogs $VerboseLogs -Coverage $false
}
}

if ($Coverage) {
# Combine code coverage reports
$ArgumentsList += @()
Expand Down
1 change: 1 addition & 0 deletions scripts/setup_ebpf_cicd_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if ($TestMode -eq "CI/CD" -or $TestMode -eq "Regression") {

Get-Duonic
Get-VCRedistributable
Get-PSExec

# Export build artifacts to the test VMs.
Export-BuildArtifactsToVMs -VMList $VMList -ErrorAction Stop
Expand Down
10 changes: 10 additions & 0 deletions scripts/vm_run_tests.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ function Invoke-CICDTestsOnVM
-Coverage $Coverage `
-TestHangTimeout $TestHangTimeout `
-UserModeDumpFolder $UserModeDumpFolder `
-ExecuteSystemTests $true `
2>&1 | Write-Log
}
"regression" {
Invoke-CICDTests `
-VerboseLogs $VerboseLogs `
-Coverage $Coverage `
-TestHangTimeout $TestHangTimeout `
-UserModeDumpFolder $UserModeDumpFolder `
-ExecuteSystemTests $false `
2>&1 | Write-Log
}
"stress" {
Expand Down

0 comments on commit 593b29d

Please sign in to comment.