stageing network takedown to avoid leveldb panics

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2024-03-11 13:31:13 +01:00
parent 06e60809ca
commit 35d0299ffd
No known key found for this signature in database

View File

@ -749,13 +749,9 @@ func (n *Network) Cleanup() {
}() }()
n.Logger.Log("cleaning up test network...") n.Logger.Log("cleaning up test network...")
n.Logger.Log("Stage 1 APIs...")
for i := len(n.Validators) - 1; i >= 0; i-- { for i := len(n.Validators) - 1; i >= 0; i-- {
v := n.Validators[i] v := n.Validators[i]
if v.tmNode != nil && v.tmNode.IsRunning() {
_ = v.tmNode.Stop()
}
if v.api != nil { if v.api != nil {
_ = v.api.Close() _ = v.api.Close()
} }
@ -767,6 +763,15 @@ func (n *Network) Cleanup() {
} }
} }
} }
n.Logger.Log("Stage 2 CometBFT...")
for i := len(n.Validators) - 1; i >= 0; i-- {
v := n.Validators[i]
if v.tmNode != nil && v.tmNode.IsRunning() {
_ = v.tmNode.Stop()
}
}
n.Logger.Log("Stage 3 Application Threads...")
// waiting for all threads to be terminated // waiting for all threads to be terminated
util.TerminationWaitGroup.Wait() util.TerminationWaitGroup.Wait()
@ -774,6 +779,7 @@ func (n *Network) Cleanup() {
// 100ms chosen randomly. // 100ms chosen randomly.
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
n.Logger.Log("Stage 4 Files...")
if n.Config.CleanupDir { if n.Config.CleanupDir {
_ = os.RemoveAll(n.BaseDir) _ = os.RemoveAll(n.BaseDir)
} }