Skip to content

Commit 5324389

Browse files
committed
fix driver test jobs.
1 parent ce6c3c5 commit 5324389

File tree

9 files changed

+323
-299
lines changed

9 files changed

+323
-299
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ jobs:
246246
if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch')
247247
uses: ./.github/workflows/reusable-test.yml
248248
strategy:
249+
fail-fast: false
249250
matrix:
250251
image:
251252
- 'server2022'

.github/workflows/reusable-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ jobs:
187187

188188
- name: Cache nuget packages
189189
if: steps.skip_check.outputs.should_skip != 'true'
190+
continue-on-error: true
190191
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
191192
env:
192193
cache-name: cache-nuget-modules

docs/remote-vm-setup.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
1-
# Running Scripts on a Remote VM
1+
# Running CI/CD Scripts on a Remote VM
22

3-
This guide explains how to set up and run eBPF for Windows CI/CD scripts on a remote VM.
3+
This guide explains how to set up and run eBPF for Windows CI/CD scripts on a remote VM using [WinRM](https://learn.microsoft.com/en-us/windows/win32/winrm/portal).
44

55
---
66

7-
## 1. Prepare the Remote VM
7+
## Prepare the Remote VM
88

99
Set the execution policy and run the setup script as Administrator:
1010

1111
```powershell
1212
Set-ExecutionPolicy Unrestricted -Force
1313
.\setup_remote_vm.ps1
1414
```
15+
Post reboot run `winrm quickconfig` and take a snapshot of the VM.
1516

1617
---
1718

18-
## 2. Ensure Remote VM is Reachable
19+
## Start WinRM service on the local host
20+
```cmd
21+
sc.exe start winrm
22+
```
23+
24+
## Ensure Remote VM is Reachable
1925

2026
On your host machine, verify that the remote VM is reachable and that WinRM is running by executing:
2127

2228
```powershell
2329
Test-WSMan <remote-vm-ip>
2430
```
2531

26-
If this command fails, ensure the VM is powered on, network connectivity is working, and WinRM is enabled. Running `winrm quickconfig` on the remote VM can help identify and fix common WinRM setup issues.
32+
If this command fails, ensure the VM is powered on, network connectivity is working, and WinRM is enabled.
2733

2834
---
2935

30-
## 2.1. Add Remote VM to Trusted Hosts
36+
## Add Remote VM to Trusted Hosts
3137

3238
On your host machine, allow connections to the remote VM by adding its IP address to the list of trusted hosts:
3339

@@ -36,7 +42,7 @@ Set-Item WSMan:\localhost\Client\TrustedHosts -Value "<remote-vm-ip>"
3642
```
3743
---
3844

39-
## 3. Store VM Credentials on the Host
45+
## Store VM Credentials on the Host
4046

4147
On your host machine, save the VM administrator and standard user credentials using the `CredentialManager` module:
4248

@@ -52,7 +58,7 @@ New-StoredCredential -Target TEST_VM_STANDARD -Username <VM Standard User Name>
5258
5359
---
5460

55-
## 4. Prepare the Build Artifacts
61+
## Prepare the Build Artifacts
5662

5763
1. **Navigate to the Build Directory**
5864

@@ -62,7 +68,7 @@ New-StoredCredential -Target TEST_VM_STANDARD -Username <VM Standard User Name>
6268
cd .\x64\Release
6369
```
6470

65-
2. **Edit `test_execution.json`**
71+
1. **Edit `test_execution.json`**
6672

6773
Update the `VMMap` section to specify your test VM.
6874
Example:
@@ -86,15 +92,15 @@ New-StoredCredential -Target TEST_VM_STANDARD -Username <VM Standard User Name>
8692
8793
---
8894

89-
## 5. Run the CI/CD Setup Script
95+
## Run the CI/CD Setup Script
9096

9197
1. **Run the Setup Script**
9298

9399
```powershell
94100
.\setup_ebpf_cicd_tests.ps1 -VMIsRemote
95101
```
96102

97-
3. **Run the Test Execution Script**
103+
1. **Run the Test Execution Script**
98104

99105
```powershell
100106
.\execute_ebpf_cicd_tests.ps1 -VMIsRemote

scripts/common.psm1

Lines changed: 78 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,14 @@ function Wait-TestJobToComplete
381381
$TestVMName = $VMList[0].Name
382382

383383
try {
384-
Write-Host "Running kernel tests on $TestVMName has timed out after one hour" -ForegroundColor Yellow
384+
Write-Host "Running kernel test job on $TestVMName has timed out after $($TestJobTimeout / 60) minutes." -ForegroundColor Yellow
385385
Write-Log "Generating kernel dump due to test timeout on $TestVMName"
386386

387387
Import-Module "$PSScriptRoot\vm_run_tests.psm1" -ArgumentList @(
388-
$false, # ExecuteOnHost
389-
$true, # ExecuteOnVM
390-
$VMIsRemote, # VMIsRemote
391-
$TestVMName, # VMName
388+
$false, # ExecuteOnHost
389+
$true, # ExecuteOnVM
390+
$VMIsRemote, # VMIsRemote
391+
$TestVMName, # VMName
392392
$AdminTestVMCredential.UserName, # Admin
393393
$AdminTestVMCredential.Password, # AdminPassword
394394
$StandardUserTestVMCredential.UserName, # StandardUser
@@ -742,51 +742,6 @@ function Get-ZipFileFromUrl {
742742
}
743743
}
744744

745-
function Get-LegacyRegressionTestArtifacts
746-
{
747-
$ArifactVersionList = @("0.11.0")
748-
$RegressionTestArtifactsPath = "$pwd\regression"
749-
if (Test-Path -Path $RegressionTestArtifactsPath) {
750-
Remove-Item -Path $RegressionTestArtifactsPath -Recurse -Force
751-
}
752-
mkdir $RegressionTestArtifactsPath
753-
754-
# verify Artifacts' folder presense
755-
if (-not (Test-Path -Path $RegressionTestArtifactsPath)) {
756-
$ErrorMessage = "*** ERROR *** Regression test artifacts folder not found: $RegressionTestArtifactsPath)"
757-
Write-Log $ErrorMessage
758-
throw $ErrorMessage
759-
}
760-
761-
# Download regression test artifacts for each version.
762-
foreach ($ArtifactVersion in $ArifactVersionList)
763-
{
764-
Write-Log "Downloading legacy regression test artifacts for version $ArtifactVersion"
765-
$DownloadPath = "$RegressionTestArtifactsPath\$ArtifactVersion"
766-
mkdir $DownloadPath
767-
$ArtifactName = "v$ArtifactVersion/Build-x64-native-only-Release.$ArtifactVersion.zip"
768-
$ArtifactUrl = "https://github.com/microsoft/ebpf-for-windows/releases/download/" + $ArtifactName
769-
770-
for ($i = 0; $i -lt 5; $i++) {
771-
try {
772-
# Download and extract the artifact.
773-
Get-ZipFileFromUrl -Url $ArtifactUrl -DownloadFilePath "$DownloadPath\artifact.zip" -OutputDir $DownloadPath
774-
775-
# Extract the inner zip file.
776-
Expand-Archive -Path "$DownloadPath\build-NativeOnlyRelease.zip" -DestinationPath $DownloadPath -Force
777-
break
778-
} catch {
779-
Write-Log -TraceMessage "Iteration $i failed to download $ArtifactUrl. Removing $DownloadPath" -ForegroundColor Red
780-
Remove-Item -Path $DownloadPath -Force -ErrorAction Ignore
781-
Start-Sleep -Seconds 5
782-
}
783-
}
784-
785-
Move-Item -Path "$DownloadPath\NativeOnlyRelease\cgroup_sock_addr2.sys" -Destination "$RegressionTestArtifactsPath\cgroup_sock_addr2_$ArtifactVersion.sys" -Force
786-
Remove-Item -Path $DownloadPath -Force -Recurse
787-
}
788-
}
789-
790745
function Get-RegressionTestArtifacts
791746
{
792747
param([Parameter(Mandatory=$True)][string] $Configuration,
@@ -875,3 +830,76 @@ function Get-PSExec {
875830
Remove-Item -Path $DownloadPath -Force -Recurse -ErrorAction Ignore
876831
return $psExecPath
877832
}
833+
834+
<#
835+
.SYNOPSIS
836+
Invokes a command on a remote or local VM.
837+
838+
.PARAMETER VMName
839+
The name of the VM.
840+
841+
.PARAMETER VMIsRemote
842+
Indicates if the VM is remote.
843+
844+
.PARAMETER Credential
845+
The credential to use for the VM.
846+
847+
.DESCRIPTION
848+
This function invokes a command on a remote or local VM using the specified credentials.
849+
850+
.PARAMETER ScriptBlock
851+
The script block to execute on the VM.
852+
853+
.PARAMETER ArgumentList
854+
The arguments to pass to the script block.
855+
856+
.EXAMPLE
857+
Invoke-CommandOnVM -VMName "MyVM" -VMIsRemote $true -Credential $credential -ScriptBlock { Get-Process }
858+
#>
859+
function Invoke-CommandOnVM {
860+
param(
861+
[Parameter(Mandatory = $true)][string] $VMName,
862+
[Parameter(Mandatory = $false)][bool] $VMIsRemote = $false,
863+
[Parameter(Mandatory = $true)][PSCredential] $Credential,
864+
[Parameter(Mandatory = $true)][ScriptBlock] $ScriptBlock,
865+
[Parameter(Mandatory = $false)][object[]] $ArgumentList = @()
866+
)
867+
Write-Log "Invoking command on VM: $VMName (IsRemote: $VMIsRemote)"
868+
if ($VMIsRemote) {
869+
Invoke-Command -ComputerName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $ArgumentList -ErrorAction Stop
870+
} else {
871+
Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $ArgumentList -ErrorAction Stop
872+
}
873+
}
874+
875+
<#
876+
.SYNOPSIS
877+
Creates a new PowerShell session on a remote or local VM.
878+
.PARAMETER VMName
879+
The name of the VM.
880+
.PARAMETER VMIsRemote
881+
Indicates if the VM is remote.
882+
.PARAMETER Credential
883+
The credential to use for the VM.
884+
.RETURNS
885+
A new PowerShell session object.
886+
.DESCRIPTION
887+
This function creates a new PowerShell session on a remote or local VM using the specified credentials
888+
.EXAMPLE
889+
$session = New-SessionOnVM -VMName "MyVM" -VMIsRemote $true -Credential $credential
890+
#>
891+
function New-SessionOnVM {
892+
param(
893+
[Parameter(Mandatory = $true)][string] $VMName,
894+
[Parameter(Mandatory = $false)][bool] $VMIsRemote = $false,
895+
[Parameter(Mandatory = $true)][PSCredential] $Credential
896+
)
897+
$session = $null
898+
Write-Log "Creating new session on VM: $VMName (IsRemote: $VMIsRemote)"
899+
if ($VMIsRemote) {
900+
$session = New-PSSession -ComputerName $VMName -Credential $Credential -ErrorAction Stop
901+
} else {
902+
$session = New-PSSession -VMName $VMName -Credential $Credential -ErrorAction Stop
903+
}
904+
return $session
905+
}

0 commit comments

Comments
 (0)