Files
orca/cloud/dev/scripts/relay-load-region-behavior.mjs
T
Jinwoo Hong 3eec77c11a chore(cloud): add the relay fence broker, ops console, Terraform root, scripts, and 24 cloud-* workflows (#18413)
Phase 6 of the relay split: the relay's deploy/operate surface moves under cloud/ with 24 cloud-* workflows gated on ORCA_CLOUD_OPERATIONS_ENABLED, the Cloud SQL rollout lease action, the relay Terraform root (dual-accept identities for both repositories), scripts, docs, CODEOWNERS, and a terraform validate job in Cloud Verify.
2026-09-03 06:55:14 -04:00

36 lines
1.1 KiB
JavaScript

const ASSIGNMENT_RETRY_DELAY_MS = 5_100
const waitPastAssignmentRateLimit = (schedule) =>
new Promise((resolve) => schedule(resolve, ASSIGNMENT_RETRY_DELAY_MS))
export async function proveRelayLoadRegionBehavior({
oldClientPeer,
stickyPeer,
asiaOrigin,
scheduleAssignmentRetry = setTimeout
}) {
try {
await oldClientPeer.connect()
if (!oldClientPeer.assignedCellUrl() || oldClientPeer.assignedCellUrl() === asiaOrigin) {
throw new Error('unhinted client did not use the US-first path')
}
} finally {
await oldClientPeer.shutdown()
}
try {
await stickyPeer.connect()
if (stickyPeer.assignedCellUrl() !== asiaOrigin) {
throw new Error('preferred Asia client did not reach the Asia cell')
}
await waitPastAssignmentRateLimit(scheduleAssignmentRetry)
const reassigned = await stickyPeer.requestAssignment('us-central1')
if (reassigned.cellUrl !== asiaOrigin) {
throw new Error('valid sticky assignment moved after preference changed')
}
} finally {
await stickyPeer.shutdown()
}
return { oldClientUsFirst: true, stickyAssignmentPreserved: true }
}