the-chaingang / ethereal

Dockerized Ethereum testnets
MIT License
13 stars 7 forks source link

Testrunner should have the ability to wait for JSON RPC API availability before greenlighting dependent processes #29

Open zomglings opened 6 years ago

zomglings commented 6 years ago

Currently, it waits on IPC socket availability : https://github.com/the-chaingang/ethereal/blob/master/testrunner.sh

Our tests which rely on the JSON RPC interface (https://github.com/the-chaingang/ethereal/blob/master/tests/rpc-apis/test.sh) currently just rely on a sleep call to wait for the HTTP endpoint to be available after the IPC socket is available. This is not an elegant solution and the testrunner should implement the right logic.

kthakore commented 6 years ago

Why not use curl to watch the end point? Also the node-* docker-compose.yml service section can use healthcheck to check if services are up. See https://docs.docker.com/compose/compose-file/#healthcheck


HTTPD=`curl -A "Web Check" -sL --connect-timeout 3 -w "%{http_code}\n" "http://localhost:${NODE_RPC_PORT}" -o /dev/null`
until [ "$HTTPD" == "200" ]; do
    printf '.'
    sleep 1
done
zomglings commented 6 years ago

@kthakore : If that works, would be great (could you add a PR?)

(I'm not sure that the service will send a 200, but if it works I'm happy.)

I was thinking to poll something like geth attach $NODE_RPC_URL --exec "process.exit(0)" until it exits with code 0.

zomglings commented 6 years ago

@kthakore : Thanks for pointing out health checks, didn't know about those. Tracking that issue as #34