forked from TrueCloudLab/neoneo-go
services/rpcsrv: Test Server
shutdown with failed precondition
There is an existing problem with RPC server shutdown freeze after start failure due to some init actions (at least HTTP listen) described in #2896. Add dedicated unit test which checks that `Shutdown` returns within 5s after `Start` method encounters internal problems. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
This commit is contained in:
parent
37f7c9d9a7
commit
649877d8f3
1 changed files with 19 additions and 0 deletions
|
@ -50,6 +50,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"go.uber.org/atomic"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3331,3 +3332,21 @@ func BenchmarkHandleIn(b *testing.B) {
|
||||||
{"type": "Integer", "value": "42"}, {"type": "Boolean", "value": false}]]}`))
|
{"type": "Integer", "value": "42"}, {"type": "Boolean", "value": false}]]}`))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFailedPreconditionShutdown(t *testing.T) {
|
||||||
|
_, srv, _ := initClearServerWithCustomConfig(t, func(c *config.Config) {
|
||||||
|
c.ApplicationConfiguration.RPC.Addresses = []string{"not an address"}
|
||||||
|
})
|
||||||
|
|
||||||
|
srv.Start()
|
||||||
|
require.Positive(t, len(srv.errChan)) // this is how Start reports internal failures
|
||||||
|
|
||||||
|
var stopped atomic.Bool
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
srv.Shutdown()
|
||||||
|
stopped.Store(true)
|
||||||
|
}()
|
||||||
|
|
||||||
|
require.Eventually(t, stopped.Load, 5*time.Second, 100*time.Millisecond, "Shutdown should return")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue