Wait until the node applied the genesis document before the sdk step asks for a build (hq issue 615)
The packages step sealed the build agent its genesis document and pushed, and the push returned as soon as it was sent. The sdk step then asked for the SDK's build at once, and the agent reads the document from the file the node writes when it applies that push: one genesis found it in time, the next was refused for having neither a binding nor the document. That one push now waits until the node reports it applied it (push --wait); every other push still returns on sending.
This commit is contained in:
@@ -42,7 +42,7 @@ func placedAfterThePush(t *testing.T, commands []string) int {
|
||||
t.Helper()
|
||||
pushed, placed := -1, 0
|
||||
for i, c := range commands {
|
||||
if strings.HasSuffix(c, "push anchor") && pushed < 0 {
|
||||
if strings.Contains(c, "/mesh-controller push anchor") && pushed < 0 {
|
||||
pushed = i
|
||||
}
|
||||
if strings.HasPrefix(c, "sh -c") && strings.Contains(c, busAccounts) &&
|
||||
@@ -95,3 +95,40 @@ func TestOnceTheBusIsTheNatsModulesThePushPlacesNothing(t *testing.T) {
|
||||
t.Fatalf("the installer placed the bus's users over the nats module's: %v", runtime.commands)
|
||||
}
|
||||
}
|
||||
|
||||
// Defends novox/hq issue 615: the packages step's push is waited for until the node applied it, because
|
||||
// the sdk step right after asks the build agent for a build that reads the genesis document from the
|
||||
// file that apply writes. A push that returned on sending let the ask race the apply.
|
||||
func TestThePackagesStepWaitsUntilTheNodeAppliedTheGenesisDocument(t *testing.T) {
|
||||
t.Setenv("TMPDIR", t.TempDir())
|
||||
runtime, control := placing(false)
|
||||
o := Options{Node: "anchor", Wait: 3 * time.Minute}
|
||||
if err := deliverGenesisRegistry(context.Background(), o, control, genesisRegistry(DefaultPorts(), "pw"), quietly); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range runtime.commands {
|
||||
if strings.Contains(c, "/mesh-controller push anchor") {
|
||||
if !strings.HasSuffix(c, "push anchor --wait 3m0s") {
|
||||
t.Fatalf("the genesis document's push does not wait for the node to apply it: %s", c)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatalf("the genesis document was never pushed: %v", runtime.commands)
|
||||
}
|
||||
|
||||
// Every other push of genesis still returns on sending: only a push whose content the next step reads on
|
||||
// the machine waits.
|
||||
func TestAnOrdinaryPushDoesNotWait(t *testing.T) {
|
||||
t.Setenv("TMPDIR", t.TempDir())
|
||||
runtime, control := placing(false)
|
||||
o := Options{Node: "anchor", Wait: time.Second}
|
||||
if _, err := installModule(context.Background(), o, control, BuilderModule, []byte(`{}`), quietly); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, c := range runtime.commands {
|
||||
if strings.Contains(c, "push anchor --wait") {
|
||||
t.Fatalf("an ordinary push waits: %s", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user