node-tools: a stopping tool runner takes its subscriptions down, so callers meet no responders (issue 721)
The runner answered each call it did not take once its stop began with the typed fault stopping (#90). Callers built before mesh-sdk read it as the callee's refusal and ended their kept call, and no edge delivered the new answer after its readers. Now, once told to stop, the runner first drains every subscription it answers calls on (a tool's, a seat verb's and a seat proof's) and subscribes none again, then finishes the calls in flight within drain-bound. A call made after the stop meets no responders at once, a transport fault every caller of every mesh-sdk already waits out, until the new runner subscribes. A call that still reached it is answered nothing, as H-A-369 has it. The typed answer goes whole: the reply's error-kind, KindedError, ErrorKindStopping and the bundle's error data. Tests: 721/AC4 in the bus (a call and a proof after the stop meet no responders within a second, the call in flight is answered, a subject served after the stop is refused) and in launch (a call that still reaches the runner gets no answer and no typed fault); the whole test meets no responders while a call is still in flight, before the drain bound. Builds: design 47 H2 H-A-570 (1), (3) (mesh-tools' part), amending §813 (12) as H-A-369 has it
This commit is contained in:
@@ -34,16 +34,6 @@ func TestALostWriteIsAnsweredWithItsOwnCodeAndNothingElseIs(t *testing.T) {
|
||||
if got := errorCode(errors.New("issues keeps no state numbers")); got == CodeChanged || got != -32000 {
|
||||
t.Errorf("a plain refusal is answered %d", got)
|
||||
}
|
||||
// A typed fault reaches the bundle as its kind in the error's data, wrapped or not (design 47 H2 H-A-542); a plain
|
||||
// refusal carries none.
|
||||
for _, err := range []error{&afterStop{module: "registry", verb: "publish"}, fmt.Errorf("asked: %w", &afterStop{module: "registry", verb: "publish"})} {
|
||||
if data, _ := errorAnswer(err)["data"].(map[string]any); data["error-kind"] != ErrorKindStopping {
|
||||
t.Errorf("%v is answered %v, want its error-kind stopping", err, errorAnswer(err))
|
||||
}
|
||||
}
|
||||
if _, has := errorAnswer(errors.New("issues keeps no state numbers"))["data"]; has {
|
||||
t.Error("a plain refusal is answered an error-kind")
|
||||
}
|
||||
}
|
||||
|
||||
// A bundle that answers the handshake and an empty tool list, and notes each start and its pid in $OUT.
|
||||
@@ -65,7 +55,7 @@ done
|
||||
// itself is stopping, none is, by a restart or by a call.
|
||||
//
|
||||
// **The tool runner drains at a stop** (design 47 H2 §813 (12), H-A-342 (2), H-A-353, H-A-369): once it drains, no new call is
|
||||
// taken and its caller is answered the typed fault stopping (H-A-542), never silence; a call
|
||||
// taken and its caller is answered nothing (Unanswered), never refused; a call
|
||||
// in flight that ends within the drain bound is answered; one still in flight at the bound is cut, said with its bundle, its verb
|
||||
// and its age, and left unanswered (Unanswered, so the bus sends its caller nothing: a transport fault).
|
||||
func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
|
||||
@@ -81,7 +71,7 @@ func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
|
||||
}{
|
||||
{"a bundle that dies while the runtime serves", false, 2, 0, false},
|
||||
{"a bundle signalled with the stopping runtime", true, 1, 0, false},
|
||||
{"a call that ends within the drain bound is answered, and a call after the stop is answered stopping", false, 0, 10 * time.Second, true},
|
||||
{"a call that ends within the drain bound is answered, and a call after the stop is answered nothing", false, 0, 10 * time.Second, true},
|
||||
{"a call that outlives the drain bound is cut and said", false, 0, 50 * time.Millisecond, false},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
@@ -140,12 +130,13 @@ func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if row.release {
|
||||
// A call made after the stop is answered the typed fault stopping, never silence (H-A-542).
|
||||
var kinded interface{ ErrorKind() string }
|
||||
// 721/AC4: a call that still reaches the runner after its stop began gets no answer from it, no typed fault
|
||||
// (H-A-570, withdrawing H-A-542's answer): every later one meets no responders on the bus.
|
||||
var unanswered interface{ Unanswered() bool }
|
||||
if _, err := run("", json.RawMessage(`{}`)); !errors.As(err, &kinded) || kinded.ErrorKind() != ErrorKindStopping ||
|
||||
errors.As(err, &unanswered) {
|
||||
t.Errorf("a call made after the stop ended %v, want it answered stopping, never silence", err)
|
||||
var kinded interface{ ErrorKind() string }
|
||||
if _, err := run("", json.RawMessage(`{}`)); !errors.As(err, &unanswered) || !unanswered.Unanswered() ||
|
||||
errors.As(err, &kinded) {
|
||||
t.Errorf("a call made after the stop ended %v, want it answered nothing, never refused", err)
|
||||
}
|
||||
f, err := os.OpenFile(hold, os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user