Answer a panicking verb with an error, say flag errors in the answer, and leave refused logins out of D15
Read verbs now run in the serving process, where a panic would end every call; refused logins are nobody's reconnect loop (review of hq issue 327).
This commit is contained in:
@@ -3,10 +3,8 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -70,45 +68,21 @@ func TestReplay327(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The binary a verb run as a process of its own is, built once for the tests that run one.
|
||||
var verbBinary struct {
|
||||
once sync.Once
|
||||
path string
|
||||
err error
|
||||
}
|
||||
|
||||
// asAProcess makes a verb that runs as a process of its own run this package's binary, on the bus at url.
|
||||
// asAProcess makes a verb that runs as a process of its own run this package's binary, on the bus at url:
|
||||
// built into the test's own directory, which goes with the test.
|
||||
func asAProcess(t *testing.T, url string) {
|
||||
t.Helper()
|
||||
verbBinary.once.Do(func() {
|
||||
dir, err := os.MkdirTemp("", "mesh-controller-verb-")
|
||||
if err != nil {
|
||||
verbBinary.err = err
|
||||
return
|
||||
}
|
||||
verbBinary.path = filepath.Join(dir, "mesh-controller")
|
||||
out, err := exec.Command("go", "build", "-o", verbBinary.path, ".").CombinedOutput()
|
||||
if err != nil {
|
||||
verbBinary.err = &buildError{out: string(out), err: err}
|
||||
}
|
||||
})
|
||||
if verbBinary.err != nil {
|
||||
t.Fatalf("the controller could not be built to run a verb as its own process: %v", verbBinary.err)
|
||||
path := filepath.Join(t.TempDir(), "mesh-controller")
|
||||
if out, err := exec.Command("go", "build", "-o", path, ".").CombinedOutput(); err != nil {
|
||||
t.Fatalf("the controller could not be built to run a verb as its own process: %v: %s", err, out)
|
||||
}
|
||||
was := ownImage
|
||||
ownImage = func() string { return verbBinary.path }
|
||||
ownImage = func() string { return path }
|
||||
t.Cleanup(func() { ownImage = was })
|
||||
t.Setenv(broker.NATSVar, url)
|
||||
t.Setenv(broker.CertificateVar, "")
|
||||
}
|
||||
|
||||
type buildError struct {
|
||||
out string
|
||||
err error
|
||||
}
|
||||
|
||||
func (e *buildError) Error() string { return e.err.Error() + ": " + e.out }
|
||||
|
||||
// closedNames are the names of the connections the bus saw closed.
|
||||
func closedNames(t *testing.T, bus *server.Server) []string {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user