diff --git a/ws/proxyConfig.json b/ws/proxyConfig.json index b1020f54..a9fd4d47 100644 --- a/ws/proxyConfig.json +++ b/ws/proxyConfig.json @@ -1,6 +1,6 @@ { "remote_urls": { - "echo.localhost:8008": "ws://localhost:9009", - "cobra.localhost:8008": "ws://localhost:8765" + "echo.localhost:8008": "ws://localhost:8009", + "cobra.localhost:8008": "ws://localhost:5678" } } diff --git a/ws/test_ws_proxy.sh b/ws/test_ws_proxy.sh new file mode 100644 index 00000000..c7036635 --- /dev/null +++ b/ws/test_ws_proxy.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# This test requires cobra to be available +which cobra > /dev/null || { + echo cobra is not installed on this machine. + exit 0 +} + +# Handle Ctrl-C by killing all sub-processing AND exiting +trap cleanup INT + +function cleanup { + exit_code=${1:-1} + echo "Killing all servers (ws and cobra)" + echo + kill `cat /tmp/pidfile.proxy` &>/dev/null + kill `cat /tmp/pidfile.echo_server` &>/dev/null + kill `cat /tmp/pidfile.cobra` &>/dev/null + kill `cat /tmp/pidfile.connect.echo` &>/dev/null + kill `cat /tmp/pidfile.connect.cobra` &>/dev/null + exit ${exit_code} +} + +ws proxy_server --pidfile /tmp/pidfile.proxy --config_path proxyConfig.json & +ws echo_server --pidfile /tmp/pidfile.echo_server --port 8009 & +cobra -v run --pidfile /tmp/pidfile.cobra --port 5678 & + +# Wait for the servers to be up +sleep 1 + +# unbuffer comes with expect (written in tcl) +echo 'hello' | unbuffer ws connect --pidfile /tmp/pidfile.connect.echo ws://echo.localhost:8008 & + +echo 'hello' | unbuffer ws connect --pidfile /tmp/pidfile.connect.cobra ws://cobra.localhost:8008 & + +# Wait +sleep 2 + +cleanup