- Fix bidirectional stream handling: responder uses accept_bi() instead of open_bi() so both sides communicate on the same stream - Add live_receive_loop to accept incoming bi-streams during ongoing sync (peer's push loop opens new streams per batch) - Split live_sync_loop into live_push_loop + live_receive_loop running concurrently via tokio::select in new run_live_sync() - Update handle_incoming to run live sync after initial reconciliation - Add direct peer connection via ticket files (EndpointAddr JSON exchange) for local testing without gossip bootstrap - Add CAN_PORT env var override for running multiple CAN instances - Add integration test binary (sync_test.rs): starts 2 CAN services + 2 sync agents, ingests files on each side, verifies bidirectional sync with 4 test cases (A→B, B→A, batch, count match) - Add PowerShell script (run-integration-test.ps1) for one-command test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.2 KiB
PowerShell
76 lines
2.2 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
# CAN Sync v2 Integration Test Runner
|
|
#
|
|
# Usage:
|
|
# .\run-integration-test.ps1 # Build + run test
|
|
# .\run-integration-test.ps1 -NoBuild # Skip building, just run
|
|
|
|
param(
|
|
[switch]$NoBuild
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$canServiceRoot = Resolve-Path (Join-Path $PSScriptRoot "../..")
|
|
$canSyncRoot = $PSScriptRoot
|
|
|
|
Write-Host ""
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host " CAN Sync v2 - Integration Test Runner" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Step 1: Build CAN service
|
|
if (-not $NoBuild) {
|
|
Write-Host "[1/3] Building CAN service..." -ForegroundColor Yellow
|
|
Push-Location $canServiceRoot
|
|
try {
|
|
cargo build 2>&1 | ForEach-Object { Write-Host " $_" -ForegroundColor DarkGray }
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "FAILED: CAN service build failed!" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host " CAN service built OK" -ForegroundColor Green
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|
|
# Step 2: Build can-sync + sync-test
|
|
Write-Host ""
|
|
Write-Host "[2/3] Building can-sync and sync-test..." -ForegroundColor Yellow
|
|
Push-Location $canSyncRoot
|
|
try {
|
|
cargo build --bin can-sync --bin sync-test 2>&1 | ForEach-Object { Write-Host " $_" -ForegroundColor DarkGray }
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "FAILED: can-sync build failed!" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host " can-sync built OK" -ForegroundColor Green
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
} else {
|
|
Write-Host "[SKIP] Builds skipped (-NoBuild)" -ForegroundColor DarkYellow
|
|
}
|
|
|
|
# Step 3: Run integration test
|
|
Write-Host ""
|
|
Write-Host "[3/3] Running integration test..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
Push-Location $canSyncRoot
|
|
try {
|
|
cargo run --bin sync-test
|
|
$testResult = $LASTEXITCODE
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($testResult -eq 0) {
|
|
Write-Host "ALL TESTS PASSED" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "SOME TESTS FAILED (exit code: $testResult)" -ForegroundColor Red
|
|
}
|
|
|
|
exit $testResult
|