Say the heartbeat's interval, export the host's validator, grant the genesis controller Phase 1 (hq to-be 45)
The controller's watchdog of a machine's heartbeat (S1) is bound to three of its intervals, and a bound the controller guessed would not move when the interval does: the heartbeat now carries interval_seconds. Its self-check (D1) must judge every composed declaration as the host does, and a second validator written from the host's rules would drift from them: the host's own parsing is exported, unchanged, as github.com/novox/mesh-host/validate. The installer's first user list grants what the controller now composes for itself: its condition buckets, the condition and doctor-heartbeat events, the bus's two consumer advisories and $SRV.INFO — or the first controller would be refused them until the broker's machine is pushed.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// **The validator a controller imports is the host's**: a declaration the host takes passes, and one
|
||||
// it refuses is refused with the host's own words, every problem at once.
|
||||
func TestTheValidatorIsTheHosts(t *testing.T) {
|
||||
good := `{"declaration": 1, "resources": [{"id": "d", "type": "directory", "path": "/var/lib/x", "mode": "0755"}]}`
|
||||
if problems := Declaration([]byte(good)); problems != nil {
|
||||
t.Fatalf("a declaration the host takes was refused: %v", problems)
|
||||
}
|
||||
for _, bad := range []string{
|
||||
`{"declaration": 1, "resources": []}`,
|
||||
`{"declaration": 99, "resources": [{"id": "d", "type": "directory", "path": "/x"}]}`,
|
||||
`{"declaration": 1, "resources": [{"id": "d", "type": "nothing-the-host-knows"}]}`,
|
||||
`not json`,
|
||||
} {
|
||||
problems := Declaration([]byte(bad))
|
||||
if len(problems) == 0 {
|
||||
t.Errorf("a declaration the host refuses was passed: %s", bad)
|
||||
}
|
||||
for _, p := range problems {
|
||||
if strings.TrimSpace(p) == "" {
|
||||
t.Errorf("a problem said nothing, for %s", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user