From 9e581ab7be3a08bc8ab06d6070310044592058c7 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 13 Jun 2024 15:33:39 +0200 Subject: [PATCH] Print backtrace when RPC fails --- cmd/soroban-rpc/internal/test/integration.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/integration.go b/cmd/soroban-rpc/internal/test/integration.go index d63d1b3c..7f1efd41 100644 --- a/cmd/soroban-rpc/internal/test/integration.go +++ b/cmd/soroban-rpc/internal/test/integration.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "log" "net" "net/http" "net/http/httptest" @@ -14,6 +15,7 @@ import ( "os/signal" "path" "path/filepath" + "runtime" "strconv" "strings" "sync" @@ -233,28 +235,30 @@ func (i *Test) getRPConfig(sqlitePath string) map[string]string { } func (i *Test) waitForRPC() { - i.t.Log("Waiting for RPC to be up...") + i.t.Log("Waiting for RPC to be healthy...") ch := jhttp.NewChannel(i.sorobanRPCURL(), nil) client := jrpc2.NewClient(ch, nil) defer client.Close() var result methods.HealthCheckResult - success := false for t := 30; t >= 0; t-- { err := client.CallResult(context.Background(), "getHealth", nil, &result) if err == nil { if result.Status == "healthy" { - success = true - break + i.t.Log("RPC is healthy") + return } } i.t.Log("RPC still unhealthy", err, result.Status) time.Sleep(time.Second) } - if !success { - i.t.Fatal("RPC failed to get healthy in 30 seconds") - } + + // Print stack trace and fail + buf := make([]byte, 1<<16) + stackSize := runtime.Stack(buf, true) + log.Printf("%s\n", string(buf[0:stackSize])) + i.t.Fatal("RPC failed to get healthy in 30 seconds") } func (i *Test) createRPCContainerMountDir(rpcConfig map[string]string) string {