BM1: the build modules give a step met away again by again-delays
Each build module declares again-delays (15s,60s) and gives its puller the delays steprun.AgainDelays reads from it; a publish's no responders is a transport fault by steprun.PublishFault with no seat call to learn why, so the modules no longer invoke the assigner's assignments. Builds: design 47 H2 §799; H-A-350 DMC-7, H-A-390
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -37,6 +39,30 @@ func TestTheStartSweepEndsWhatAPreviousProcessLeft(t *testing.T) {
|
||||
// ADR 0664 §1 (issue 1748): the module's own paths from a failed fetch or install to its step's error say a network that did
|
||||
// not answer as a transport fault, and a failure of the source (a package the registry lacks) as none.
|
||||
func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) {
|
||||
// A step whose fetch or publish met its holder away is given again after the module's again-delays, 15 s after its
|
||||
// first run and 60 s after its second by default (design 47 H2 §799; H-A-390).
|
||||
t.Run("again-delays is declared and read", func(t *testing.T) {
|
||||
raw, err := os.ReadFile(filepath.Join("..", "..", "module.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var m struct {
|
||||
Config map[string]json.RawMessage `json:"config"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var c struct {
|
||||
Default string `json:"default"`
|
||||
Runtime bool `json:"runtime"`
|
||||
}
|
||||
decl, ok := m.Config[steprun.AgainDelaysSetting]
|
||||
_ = json.Unmarshal(decl, &c)
|
||||
delay, err := steprun.AgainDelays(c.Default)
|
||||
if !ok || !c.Runtime || err != nil || delay(1) != 15*time.Second || delay(2) != 60*time.Second {
|
||||
t.Fatalf("again-delays declared %v as %+v: %v", ok, c, err)
|
||||
}
|
||||
})
|
||||
conformance.Passing(t, []string{conformance.GitFetch, conformance.NpmCI}, func(runner, words string) error {
|
||||
switch runner {
|
||||
case conformance.GitFetch:
|
||||
|
||||
@@ -83,6 +83,14 @@ func main() {
|
||||
steps := m.StepTools()
|
||||
booted := time.Now()
|
||||
puller := m.Puller(steps, nil)
|
||||
// A step whose fetch or publish met its holder away is given again after again-delays (design 47 H2 §799; H-A-390).
|
||||
againSetting, _ := stdio.Setting(steprun.AgainDelaysSetting)
|
||||
againDelay, againErr := steprun.AgainDelays(againSetting)
|
||||
if againErr != nil {
|
||||
logf("the setting %s: %v", steprun.AgainDelaysSetting, againErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
puller.Delay = againDelay
|
||||
m.Held = puller
|
||||
if m.Node != "" {
|
||||
// A step a previous process left running is ended (issue 1890): one that names another owner, or none and
|
||||
|
||||
@@ -137,17 +137,9 @@ func TestARefusedPushFailsNotStoredAndNoPackedFileStays(t *testing.T) {
|
||||
if c.words != "" && (err == nil || !strings.HasPrefix(err.Error(), builds.NotStored+"tools: ") || !strings.Contains(err.Error(), c.words)) {
|
||||
t.Errorf("a refused publish answered %v", err)
|
||||
}
|
||||
if c.noSeat {
|
||||
// ADR 0664 §1: with a holder named by the assigner the same words are a transport fault, the bus gives the ask again.
|
||||
m.Call = func(key string, _ any) (json.RawMessage, error) {
|
||||
if key == steprun.AssignerHolders {
|
||||
return json.RawMessage(`{"seats":[{"seat":"oci-artifact-registry","holders":[{"module":"mesh-registry","node":"novox"}]}],"holds":1}`), nil
|
||||
}
|
||||
return nil, errors.New("nats: no responders available for request")
|
||||
}
|
||||
if _, err := m.build(context.Background(), buildArgs()); err == nil || !sdkstep.IsPassing(err) || !strings.Contains(err.Error(), "the holder is silent") {
|
||||
t.Errorf("no responders with a holder named answered %v, want a transport fault", err)
|
||||
}
|
||||
if c.noSeat && (err == nil || !sdkstep.IsPassing(err) || !strings.Contains(err.Error(), "publish: ")) {
|
||||
// A publish met by no responders is a transport fault with no seat call to learn why (design 47 H2 §799).
|
||||
t.Errorf("no responders answered %v, want a transport fault opening publish:", err)
|
||||
}
|
||||
var archives []string
|
||||
filepath.WalkDir(work, func(p string, d os.DirEntry, err error) error {
|
||||
|
||||
Reference in New Issue
Block a user