carlos / platform Public

Merge remote-tracking branch 'origin/fleet-seeded-create-2b' into fleet-seeded-create-2

Paul Campbell pushed by paul@keymail.dev 06be45bdb9cc81a05fe2b0da7bcc6df990d395e6 parent e8a590eparent f5f903a
9 files changed, +385 −2
  • internal/edge/edge.go +1 −1
  • internal/edge/replicaconsole.go +12 −0
  • internal/edge/replicaconsole_test.go +53 −0
  • internal/host/claimreport.go +4 −0
  • internal/host/seedsfloorprobe.go +49 −0
  • internal/host/seedsfloorprobe_root_linux_test.go +90 −0
  • internal/host/seedsfloorprobe_test.go +135 −0
  • internal/status/snapshot.go +23 −1
  • internal/status/snapshot_test.go +18 −0

CI failed — run details

diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index afca1bd0e..734f42043 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -2409,7 +2409,7 @@ func (e *Edge) ServeHTTP(w http.ResponseWriter, r *http.Request) {
e.door.ServeHTTP(w, r)
return
}
- if p := r.URL.Path; r.Method == http.MethodPost && r.URL.RawPath == "" && path.Clean(p) == p && strings.HasPrefix(p, "/api/fleet/replicas/") {
+ if boxConsolePath(r) {
e.serveReplicaConsole(w, r)
return
}
diff --git a/internal/edge/replicaconsole.go b/internal/edge/replicaconsole.go
index 508310010..30d3700ec 100644
--- a/internal/edge/replicaconsole.go
+++ b/internal/edge/replicaconsole.go
@@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httputil"
"net/netip"
+ "path"
"strconv"
"strings"
"time"
@@ -129,3 +130,14 @@ func (e *Edge) serveReplicaConsole(w http.ResponseWriter, r *http.Request) {
}
console.ServeHTTP(w, e.withForwardKey(r))
}
+
+// boxConsolePath: the box doors the hub hands to the local console, POST
+// only, with a clean path and no raw path: /api/fleet/replicas/ and
+// /api/fleet/seeds/ (the seeds door, a box's placed and failed reports).
+func boxConsolePath(r *http.Request) bool {
+ p := r.URL.Path
+ if r.Method != http.MethodPost || r.URL.RawPath != "" || path.Clean(p) != p {
+ return false
+ }
+ return strings.HasPrefix(p, "/api/fleet/replicas/") || strings.HasPrefix(p, "/api/fleet/seeds/")
+}
diff --git a/internal/edge/replicaconsole_test.go b/internal/edge/replicaconsole_test.go
index f665415a6..6f8b2c3bb 100644
--- a/internal/edge/replicaconsole_test.go
+++ b/internal/edge/replicaconsole_test.go
@@ -271,3 +271,56 @@ func TestReplicaConsoleAddrFromHostEnv(t *testing.T) {
t.Fatalf("good value: %v, configured %v", err, e.replicaConsole != nil)
}
}
+
+// TestHubRoutesFleetSeedsToConsole: the seeds door rides the same hub-to-
+// console hand-off as the replica door, POST only, clean paths only.
+func TestHubRoutesFleetSeedsToConsole(t *testing.T) {
+ var hits atomic.Int32
+ console := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ hits.Add(1)
+ w.Header().Set("X-Upstream-Path", r.URL.RequestURI())
+ _, _ = io.WriteString(w, `{}`)
+ }))
+ defer console.Close()
+ reg := openReg(t)
+ rt := registry.Route{Host: "console.test", App: "console", Unit: "console.service", Kind: "service", Addr: console.Listener.Addr().String(), Status: "ready", Version: "v-test"}
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer e.probers.Stop()
+ e.EnableTunnels(NewTunnelHub("tunnel.test", nil))
+ const prefix = "/api/fleet/seeds/a/app/h/"
+ for _, tc := range []struct {
+ method, path string
+ hit bool
+ }{
+ {"POST", prefix + "placed", true},
+ {"POST", prefix + "failed", true},
+ {"GET", prefix + "placed", false},
+ {"POST", "/api/fleet/seeds", false},
+ {"POST", "/api/fleet/seeds-other/a", false},
+ {"POST", "/api/fleet/seeds/../../cli/apps/x", false},
+ {"POST", "//api/fleet/seeds/x", false},
+ {"POST", "/api/fleet/seeds/%2e%2e/x", false},
+ {"POST", "/api/fleet/seeds/a%2Fb/app/h/placed", false},
+ } {
+ t.Run(tc.method+tc.path, func(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ defer cancel()
+ req := httptest.NewRequest(tc.method, "https://tunnel.test"+tc.path, strings.NewReader(`{}`)).WithContext(ctx)
+ before := hits.Load()
+ w := httptest.NewRecorder()
+ e.ServeHTTP(w, req)
+ if got := hits.Load() > before; got != tc.hit {
+ t.Fatalf("console hit = %v, want %v (status %d)", got, tc.hit, w.Code)
+ }
+ if tc.hit && w.Header().Get("X-Upstream-Path") != tc.path {
+ t.Fatalf("upstream path: %q", w.Header().Get("X-Upstream-Path"))
+ }
+ })
+ }
+}
diff --git a/internal/host/claimreport.go b/internal/host/claimreport.go
index b15b53cc6..1e10e07f7 100644
--- a/internal/host/claimreport.go
+++ b/internal/host/claimreport.go
@@ -12,6 +12,10 @@ import (
)
func claimReport(p *status.Probes) {
+ // First, ahead of the early returns below: a box with no host-claim
+ // floor still reports its seeds floor (seeded-create Task 11). The call
+ // lives here so agent.go, at its line ceiling, does not grow.
+ fillSeedsFloorProbe(p)
d, err := floorDisk(release.OptDir())
if err != nil {
return
diff --git a/internal/host/seedsfloorprobe.go b/internal/host/seedsfloorprobe.go
new file mode 100644
index 000000000..ff24f0b15
--- /dev/null
+++ b/internal/host/seedsfloorprobe.go
@@ -0,0 +1,49 @@
+package host
+
+import (
+ "os"
+
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// movesFloorContext is the part of the moves floor the seeds floor's writer
+// depends on: withSeedsFields picks the root path from a non-empty state
+// (seedsfloor.go:58) and the report carries both fields. It is filled first,
+// exactly as the edges file's loop fills it (withMovesFields, then
+// withSeedsFields), never left zero by a caller that only wants the seeds
+// half.
+type movesFloorContext struct {
+ State string
+ Generation uint64
+}
+
+// seedsFloorFields is withSeedsFields' (and withRootSeedsFields') logic as
+// one value, so the edges file and the heartbeat are filled by the same
+// code. box is the identity withRootSeedsFields compares the root
+// projection's box against, and moves is the moves-floor context; both are
+// inputs the writers depend on, so the report is never derived from an
+// empty edgesFile (plan R3-2).
+func seedsFloorFields(dataDir, optDir, box string, moves movesFloorContext) status.SeedsFloorReport {
+ f := withSeedsFields(edgesFile{Box: box, MovesFloorState: moves.State, MovesFloorGeneration: moves.Generation}, dataDir, optDir)
+ return status.SeedsFloorReport{
+ Protocol: f.SeedsProtocol,
+ MinRelease: f.SeedsFloorMinRelease,
+ PrevAllowedFor: f.PrevSeedsAllowedFor,
+ FloorState: f.SeedsFloorState,
+ FloorGeneration: f.SeedsFloorGeneration,
+ MovesFloorState: f.MovesFloorState,
+ MovesFloorGeneration: f.MovesFloorGeneration,
+ }
+}
+
+// fillSeedsFloorProbe sets the status tick's seeds-floor block from this
+// box's own files. The moves context is read the way the edges file loop
+// reads it (withMovesFields first), under the same box label the loop uses.
+func fillSeedsFloorProbe(p *status.Probes) {
+ dd, opt := dataDir(), release.OptDir()
+ box := metricsBoxLabel(os.Getenv, readMachineID())
+ m := withMovesFields(edgesFile{Box: box}, dd, opt)
+ r := seedsFloorFields(dd, opt, box, movesFloorContext{State: m.MovesFloorState, Generation: m.MovesFloorGeneration})
+ p.SeedsFloor = &r
+}
diff --git a/internal/host/seedsfloorprobe_root_linux_test.go b/internal/host/seedsfloorprobe_root_linux_test.go
new file mode 100644
index 000000000..c5d2c02bf
--- /dev/null
+++ b/internal/host/seedsfloorprobe_root_linux_test.go
@@ -0,0 +1,90 @@
+//go:build linux && rootrunner
+
+package host
+
+import (
+ "context"
+ "crypto/ed25519"
+ "encoding/base64"
+ "github.com/carlosframework/platform/internal/moves"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/rootstate"
+ "github.com/carlosframework/platform/internal/seeds"
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+// TestSeedsFloorFieldsBoxIdentityRootRunner is plan R3-2 against a real root
+// projection (the fixtures of TestPlan14RootSeedsFloorRootRunner): one that
+// names this box is accepted, one that names another box is quarantined.
+func TestSeedsFloorFieldsBoxIdentityRootRunner(t *testing.T) {
+ opt := generationRootRunnerDir(t)
+ dd := filepath.Join(opt, "data")
+ if err := os.Mkdir(dd, 0755); err != nil {
+ t.Fatal(err)
+ }
+ id := rootFloorIdentity{"deploy", "box", "en"}
+ pub, key, _ := ed25519.GenerateKey(nil)
+ t.Setenv("CARLOS_RELEASE_PUBKEY", base64.StdEncoding.EncodeToString(pub))
+ t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "deploy")
+ rootFloorSignRunnerBytes(t, opt, systemBinaryPath(opt), "v2.0.0", []byte("#!/bin/sh\nexit 0\n"), key)
+ if false {
+ rootFloorSignRunnerBytes(t, opt, systemPrevPath(opt), "v2.0.0", []byte("#!/bin/sh\nexit 0 #prev\n"), key)
+ }
+ identities, e := rootstate.Open(filepath.Join(opt, "system", "guard", "identities"), false, true)
+ if e != nil {
+ t.Fatal(e)
+ }
+ names, e := identities.Names()
+ if e != nil {
+ t.Fatal(e)
+ }
+ for _, name := range names {
+ raw, e := identities.Read(name)
+ if e != nil {
+ t.Fatal(e)
+ }
+ var p release.SystemPointer
+ if release.VerifyRootEnvelope(pub, raw, &p) != nil {
+ t.Fatal("identity")
+ }
+ p.Current.SeedsProtocol = 1
+ wire, e := release.SignRootEnvelope(release.RootSigner(key), p)
+ if e != nil {
+ t.Fatal(e)
+ }
+ if e := identities.Write(name, wire); e != nil {
+ t.Fatal(e)
+ }
+ }
+ identities.Close()
+ f, err := openRootProtocolFloors(rootSeedsFloorDir(opt), id, true)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.close()
+ a := moves.Floor{Min: 1, MinRelease: "v1.0.0"}
+ if err := f.reconstruct(t.Context(), rootFloorReconstruction{Identity: id, Floor: &a, Source: "root history", Digest: floorTestDigest, Authorization: floorTestAuthorization(t, f)}); err != nil {
+ t.Fatal(err)
+ }
+ j := rootFloorJudge{floors: f, current: systemBinaryPath(opt), prev: systemPrevPath(opt), binary: func(path string) (rootFloorBinary, error) { return readRootSeedsBinary(opt, path) }, idle: func(context.Context) error { return nil }}
+ if err := j.judge(t.Context()); err != nil {
+ t.Fatal(err)
+ }
+ initial, err := release.SignRootEnvelope(release.RootSigner(key), rootSeedsPublication{Schema: 1, Deployment: id.Deployment, Purpose: seeds.FloorKey, Floor: a})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := acceptRootSeedsPublication(t.Context(), f, initial); err != nil {
+ t.Fatal(err)
+ }
+ moved := movesFloorContext{State: "accepted"}
+ if got := seedsFloorFields(dd, opt, id.Box, moved); got.MinRelease != a.MinRelease {
+ t.Fatalf("a projection naming this box was not accepted: %+v", got)
+ }
+ got := seedsFloorFields(dd, opt, "not-"+id.Box, moved)
+ if got.FloorState != "quarantined" || got.MinRelease != "" || got.PrevAllowedFor != "" {
+ t.Fatalf("a projection naming another box = %+v, want quarantined", got)
+ }
+}
diff --git a/internal/host/seedsfloorprobe_test.go b/internal/host/seedsfloorprobe_test.go
new file mode 100644
index 000000000..bb7ab72c0
--- /dev/null
+++ b/internal/host/seedsfloorprobe_test.go
@@ -0,0 +1,135 @@
+package host
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/seeds"
+)
+
+// armSeedsProbeFloor writes a local seeds floor and carlos.prev's verdict
+// (legacy path).
+func armSeedsProbeFloor(t *testing.T, dd, opt, rel string) {
+ t.Helper()
+ // Written directly, not through the floor lock (linux-only): the reader
+ // is what the writers under test call.
+ body, _ := json.Marshal(seeds.Floor{Min: seeds.RequiredProtocol, MinRelease: rel})
+ if err := os.MkdirAll(filepath.Join(dd, filepath.Dir(seeds.FloorFile)), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(dd, seeds.FloorFile), body, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(seedsPrevAllowedPath(opt), []byte(rel+"\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// TestSeedsFloorFieldsSameForEdgesFileAndHeartbeat: the edges file's writer
+// and the heartbeat's report are one code path, armed and not, and with the
+// root guard directory present.
+func TestSeedsFloorFieldsSameForEdgesFileAndHeartbeat(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ arm bool
+ root bool
+ moves movesFloorContext
+ }{
+ {name: "unarmed"},
+ {name: "armed", arm: true},
+ {name: "root guard armed", root: true},
+ {name: "root guard and moves state", root: true, moves: movesFloorContext{State: "accepted", Generation: 5}},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ dd, opt := t.TempDir(), t.TempDir()
+ if tc.arm {
+ armSeedsProbeFloor(t, dd, opt, "v0.27.0")
+ }
+ if tc.root {
+ if err := os.MkdirAll(rootSeedsFloorDir(opt), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ }
+ f := withSeedsFields(edgesFile{Box: "kass-1", MovesFloorState: tc.moves.State, MovesFloorGeneration: tc.moves.Generation}, dd, opt)
+ got := seedsFloorFields(dd, opt, "kass-1", tc.moves)
+ if got.Protocol != f.SeedsProtocol || got.MinRelease != f.SeedsFloorMinRelease || got.PrevAllowedFor != f.PrevSeedsAllowedFor ||
+ got.FloorState != f.SeedsFloorState || got.FloorGeneration != f.SeedsFloorGeneration ||
+ got.MovesFloorState != f.MovesFloorState || got.MovesFloorGeneration != f.MovesFloorGeneration {
+ t.Fatalf("heartbeat %+v differs from edges file %+v", got, f)
+ }
+ if got.Protocol != seeds.ProtocolVersion {
+ t.Fatalf("protocol = %d", got.Protocol)
+ }
+ if tc.arm && (got.MinRelease != "v0.27.0" || got.PrevAllowedFor != "v0.27.0") {
+ t.Fatalf("armed floor not reported: %+v", got)
+ }
+ })
+ }
+}
+
+// TestSeedsFloorFieldsBoxIdentity: the box identity reaches the writer that
+// compares it (withRootSeedsFields checks the projection's box against
+// f.Box), so the heartbeat can never be filled from an anonymous edgesFile.
+// A root box with no projection that names it is quarantined whatever the
+// name; the identity itself is pinned at the source.
+func TestSeedsFloorFieldsBoxIdentity(t *testing.T) {
+ dd, opt := t.TempDir(), t.TempDir()
+ if err := os.MkdirAll(rootSeedsFloorDir(opt), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ for _, box := range []string{"kass-1", "other-box"} {
+ got := seedsFloorFields(dd, opt, box, movesFloorContext{})
+ if got.FloorState != "quarantined" || got.MinRelease != "" || got.PrevAllowedFor != "" {
+ t.Fatalf("%s: a root box without its projection = %+v, want quarantined", box, got)
+ }
+ }
+ src := funcSource(t, "seedsfloorprobe.go", "seedsFloorFields")
+ if !strings.Contains(src, "Box: box") {
+ t.Fatalf("seedsFloorFields does not pass its box identity on:\n%s", src)
+ }
+ if strings.Contains(src, "edgesFile{}") {
+ t.Fatal("seedsFloorFields derives from an empty edgesFile")
+ }
+}
+
+// TestSeedsFloorFieldsRootMovesGuardWithoutSeedsProjection: the root moves
+// guard is present, the seeds projection is absent. The root path is chosen
+// (through the moves context) and reads not-ready, never the legacy path,
+// which would report the local floor as if root had accepted it.
+func TestSeedsFloorFieldsRootMovesGuardWithoutSeedsProjection(t *testing.T) {
+ dd, opt := t.TempDir(), t.TempDir()
+ armSeedsProbeFloor(t, dd, opt, "v0.27.0")
+ got := seedsFloorFields(dd, opt, "kass-1", movesFloorContext{State: "accepted", Generation: 2})
+ if got.FloorState != "quarantined" || got.MinRelease != "" || got.PrevAllowedFor != "" {
+ t.Fatalf("root moves guard without a seeds projection = %+v, want quarantined and no floor", got)
+ }
+ if got.MovesFloorState != "accepted" || got.MovesFloorGeneration != 2 {
+ t.Fatalf("moves context not carried: %+v", got)
+ }
+ // With no moves context at all the legacy path is right: nothing on this
+ // box has opted in to root floors.
+ if legacy := seedsFloorFields(dd, opt, "kass-1", movesFloorContext{}); legacy.MinRelease != "v0.27.0" {
+ t.Fatalf("legacy = %+v", legacy)
+ }
+}
+
+// TestStatusLoopSetsSeedsFloor reads source, as the named-units order test
+// does: the heartbeat's probe is set by claimReport, which statusLoop calls
+// once per tick, so agent.go does not grow.
+func TestStatusLoopSetsSeedsFloor(t *testing.T) {
+ if n := strings.Count(funcSource(t, "agent.go", "statusLoop"), "claimReport(&p)"); n != 1 {
+ t.Fatalf("statusLoop calls claimReport %d times, want once", n)
+ }
+ body := funcSource(t, "claimreport.go", "claimReport")
+ if n := strings.Count(body, "fillSeedsFloorProbe(p)"); n != 1 {
+ t.Fatalf("claimReport sets the seeds floor probe %d times, want once", n)
+ }
+ // Before the first early return, so a box with no host-claim floor still
+ // reports its seeds floor.
+ if strings.Index(body, "fillSeedsFloorProbe(p)") > strings.Index(body, "return\n") {
+ t.Fatal("the seeds floor probe is set after an early return")
+ }
+}
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 34fd93a49..c6580a0a6 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -240,6 +240,24 @@ type Probes struct {
// NamedUnits is root's last named-units record, read by the agent from
// the public root store; nil when root has written none.
NamedUnits *NamedUnitsStatus
+ // SeedsFloor is the box's seeds protocol floor as it advertises it in
+ // the edges file, so the console can read the same facts for a fleet
+ // (seeded-create D3). nil when the box did not say.
+ SeedsFloor *SeedsFloorReport
+}
+
+// SeedsFloorReport is the seven facts the console's region seeds check reads
+// (internal/console/seedfloor.go), carried in the heartbeat so the fleet
+// check can apply the same rule. Written by host.seedsFloorFields, the same
+// code that fills the edges file.
+type SeedsFloorReport struct {
+ Protocol int `json:"protocol"` // the build's seeds.ProtocolVersion
+ MinRelease string `json:"min_release,omitempty"` // armed floor; "" = none armed
+ PrevAllowedFor string `json:"prev_allowed_for,omitempty"` // carlos.prev's verdict
+ FloorState string `json:"floor_state,omitempty"` // root floor guard
+ FloorGeneration uint64 `json:"floor_generation,omitempty"`
+ MovesFloorState string `json:"moves_floor_state,omitempty"`
+ MovesFloorGeneration uint64 `json:"moves_floor_generation,omitempty"`
}
// OfflineMoveFacts is what a box that can take part in an offline move
@@ -860,6 +878,9 @@ type BoxMetrics struct {
// carried in the heartbeat the agent already publishes. Omitted when root
// has written none.
NamedUnits *NamedUnitsStatus `json:"named_units,omitempty"`
+ // SeedsFloor is Probes.SeedsFloor: the seeds protocol floor facts a
+ // fleet's seed door reads. Omitted when the box did not say.
+ SeedsFloor *SeedsFloorReport `json:"seeds_floor,omitempty"`
}
// UpdateSettingsProtocol is the BoxMetrics.UpdateSettings a binary reports
@@ -1302,7 +1323,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" ||
p.Alerts != nil || p.GeoIP != nil || p.HeldStreams != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" ||
p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil ||
- p.MailerArmed || p.OfflineMove != nil || p.NamedUnits != nil {
+ p.MailerArmed || p.OfflineMove != nil || p.NamedUnits != nil || p.SeedsFloor != nil {
var capabilities []string
if p.DemoClaimSeedReady {
capabilities = append(capabilities, seeds.DemoClaimCapability)
@@ -1363,6 +1384,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
MailerArmed: p.MailerArmed,
OfflineMove: p.OfflineMove,
NamedUnits: p.NamedUnits,
+ SeedsFloor: p.SeedsFloor,
}
}
diff --git a/internal/status/snapshot_test.go b/internal/status/snapshot_test.go
index 5cf4bebaf..500b33c42 100644
--- a/internal/status/snapshot_test.go
+++ b/internal/status/snapshot_test.go
@@ -490,3 +490,21 @@ func TestCollectBoxCarriesOfflineMoveFacts(t *testing.T) {
t.Fatalf("no facts and nothing else known must mean no metrics block: %+v", b.Metrics)
}
}
+
+// TestCollectBoxCarriesSeedsFloor: the seeds-floor block reaches the private
+// Metrics block, counts as something known, and a box without it publishes
+// what it did before.
+func TestCollectBoxCarriesSeedsFloor(t *testing.T) {
+ want := SeedsFloorReport{Protocol: 4, MinRelease: "v1.2.3", PrevAllowedFor: "v1.2.3", FloorState: "accepted", FloorGeneration: 7, MovesFloorState: "accepted", MovesFloorGeneration: 3}
+ b := CollectBox(nil, Probes{MachineID: "m", SeedsFloor: &want}, time.Now())
+ if b.Metrics == nil || b.Metrics.SeedsFloor == nil || *b.Metrics.SeedsFloor != want {
+ t.Fatalf("Metrics = %+v", b.Metrics)
+ }
+ raw, _ := json.Marshal(b.Metrics)
+ if !strings.Contains(string(raw), `"seeds_floor":{"protocol":4,"min_release":"v1.2.3"`) {
+ t.Fatalf("wire = %s", raw)
+ }
+ if b := CollectBox(nil, Probes{MachineID: "m"}, time.Now()); b.Metrics != nil {
+ t.Fatalf("an all-unknown probe attached Metrics: %+v", b.Metrics)
+ }
+}