Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NuGet runtime tests #795

Merged
merged 9 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure/onebranch.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ stages:
osName: ${{os}}
timeoutInMinutes: ${{ variables.functionalRuntime }}
iterations: ${{ variables.functionalIterations }}
xdpInstaller: NuGet

- stage: stress_${{os}}_${{platform}}_${{config}}
displayName: Stress ${{os}} (${{platform}}_${{config}})
Expand All @@ -81,3 +82,4 @@ stages:
xdpmpPollProvider: NDIS
${{ if ne(os, 'Prerelease') }}:
xdpmpPollProvider: FNDIS
xdpInstaller: NuGet
3 changes: 3 additions & 0 deletions .azure/templates/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:

- task: NuGetCommand@2
displayName: Nuget Restore
env:
NUGET_RESTORE_MSBUILD_ARGS: /p:IsAdmin=true /p:Platform=${{ parameters.platform }} /p:Configuration=${{ parameters.config }}
inputs:
restoreSolution: xdp.sln
feedsToUse: config
Expand All @@ -64,6 +66,7 @@ jobs:
platform: ${{ parameters.platform }}
configuration: ${{ parameters.config }}
msbuildArgs: -m /p:SignMode=TestSign /p:IsAdmin=true
msBuildArchitecture: x64

- task: CopyFiles@2
displayName: Filter Artifacts
Expand Down
4 changes: 3 additions & 1 deletion .azure/templates/spinxsk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ parameters:
- name: xdpmpPollProvider
default: 'NDIS'
- name: osName
- name: xdpInstaller
default: 'MSI'

jobs:
- job: spinxsk__${{ parameters.platform }}_${{ parameters.config }}_${{ parameters.osName }}_${{ replace(parameters.pool, '-', '_') }}
Expand Down Expand Up @@ -73,7 +75,7 @@ jobs:
arguments: -Config ${{ parameters.config }} -Platform ${{ parameters.platform }} -QueueCount 2
-Minutes ${{ parameters.runtimeMinutes }} -XdpmpPollProvider ${{ parameters.xdpmpPollProvider }}
-Verbose -Stats -SuccessThresholdPercent ${{ parameters.successThresholdPercent }}
-EnableEbpf
-EnableEbpf -XdpInstaller ${{ parameters.xdpInstaller }}

- task: PowerShell@2
displayName: Convert logs
Expand Down
3 changes: 2 additions & 1 deletion .azure/templates/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parameters:
timeoutInMinutes: 10
iterations: 1
osName:
xdpInstaller: 'MSI'

jobs:
- job: tests_${{ parameters.platform }}_${{ parameters.config }}_${{ parameters.osName }}_${{ replace(parameters.pool, '-', '_') }}
Expand Down Expand Up @@ -48,7 +49,7 @@ jobs:
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
inputs:
filePath: tools/functional.ps1
arguments: -Verbose -Config ${{ parameters.config }} -Platform ${{ parameters.platform }} -Iterations ${{ parameters.iterations }} -Timeout ${{ parameters.timeoutInMinutes }}
arguments: -Verbose -Config ${{ parameters.config }} -Platform ${{ parameters.platform }} -Iterations ${{ parameters.iterations }} -Timeout ${{ parameters.timeoutInMinutes }} -XdpInstaller ${{ parameters.xdpInstaller }}

