feat(P01): orca init full bootstrap + schema 0006
orca init transforms from a bare mkdir into a full single-node cluster bootstrap. After `orca init`, `orca doctor` passes with zero FAILs on the bootstrap checks (CA, cert, db, localhost node). Changes: - migration 0006: nodes.kind + nodes.os nullable columns (REQ-049) - model.Node: Kind + OS fields + NodeKind constants (localhost|linux|proxmox) - NodeRepo: extended Insert/Get/List/Watch/scanNode for kind/os columns (NULL -> "" mapping); added GetByName + UpdateLastSeenAndOS helpers - internal/cli/osdetect.go: detectOS() from /etc/os-release ID= field (D-032); fallback to /usr/lib/os-release then "linux" - internal/cli/init.go: full bootstrap sequence (REQ-047, REQ-048): 1. MkdirAll namespace dir 2. store.Open (runs migrations 0001..0006) 3. security.CAInit (idempotent fast-path) 4. server cert gen if absent (D-036: skip if present) 5. detectOS from /etc/os-release 6. localhost node upsert (insert if new, refresh last_seen+os if exists) Idempotent re-run: no duplicate node, no cert regen, id/joined_at preserved - --json output: full bootstrap summary (namespace, db, ca_fp, cert_fp, os, node_id, steps array) - tests: init idempotency, osdetect parsing (ubuntu/debian/alpine/pve), kind/os round-trip, NULL->"" mapping, GetByName, UpdateLastSeenAndOS E2E smoke test: orca init -> 5 PASS / 0 WARN / 1 FAIL (network=daemon not running, expected); orca node list shows localhost node (os=ubuntu). ---ci--- project: orca phase: 1 milestone: v0.6 status: execute ---/ci---
This commit is contained in:
@@ -98,15 +98,23 @@ func TestInitJSONOutput(t *testing.T) {
|
||||
t.Fatalf("init --json: %v", err)
|
||||
}
|
||||
|
||||
var result map[string]string
|
||||
// v0.6: init --json now outputs a full bootstrap summary object.
|
||||
var result map[string]any
|
||||
if err := json.Unmarshal(bytes.TrimSpace(buf.Bytes()), &result); err != nil {
|
||||
t.Fatalf("unmarshal init output: %v\noutput: %s", err, buf.String())
|
||||
}
|
||||
if result["path"] != tmp {
|
||||
t.Errorf("init --json path = %q, want %q", result["path"], tmp)
|
||||
if result["namespace"] != tmp {
|
||||
t.Errorf("init --json namespace = %q, want %q", result["namespace"], tmp)
|
||||
}
|
||||
if result["status"] != "initialized" {
|
||||
t.Errorf("init --json status = %q, want %q", result["status"], "initialized")
|
||||
if result["os"] == nil || result["os"] == "" {
|
||||
t.Errorf("init --json os is missing/empty")
|
||||
}
|
||||
if result["node_id"] == nil || result["node_id"] == "" {
|
||||
t.Errorf("init --json node_id is missing/empty")
|
||||
}
|
||||
steps, ok := result["steps"].([]any)
|
||||
if !ok || len(steps) < 6 {
|
||||
t.Errorf("init --json steps: expected 6+ entries, got %v", result["steps"])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user