feat(benchmark): add static IP support to Measure-CIBenchmark
- Add -StaticIP/-Netmask/-Gateway params; injects guestinfo into cloned VMX before start, mirroring job.py _inject_guestinfo_ip behaviour - Add -GuestInfoOnly switch to Get-GuestIPAddress: skips vmrun getGuestIPAddress fallback to prevent race where transient DHCP address is returned before ci-static-ip.ps1 finishes reconfiguring the NIC - Benchmark passes -GuestInfoOnly automatically when -StaticIP is set - staticIP field added to benchmark.jsonl for DHCP vs static comparison Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+19
-10
@@ -254,10 +254,16 @@ function Get-GuestIPAddress {
|
||||
param(
|
||||
[Parameter(Mandatory)] [string] $VmrunPath,
|
||||
[Parameter(Mandatory)] [string] $VmxPath,
|
||||
[int] $TimeoutSeconds = 120
|
||||
[int] $TimeoutSeconds = 120,
|
||||
# When set, skip vmrun getGuestIPAddress fallback and poll only
|
||||
# guestinfo.ci-ip. Use when guestinfo.ip-assignment was injected into
|
||||
# the VMX — avoids returning a transient DHCP address before
|
||||
# ci-static-ip.ps1 has finished reconfiguring the NIC.
|
||||
[switch] $GuestInfoOnly
|
||||
)
|
||||
|
||||
Write-Host "[Get-GuestIPAddress] Polling for VM IP (max ${TimeoutSeconds}s)..."
|
||||
$modeLabel = if ($GuestInfoOnly) { 'guestinfo only' } else { 'guestinfo + getGuestIPAddress' }
|
||||
Write-Host "[Get-GuestIPAddress] Polling for VM IP (max ${TimeoutSeconds}s, mode: $modeLabel)..."
|
||||
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
||||
$attempt = 0
|
||||
|
||||
@@ -279,15 +285,18 @@ function Get-GuestIPAddress {
|
||||
return $ipOut
|
||||
}
|
||||
|
||||
# Fallback: vmrun getGuestIPAddress (VMware Tools / open-vm-tools required).
|
||||
$savedEap = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
|
||||
$ipOut2 = (& $VmrunPath -T ws getGuestIPAddress $VmxPath 2>&1).Trim()
|
||||
$ipRc2 = $LASTEXITCODE
|
||||
$ErrorActionPreference = $savedEap
|
||||
# Fallback: vmrun getGuestIPAddress — skipped when GuestInfoOnly is set
|
||||
# to avoid returning a transient DHCP address during static-IP reconfiguration.
|
||||
if (-not $GuestInfoOnly) {
|
||||
$savedEap = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
|
||||
$ipOut2 = (& $VmrunPath -T ws getGuestIPAddress $VmxPath 2>&1).Trim()
|
||||
$ipRc2 = $LASTEXITCODE
|
||||
$ErrorActionPreference = $savedEap
|
||||
|
||||
if ($ipRc2 -eq 0 -and $ipOut2 -match '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') {
|
||||
Write-Host "[Get-GuestIPAddress] IP via getGuestIPAddress: $ipOut2"
|
||||
return $ipOut2
|
||||
if ($ipRc2 -eq 0 -and $ipOut2 -match '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') {
|
||||
Write-Host "[Get-GuestIPAddress] IP via getGuestIPAddress: $ipOut2"
|
||||
return $ipOut2
|
||||
}
|
||||
}
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
Reference in New Issue
Block a user