From 30ffe7bc7917b764b9b7e5ca4605690c134bd652 Mon Sep 17 00:00:00 2001 From: Gianni Trevisiol Date: Wed, 21 Feb 2024 11:05:45 -0800 Subject: [PATCH] wip --- scripts/cleanup_ebpf_cicd_tests.ps1 | 3 ++- scripts/execute_ebpf_cicd_tests.ps1 | 4 ++-- scripts/run_driver_tests.psm1 | 19 ++++++++++--------- scripts/vm_run_tests.psm1 | 10 +++------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index 1a1ede97d3..b15443821d 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -27,7 +27,8 @@ Import-ResultsFromVM -VMList $VMList -KmTracing $KmTracing # Uninstall eBPF Components on the test VM. foreach($VM in $VMList) { $VMName = $VM.Name - Uninstall-eBPFComponentsOnVM -VMName $VMname -ErrorAction Stop + Write-Host "Uninstalling eBPF components on VM $VMName..." + Uninstall-eBPFComponentsOnVM -VMName $VMname -WorkingDirectory $WorkingDirectory -ErrorAction Stop } # Stop the VMs. diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index cf18496966..44be43fd2f 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -17,8 +17,8 @@ $AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction $StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop # Load other utility modules. -Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue -Import-Module .\vm_run_tests.psm1 -Force -ArgumentList ($AdminTestVMCredential.UserName, $AdminTestVMCredential.Password, $StandardUserTestVMCredential.UserName, $StandardUserTestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue +Import-Module $PSScriptRoot\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue +Import-Module $PSScriptRoot\vm_run_tests.psm1 -Force -ArgumentList ($AdminTestVMCredential.UserName, $AdminTestVMCredential.Password, $StandardUserTestVMCredential.UserName, $StandardUserTestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index b7ecbc115b..bf6744d306 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -9,6 +9,7 @@ Push-Location $WorkingDirectory Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue Import-Module .\install_ebpf.psm1 -Force -ArgumentList ($WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue +$TestDirectory = "$env:ProgramFiles\ebpf-for-windows\testing" $CodeCoverage = "$env:ProgramFiles\OpenCppCoverage\OpenCppCoverage.exe" # @@ -102,7 +103,7 @@ function Invoke-CICDTests param([parameter(Mandatory = $true)][bool] $VerboseLogs, [parameter(Mandatory = $false)][bool] $Coverage = $false) - pushd $WorkingDirectory + Push-Location $WorkingDirectory $env:EBPF_ENABLE_WER_REPORT = "yes" try { @@ -113,7 +114,7 @@ function Invoke-CICDTests "socket_tests.exe") foreach ($Test in $TestList) { - Invoke-Test -TestName $Test -VerboseLogs $VerboseLogs -Coverage $Coverage + Invoke-Test -TestName "$TestDirectory\$Test" -VerboseLogs $VerboseLogs -Coverage $Coverage } if ($Coverage) { @@ -136,7 +137,7 @@ function Invoke-CICDTests throw } - popd + Pop-Location } function Invoke-XDPTest @@ -146,7 +147,7 @@ function Invoke-XDPTest [parameter(Mandatory=$true)][string] $XDPTestName, [parameter(Mandatory=$true)][string] $WorkingDirectory) - pushd $WorkingDirectory + Push-Location $WorkingDirectory Write-Log "Executing $XDPTestName with remote address: $RemoteIPV4Address." $LASTEXITCODE = 0 @@ -164,7 +165,7 @@ function Invoke-XDPTest Write-Log "$XDPTestName Test Passed" -ForegroundColor Green - popd + Pop-Location } function Invoke-ConnectRedirectTest @@ -182,7 +183,7 @@ function Invoke-ConnectRedirectTest [parameter(Mandatory=$true)][string] $UserType, [parameter(Mandatory=$true)][string] $WorkingDirectory) - pushd $WorkingDirectory + Push-Location $WorkingDirectory ## First run the test with both v4 and v6 programs attached. $Parameters = "--virtual-ip-v4 $VirtualIPv4Address --virtual-ip-v6 $VirtualIPv6Address --local-ip-v4 $LocalIPv4Address --local-ip-v6 $LocalIPv6Address --remote-ip-v4 $RemoteIPv4Address --remote-ip-v6 $RemoteIPv6Address --destination-port $DestinationPort --proxy-port $ProxyPort --user-type $UserType" @@ -242,7 +243,7 @@ function Invoke-ConnectRedirectTest Write-Log "Connect-Redirect Test Passed" -ForegroundColor Green - popd + Pop-Location } function Invoke-CICDStressTests @@ -251,7 +252,7 @@ function Invoke-CICDStressTests [parameter(Mandatory = $false)][bool] $Coverage = $false, [parameter(Mandatory = $false)][bool] $RestartExtension = $false) - pushd $WorkingDirectory + Push-Location $WorkingDirectory $env:EBPF_ENABLE_WER_REPORT = "yes" Write-Log "Executing eBPF kernel mode multi-threaded stress tests (restart extension:$RestartExtension)." @@ -271,7 +272,7 @@ function Invoke-CICDStressTests throw "*** ERROR *** eBPF kernel mode multi-threaded stress tests FAILED (restart extension:$RestartExtension)" } - popd + Pop-Location } function Invoke-CICDPerformanceTests diff --git a/scripts/vm_run_tests.psm1 b/scripts/vm_run_tests.psm1 index b9f555073d..999c5720be 100644 --- a/scripts/vm_run_tests.psm1 +++ b/scripts/vm_run_tests.psm1 @@ -35,9 +35,8 @@ function Invoke-CICDTestsOnVM [parameter(Mandatory=$True)][string[]] $Options) $WorkingDirectory = "$Env:SystemDrive\$WorkingDirectory" - $TestDirectory = "$env:ProgramFiles\ebpf-for-windows\testing" Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue - Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($TestDirectory, $LogFileName) -Force -WarningAction SilentlyContinue + Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName) -Force -WarningAction SilentlyContinue $TestMode = $TestMode.ToLower() switch ($TestMode) @@ -81,9 +80,8 @@ function Add-eBPFProgramOnVM [Parameter(Mandatory=$True)] [string] $WorkingDirectory, [Parameter(Mandatory=$True)] [string] $LogFileName) $WorkingDirectory = "$Env:SystemDrive\$WorkingDirectory" - $TestDirectory = "$env:ProgramFiles\ebpf-for-windows\testing" Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue - Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($TestDirectory, $LogFileName) -Force -WarningAction SilentlyContinue + Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName) -Force -WarningAction SilentlyContinue if ([System.String]::IsNullOrEmpty($Interface)){ Write-Log "Loading $Program on $VM." @@ -116,9 +114,8 @@ function Set-eBPFProgramOnVM [Parameter(Mandatory=$True)] [string] $WorkingDirectory, [Parameter(Mandatory=$True)] [string] $LogFileName) $WorkingDirectory = "$Env:SystemDrive\$WorkingDirectory" - $TestDirectory = "$env:ProgramFiles\ebpf-for-windows\testing" Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue - Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($TestDirectory, $LogFileName) -Force -WarningAction SilentlyContinue + Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($TestDWorkingDirectoryirectory, $LogFileName) -Force -WarningAction SilentlyContinue Write-Log "Setting program $ProgId at interface $Interface on $VM." Invoke-NetshEbpfCommand -Arguments "set program $ProgId xdp_test interface=""$Interface""" @@ -139,7 +136,6 @@ function Remove-eBPFProgramFromVM [Parameter(Mandatory=$True)] [string] $WorkingDirectory, [Parameter(Mandatory=$True)] [string] $LogFileName) $WorkingDirectory = "$Env:SystemDrive\$WorkingDirectory" - $TestDirectory = "$env:ProgramFiles\ebpf-for-windows\testing" Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName) -Force -WarningAction SilentlyContinue