Reduce client connection attempts to test engine status

200 -> 16

Previously, considering the fibonacci back off strategy, if engine failed to
start it would have tried to attempt connections for 2.862799e+33 years.

Now, the amount of attempts is 16, equivalent to around 2 and a half seconds.
Should be more than enough, considering that usually 6-7 attempts are enough.
This commit is contained in:
ionutboangiu
2024-09-25 12:33:07 +03:00
committed by Dan Christian Bogos
parent fe1a2a13bd
commit f26a0c2d0b
2 changed files with 4 additions and 4 deletions

View File

@@ -128,7 +128,7 @@ func testCoreItStartEngineByExecWithCPUProfiling(t *testing.T) {
}
fib := utils.FibDuration(time.Millisecond, 0)
var connected bool
for i := 0; i < 200; i++ {
for i := 0; i < 16; i++ {
time.Sleep(fib())
if _, err := jsonrpc.Dial(utils.TCP, coreSCfg.ListenCfg().RPCJSONListen); err != nil {
t.Log(err)
@@ -184,7 +184,7 @@ func testCoreItStartEngineByExecWIthMemProfiling(t *testing.T) {
}
fib := utils.FibDuration(time.Millisecond, 0)
var connected bool
for i := 0; i < 200; i++ {
for i := 0; i < 16; i++ {
time.Sleep(fib())
if _, err := jsonrpc.Dial(utils.TCP, coreSCfg.ListenCfg().RPCJSONListen); err != nil {
t.Log(err)

View File

@@ -119,7 +119,7 @@ func StartEngine(cfgPath string, waitEngine int) (*exec.Cmd, error) {
}
fib := utils.FibDuration(time.Millisecond, 0)
var connected bool
for i := 0; i < 200; i++ {
for i := 0; i < 16; i++ {
time.Sleep(fib())
if _, err := jsonrpc.Dial(utils.TCP, cfg.ListenCfg().RPCJSONListen); err != nil {
utils.Logger.Warning(fmt.Sprintf("Error <%s> when opening test connection to: <%s>",
@@ -147,7 +147,7 @@ func StartEngineWithContext(ctx context.Context, cfgPath string, waitEngine int)
return
}
fib := utils.FibDuration(time.Millisecond, 0)
for i := 0; i < 200; i++ {
for i := 0; i < 16; i++ {
time.Sleep(fib())
if _, err = jsonrpc.Dial(utils.TCP, cfg.ListenCfg().RPCJSONListen); err != nil {
continue