add a simple shell script to test websocket proxy

This commit is contained in:
Benjamin Sergeant 2020-08-14 15:09:34 -07:00
parent 5423a31d5a
commit a8284e64e3
2 changed files with 41 additions and 2 deletions

View File

@ -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"
}
}

39
ws/test_ws_proxy.sh Normal file
View File

@ -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