Wait for a stopped bundle's exit instead of sleeping after it
Launched.Stop now returns once the bundle's exit is handled, bounded by StopWait, and the launcher reads its restart pauses once at Start, so the exit goroutine no longer races a test that changes them. The caller tests drop their half-second pause (novox/hq issue 476).
This commit is contained in:
@@ -27,7 +27,7 @@ func TestACallOnTheCallerNamedSubjectReachesTheModuleWithItsCaller(t *testing.T)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer settled(stop)
|
||||
defer stop() // returns once the bundle's exit is handled (novox/hq issue 476)
|
||||
asker, err := bus.Connect(bus.Credential{URL: mt.URL(t), Module: "node-tools", Node: "shanks",
|
||||
User: "shanks.node-tools", Password: "unused"})
|
||||
if err != nil {
|
||||
@@ -65,7 +65,7 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer settled(stop)
|
||||
defer stop() // returns once the bundle's exit is handled (novox/hq issue 476)
|
||||
old, err := nats.Connect(mt.URL(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -89,11 +89,3 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// settled stops a runtime and waits for its bundle's exit to be handled: the launcher reads its restart pauses
|
||||
// (launch.RestartFirst) as a bundle exits, and a later test in this package sets them, so a test that leaves its
|
||||
// bundle exiting behind it races the next one.
|
||||
func settled(stop func()) {
|
||||
stop()
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user