|
|
@ -2,7 +2,10 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"log" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/tendermint/abci/types" |
|
|
|
) |
|
|
@ -20,6 +23,28 @@ func main() { |
|
|
|
testCounter() |
|
|
|
} |
|
|
|
|
|
|
|
const ( |
|
|
|
maxABCIConnectTries = 10 |
|
|
|
) |
|
|
|
|
|
|
|
func ensureABCIIsUp(typ string, n int) error { |
|
|
|
var err error |
|
|
|
cmdString := "abci-cli echo hello" |
|
|
|
if typ == "grpc" { |
|
|
|
cmdString = "abci-cli --abci grpc echo hello" |
|
|
|
} |
|
|
|
|
|
|
|
for i := 0; i < n; i++ { |
|
|
|
cmd := exec.Command("bash", "-c", cmdString) // nolint: gas
|
|
|
|
_, err = cmd.CombinedOutput() |
|
|
|
if err == nil { |
|
|
|
break |
|
|
|
} |
|
|
|
<-time.After(500 * time.Millisecond) |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
func testCounter() { |
|
|
|
abciApp := os.Getenv("ABCI_APP") |
|
|
|
if abciApp == "" { |
|
|
@ -27,8 +52,18 @@ func testCounter() { |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Printf("Running %s test with abci=%s\n", abciApp, abciType) |
|
|
|
appProc := startApp(abciApp) |
|
|
|
defer appProc.StopProcess(true) |
|
|
|
cmd := exec.Command("bash", "-c", fmt.Sprintf("abci-cli %s", abciApp)) // nolint: gas
|
|
|
|
cmd.Stdout = os.Stdout |
|
|
|
if err := cmd.Start(); err != nil { |
|
|
|
log.Fatalf("starting %q err: %v", abciApp, err) |
|
|
|
} |
|
|
|
defer cmd.Wait() |
|
|
|
defer cmd.Process.Kill() |
|
|
|
|
|
|
|
if err := ensureABCIIsUp(abciType, maxABCIConnectTries); err != nil { |
|
|
|
log.Fatalf("echo failed: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
client := startClient(abciType) |
|
|
|
defer client.Stop() |
|
|
|
|
|
|
|