e544d58d16
Replace generic publicIp state/provider fields with publicIpv4 and publicIpv6, derive provider IPv6 addresses from prefixes using ::73be, and update provider, DNS, firewall, deployment, CLI, renderer, and tests accordingly.
94 lines
2.3 KiB
TypeScript
94 lines
2.3 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import test from "node:test"
|
|
|
|
import { canPollManagedNode } from "../../src/main/managed-node-polling"
|
|
import type { NodeExecutionPhase, VpsRecord } from "../../src/shared/app"
|
|
|
|
const NOW = "2026-06-25T12:00:00.000Z"
|
|
|
|
test("managed node polling requires a proven managed node public key", () => {
|
|
assert.equal(canPollManagedNode(createServer({ nodePublicKey: "node-pubkey" })), true)
|
|
assert.equal(canPollManagedNode(createServer()), false)
|
|
})
|
|
|
|
test("managed node polling skips active install phases before readiness", () => {
|
|
assert.equal(
|
|
canPollManagedNode(
|
|
createServer({
|
|
nodePublicKey: "node-pubkey",
|
|
executionPhase: "post-install-tribes"
|
|
})
|
|
),
|
|
false
|
|
)
|
|
assert.equal(
|
|
canPollManagedNode(
|
|
createServer({
|
|
nodePublicKey: "node-pubkey",
|
|
executionPhase: "waiting-ready"
|
|
})
|
|
),
|
|
true
|
|
)
|
|
})
|
|
|
|
test("managed node polling skips non-running provider states", () => {
|
|
assert.equal(
|
|
canPollManagedNode(
|
|
createServer({
|
|
nodePublicKey: "node-pubkey",
|
|
status: "stopped"
|
|
})
|
|
),
|
|
false
|
|
)
|
|
})
|
|
|
|
function createServer(
|
|
input: {
|
|
nodePublicKey?: string
|
|
executionPhase?: NodeExecutionPhase
|
|
status?: VpsRecord["status"]
|
|
} = {}
|
|
): VpsRecord {
|
|
return {
|
|
id: "server-1",
|
|
provider: "hetzner",
|
|
providerServerId: "42",
|
|
providerResourceName: "server-1",
|
|
role: "primary",
|
|
sshUsername: "root",
|
|
sshPrivateKey: "PRIVATE",
|
|
status: input.status ?? "running",
|
|
publicIpv4: "203.0.113.10",
|
|
region: "fsn1",
|
|
planName: "cx23",
|
|
commercialMetadata: { effectiveMonthlyGrossEur: 5, source: "provider", notes: [] },
|
|
deployment: {
|
|
status: input.executionPhase ? "running" : "ready",
|
|
snippets: []
|
|
},
|
|
managedBootstrap: {
|
|
nodePrivateKey: "1".repeat(64),
|
|
nodePublicKey: input.nodePublicKey,
|
|
nodeName: "server-1",
|
|
publicIpv4: "203.0.113.10",
|
|
publicPort: 443,
|
|
publicScheme: "https"
|
|
},
|
|
execution: input.executionPhase
|
|
? {
|
|
operationId: "operation-1",
|
|
operation: "add",
|
|
status: "running",
|
|
phase: input.executionPhase,
|
|
retryable: false,
|
|
startedAt: NOW,
|
|
updatedAt: NOW
|
|
}
|
|
: undefined,
|
|
createdAt: NOW,
|
|
updatedAt: NOW
|
|
}
|
|
}
|