mesh/merge-gate head e7ff7c3045fc merged into trunk afb94d925e94 — pass: builds mesh-provisioner-client → ace, g14, novox, shanks; no bus step; every machi…
mesh/repo-check head e7ff7c3045fc merged into trunk afb94d925e94 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered
53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// 1129/AC5 (integration): the client as main/serve would run it — reading its credential from disk, dialling a
|
|
// real bus, and asking a real node-engine-shaped socket to write — fills a module once and then asks for no write
|
|
// for three seconds: there is no timer that asks again on its own (ADR 0349 clause 4). Compiled (`go vet -tags
|
|
// integration ./...`), never run here: the lead runs it against a real bus through mesh-controller.try.
|
|
func TestIntegrationServeFillsOnceAndThenAsksForNoWrite(t *testing.T) {
|
|
b := startBus(t)
|
|
e := startEngine(t, map[string]string{dunstrc: "owned"})
|
|
b.config(t, "dunst", "font-size", "13")
|
|
b.assign(t, "dunst", dunst(t))
|
|
|
|
dir := t.TempDir()
|
|
credential := filepath.Join(dir, "credential.json")
|
|
body, err := json.Marshal(Credential{URL: b.url, Node: node, User: "provisioner." + node, Password: "x"})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(credential, body, 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
done := make(chan error, 1)
|
|
go func() { done <- serve(ctx, credential, e.socket, filepath.Join(dir, "state")) }()
|
|
t.Cleanup(func() {
|
|
cancel()
|
|
<-done
|
|
})
|
|
|
|
eventually(t, "dunstrc is filled", func() bool { return strings.Contains(e.read(t, dunstrc), "Monospace 13") })
|
|
_, asked := e.counts(dunstrc)
|
|
|
|
// Well over any former drift interval (a minute by default, before this issue removed the --drift flag).
|
|
time.Sleep(3 * time.Second)
|
|
if _, after := e.counts(dunstrc); after != asked {
|
|
t.Errorf("the node-engine was asked to write %s again %d time(s) within three seconds, with nothing over "+
|
|
"the bus: there is no timer", dunstrc, after-asked)
|
|
}
|
|
}
|