1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/bin/sh
SNI_PROXY_PORT=${SNI_PROXY_PORT:=8080}
if [ -n "${LOCAL_HTTPD_PORT}" ]; then
TEST_HTTPD_PORT=${LOCAL_HTTPD_PORT}
else
TEST_HTTPD_PORT=${TEST_HTTPD_PORT:=8081}
# Start TestHTTPD
perl -MTestHTTPD -e "TestHTTPD::httpd(port => ${TEST_HTTPD_PORT})" &
TEST_HTTPD_PID=$!
fi
# Create a test configuration file
CONFIG_FILE=$(perl -MTestUtils -e "print TestUtils::make_config(${SNI_PROXY_PORT}, ${TEST_HTTPD_PORT});")
# Start sniproxy
$@ ../src/sniproxy -f -c ${CONFIG_FILE} &
SNI_PROXY_PID=$!
echo -n "Wait for TestHTTPD to start"
until netstat -ltn | grep -q :${TEST_HTTPD_PORT}; do
echo -n .
done
echo ""
echo -n "Wait for sniproxy to start"
until netstat -ltn | grep -q :${SNI_PROXY_PORT}; do
echo -n .
done
echo ""
sleep 1;
# Run apache bench
ab -n 65536 -c 256 http://localhost:${SNI_PROXY_PORT}/
RESULT=$?
# Cleanup
if [ -n "${TEST_HTTPD_PID}" ]; then
kill ${TEST_HTTPD_PID}
wait ${TEST_HTTPD_PID}
fi
kill ${SNI_PROXY_PID}
wait ${SNI_PROXY_PID}
rm -f ${CONFIG_FILE}
exit ${RESULT}
|