- task: PowerShell@2
displayName: Convert Logs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ jobs:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
shell: PowerShell
timeout-minutes: 20
run: tools/spinxsk.ps1 -Verbose -Stats -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Minutes ${{ env.prRuntime }} -XdpmpPollProvider ${{ env.xdpmpPollProvider }} -SuccessThresholdPercent ${{ env.successThresholdPercent }} -EnableEbpf
run: tools/spinxsk.ps1 -Verbose -Stats -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Minutes ${{ env.prRuntime }} -XdpmpPollProvider ${{ env.xdpmpPollProvider }} -SuccessThresholdPercent ${{ env.successThresholdPercent }} -EnableEbpf -XdpInstaller NuGet
- name: Run spinxsk (main)
if: ${{ github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch'}}
shell: PowerShell
timeout-minutes: 70
run: tools/spinxsk.ps1 -Verbose -Stats -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Minutes ${{ env.fullRuntime }} -XdpmpPollProvider ${{ env.xdpmpPollProvider }} -SuccessThresholdPercent ${{ env.successThresholdPercent }} -EnableEbpf
run: tools/spinxsk.ps1 -Verbose -Stats -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Minutes ${{ env.fullRuntime }} -XdpmpPollProvider ${{ env.xdpmpPollProvider }} -SuccessThresholdPercent ${{ env.successThresholdPercent }} -EnableEbpf -XdpInstaller NuGet
- name: Convert Logs
if: ${{ always() }}
timeout-minutes: 15
Expand Down
8 changes: 8 additions & 0 deletions src/nuget/nuget.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,13 @@
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Target Name="CleanNuget" BeforeTargets="Clean" Condition="$(BuildStage) == '' OR $(BuildStage) == 'AllPackage'">
<ItemGroup>
<FilesToDelete Include="$(OutDir)XDP-for-Windows.*.nupkg"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)">
<Output TaskParameter="DeletedFiles" ItemName="FilesDeleted"/>
</Delete>
</Target>
<Import Project="$(SolutionDir)src\xdp.targets" />
</Project>
8 changes: 8 additions & 0 deletions src/xdpruntime/xdpruntime.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
<Target Name="SignBinaries" DependsOnTargets="CopyBinaries" BeforeTargets="Build" Condition="$(SignMode) != 'Off' and $(BuildStage) != 'Package'">
<Exec Command="powershell.exe /c &quot;&amp; '$(DriverSignToolPath)signtool.exe' sign /sha1 ([system.security.cryptography.x509certificates.x509certificate2]::new([System.IO.File]::ReadAllBytes('$(OutDir)xdp\xdp.sys'))).Thumbprint /fd sha256 $(OutDir)xdp-setup.ps1&quot;" />
</Target>
<Target Name="CleanNuget" BeforeTargets="Clean" Condition="$(BuildStage) == '' OR $(BuildStage) == 'Package'">
<ItemGroup>
<FilesToDelete Include="$(OutDir)XDP-for-Windows-Runtime.$(Platform).*.nupkg"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)">
<Output TaskParameter="DeletedFiles" ItemName="FilesDeleted"/>
</Delete>
</Target>
<Target Name="BuildNuget" AfterTargets="Build" Condition="$(BuildStage) != 'Binary'">
<Exec Command="powershell.exe /c &quot;$(SolutionDir)tools\update-nuspec.ps1 -InputFile xdp-for-windows-runtime.nuspec.in -OutputFile $(IntDir)xdp-for-windows-runtime.nuspec -Platform $(Platform) -Config $(Configuration)&quot;" />
<Exec Command="NuGet.exe pack $(IntDir)xdp-for-windows-runtime.nuspec -OutputDirectory $(OutDir) -BasePath $(ProjectDir) -Properties NoWarn=NU5100,NU5110,NU5111" />
Expand Down
2 changes: 1 addition & 1 deletion tools/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Get-VsTestPath {

# Returns the XDP installation path
function Get-XdpInstallPath {
return "$($env:SystemDrive)\xdpmsi"
return "$($env:SystemDrive)\xdpruntime"
}

# Returns the eBPF installation path
Expand Down
10 changes: 7 additions & 3 deletions tools/functional.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ param (
[string]$TestBinaryPath = "",

[Parameter(Mandatory = $false)]
[switch]$NoPrerelease = $false
[switch]$NoPrerelease = $false,

[Parameter(Mandatory = $false)]
[ValidateSet("MSI", "INF", "NuGet")]
[string]$XdpInstaller = "MSI"
)

Set-StrictMode -Version 'Latest'
Expand Down Expand Up @@ -98,7 +102,7 @@ for ($i = 1; $i -le $Iterations; $i++) {
}

Write-Verbose "installing xdp..."
& "$RootDir\tools\setup.ps1" -Install xdp -Config $Config -Platform $Platform -EnableEbpf
& "$RootDir\tools\setup.ps1" -Install xdp -Config $Config -Platform $Platform -EnableEbpf -XdpInstaller $XdpInstaller
Write-Verbose "installed xdp."

Write-Verbose "installing fnmp..."
Expand Down Expand Up @@ -168,7 +172,7 @@ for ($i = 1; $i -le $Iterations; $i++) {
& "$RootDir\tools\setup.ps1" -Uninstall fnsock -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall fnlwf -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall fnmp -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall xdp -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall xdp -Config $Config -Platform $Platform -XdpInstaller $XdpInstaller -ErrorAction 'Continue'
if (!$EbpfPreinstalled) {
& "$RootDir\tools\setup.ps1" -Uninstall ebpf -Config $Config -Platform $Platform -ErrorAction 'Continue'
}
Expand Down
65 changes: 64 additions & 1 deletion tools/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ param (
[string]$XdpmpPollProvider = "NDIS",

[Parameter(Mandatory = $false)]
[ValidateSet("MSI", "INF")]
[ValidateSet("MSI", "INF", "NuGet")]
[string]$XdpInstaller = "MSI",

[Parameter(Mandatory = $false)]
Expand Down Expand Up @@ -74,6 +74,7 @@ $XdpFileVersion = (Get-Item $XdpSys).VersionInfo.FileVersion
# format is "A.B.C.D", but XDP (and semver) use only the "A.B.C".
$XdpFileVersion = $XdpFileVersion.substring(0, $XdpFileVersion.LastIndexOf('.'))
$XdpMsiFullPath = "$ArtifactsDir\xdp-for-windows.$Platform.$XdpFileVersion.msi"
$XdpRuntimeNupkgSetupPath = "runtime/native/xdp-setup.ps1"
$FndisSys = "$ArtifactsDir\test\fndis\fndis.sys"
$XdpMpSys = "$ArtifactsDir\test\xdpmp\xdpmp.sys"
$XdpMpInf = "$ArtifactsDir\test\xdpmp\xdpmp.inf"
Expand Down Expand Up @@ -173,6 +174,25 @@ function Cleanup-Service($Name) {
}
}

# Returns the only nupkg matching the pattern, otherwise throws an error.
function Find-Nupkg($Pattern) {
$Nupkg = @(Get-ChildItem -Path $Pattern)
if ($Nupkg.Count -ne 1) {
Write-Error "Expected exactly one nupkg matching $Pattern, but found $Nupkg"
}
return $Nupkg.FullName
}

# Extracts a NuGet package to a directory.
function Expand-Nupkg($Nupkg, $Dir) {
$NupkgZip = "$Nupkg.zip"
Write-Verbose "Expanding $Nupkg to $Dir"
Remove-Item -Path $Dir -Recurse -Force -ErrorAction Ignore | Write-Verbose
Copy-Item -Path $Nupkg -Destination $NupkgZip
Expand-Archive -Path $NupkgZip -DestinationPath $Dir
Remove-Item -Path $NupkgZip
}

# Installs the certificates for driver package signing.
function Install-DriverCertificate($CertFileName) {
Write-Verbose "Installing driver signing certificate $CertFileName"
Expand Down Expand Up @@ -284,6 +304,23 @@ function Install-Xdp {
if ($LastExitCode -ne 0) {
Write-Error "XDP MSI installation failed: $LastExitCode"
}
} elseif ($XdpInstaller -eq "NuGet") {
$XdpPath = Get-XdpInstallPath
$XdpSetupPath = "$XdpPath/$XdpRuntimeNupkgSetupPath"
$XdpRuntimeNupkgFullPath = Find-Nupkg "$ArtifactsDir\XDP-for-Windows-Runtime.$Platform.$XdpFileVersion*.nupkg"

Expand-Nupkg $XdpRuntimeNupkgFullPath $XdpPath | Write-Verbose

Write-Verbose "$XdpSetupPath -Install xdp"
& $XdpSetupPath -Install xdp | Write-Verbose
if ($PaLayer) {
Write-Verbose "$XdpSetupPath -Install xdppa"
& $XdpSetupPath -Install xdppa | Write-Verbose
}
if ($EnableEbpf) {
Write-Verbose "$XdpSetupPath -Install xdpebpf"
& $XdpSetupPath -Install xdpebpf | Write-Verbose
}
} elseif ($XdpInstaller -eq "INF") {
Write-Verbose "netcfg.exe -v -l $XdpInf -c s -i ms_xdp"
netcfg.exe -v -l $XdpInf -c s -i ms_xdp | Write-Verbose
Expand Down Expand Up @@ -363,6 +400,32 @@ function Uninstall-Xdp {
Write-Error "XDP MSI uninstall failed with status $LastExitCode" -ErrorAction Continue
Uninstall-Failure "xdp_uninstall.dmp"
}
} elseif ($XdpInstaller -eq "NuGet") {
$XdpPath = Get-XdpInstallPath
$XdpSetupPath = "$XdpPath/$XdpRuntimeNupkgSetupPath"

if (!(Test-Path $XdpPath)) {
Write-Verbose "$XdpPath does not exist. Assuming XDP is not installed."
return
}

if ((Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xdp\Parameters").PSObject.Properties["XdpEbpfEnabled"]) {
Write-Verbose "$XdpSetupPath -Uninstall xdpebpf"
& $XdpSetupPath -Uninstall xdpebpf
}
if (Get-NetAdapterBinding -ComponentID ms_xdp_pa -ErrorAction Ignore) {
Write-Verbose "$XdpSetupPath -Uninstall xdppa"
& $XdpSetupPath -Uninstall xdppa
}
if (Get-NetAdapterBinding -ComponentID ms_xdp -ErrorAction Ignore) {
Write-Verbose "$XdpSetupPath -Uninstall xdp"
& $XdpSetupPath -Uninstall xdp
}

Write-Verbose "Remove-Item $XdpPath -Recurse -Force"
Remove-Item $XdpPath -Recurse -Force

$global:LASTEXITCODE = 0
} elseif ($XdpInstaller -eq "INF") {
Write-Verbose "unlodctr.exe /m:$XdpPcwMan"
unlodctr.exe /m:$XdpPcwMan | Write-Verbose
Expand Down
10 changes: 7 additions & 3 deletions tools/spinxsk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ param (
[switch]$EnableEbpf = $false,

[Parameter(Mandatory = $false)]
[switch]$EbpfPreinstalled = $false
[switch]$EbpfPreinstalled = $false,

[Parameter(Mandatory = $false)]
[ValidateSet("MSI", "INF", "NuGet")]
[string]$XdpInstaller = "MSI"
)

Set-StrictMode -Version 'Latest'
Expand Down Expand Up @@ -145,7 +149,7 @@ while (($Minutes -eq 0) -or (((Get-Date)-$StartTime).TotalMinutes -lt $Minutes))
}

Write-Verbose "installing xdp..."
& "$RootDir\tools\setup.ps1" -Install xdp -Config $Config -Platform $Platform -EnableEbpf:$EnableEbpf
& "$RootDir\tools\setup.ps1" -Install xdp -Config $Config -Platform $Platform -EnableEbpf:$EnableEbpf -XdpInstaller $XdpInstaller
Write-Verbose "installed xdp."

Write-Verbose "installing xdpmp..."
Expand Down Expand Up @@ -189,7 +193,7 @@ while (($Minutes -eq 0) -or (((Get-Date)-$StartTime).TotalMinutes -lt $Minutes))
}
} finally {
& "$RootDir\tools\setup.ps1" -Uninstall xdpmp -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall xdp -Config $Config -Platform $Platform -ErrorAction 'Continue'
& "$RootDir\tools\setup.ps1" -Uninstall xdp -Config $Config -Platform $Platform -XdpInstaller $XdpInstaller -ErrorAction 'Continue'
if (!$EbpfPreinstalled) {
& "$RootDir\tools\setup.ps1" -Uninstall ebpf -Config $Config -Platform $Platform -ErrorAction 'Continue'
}
Expand Down