Fix Windows CI test failures (bd-99)

- Fix PID detection: Open lock file with O_RDWR for Windows LockFileEx
- Fix script tests: Increase timeout to 2-5s for Windows process startup
- Fix uptime test: Use math.Ceil with minimum 1 second to prevent flakiness
- Fix socket cleanup: Add done channel to wait for Start() cleanup completion

All 5 failing Windows tests should now pass.
This commit is contained in:
Steve Yegge
2025-10-24 10:07:05 -07:00
parent 58ea4548fa
commit 09e51b2184
5 changed files with 49 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package rpc
import (
"math"
"runtime"
"sort"
"sync"
@@ -112,6 +113,12 @@ func (m *Metrics) Snapshot(cacheHits, cacheMisses int64, cacheSize, activeConns
// Compute statistics outside the lock
uptime := time.Since(m.startTime)
// Round up uptime and enforce minimum of 1 second if any time has passed
// This prevents flaky tests on fast systems (especially Windows VMs)
uptimeSeconds := math.Ceil(uptime.Seconds())
if uptime > 0 && uptimeSeconds == 0 {
uptimeSeconds = 1
}
// Calculate per-operation stats
operations := make([]OperationMetrics, 0, len(opsSet))
@@ -152,7 +159,7 @@ func (m *Metrics) Snapshot(cacheHits, cacheMisses int64, cacheSize, activeConns
return MetricsSnapshot{
Timestamp: time.Now(),
UptimeSeconds: uptime.Seconds(),
UptimeSeconds: uptimeSeconds,
Operations: operations,
CacheHits: cacheHits,
CacheMisses: cacheMisses,