The node agent waits for a backup's end on the holder's event, not by polling; the manifest consumes it (R6-A A5)

This commit is contained in:
2026-10-24 17:03:30 +02:00
parent 20d0998cdd
commit e5a06cc73d
6 changed files with 158 additions and 53 deletions
+4 -17
View File
@@ -230,32 +230,19 @@ func TestNatsAWantAndItsCompositionAreAppliedWithinASecond(t *testing.T) {
// module (nothing applied, the have says held with the backup's words); when its want then says skip, it is applied.
func TestNatsADataModuleAsksItsBackupFirstAndIsHeldWhenItFails(t *testing.T) {
b := newItBed(t)
backupPollEvery = 20 * time.Millisecond
var mu sync.Mutex
var asked []string
var onDiskWhenAsked string
var nightOK bool
var at time.Time
if _, err := b.conn.Subscribe("mesh.seat.node-backup.tool.now."+itNode, func(m *nats.Msg) {
mu.Lock()
asked = append(asked, "now")
onDiskWhenAsked = b.file("db")
at = time.Now()
mu.Unlock()
_ = m.Respond([]byte(`{"result":{"started":"db"}}`))
}); err != nil {
t.Fatal(err)
}
if _, err := b.conn.Subscribe("mesh.seat.node-backup.tool.backed-up."+itNode, func(m *nats.Msg) {
mu.Lock()
defer mu.Unlock()
if at.IsZero() {
_ = m.Respond([]byte(`{"result":[]}`))
return
}
night, _ := json.Marshal(map[string]any{"module": "db", "lastNight": map[string]any{"ok": nightOK,
"at": time.Now().UTC(), "error": "restic: the repository is locked"}})
_ = m.Respond([]byte(`{"result":[` + string(night) + `]}`))
// The holder says the backup ended on its event.
ev, _ := json.Marshal(map[string]any{"node": itNode, "module": "db", "ok": false, "at": time.Now().UTC(),
"error": "restic: the repository is locked"})
_ = b.conn.Publish(backedUpEvent, ev)
}); err != nil {
t.Fatal(err)
}