From 5c15dd0a2f1c44123527308850fab118e6ed789b Mon Sep 17 00:00:00 2001 From: Matt Bonneau Date: Fri, 10 Apr 2020 13:15:49 -0400 Subject: [PATCH] Try to get IP address sorted out for travis --- tests/ab/clientRunner.php | 9 +++++++-- tests/ab/docker_bootstrap.sh | 12 ++++++++++++ tests/ab/fuzzingclient.json | 2 +- tests/ab/fuzzingclient_skip_deflate.json | 4 ++-- tests/ab/run_ab_tests.sh | 7 ++++++- tests/ab/startServer.php | 4 ++-- 6 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 tests/ab/docker_bootstrap.sh diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php index d41a645..29aef92 100644 --- a/tests/ab/clientRunner.php +++ b/tests/ab/clientRunner.php @@ -246,8 +246,13 @@ getTestCases()->then(function ($count) use ($loop) { $allDeferred->resolve(); return; } - echo "Running test $i/$count\n"; - runTest($i)->then($runNextCase); + echo "Running test $i/$count..."; + $startTime = microtime(true); + runTest($i) + ->then(function () use ($startTime) { + echo " completed " . round((microtime(true) - $startTime) * 1000) . " ms\n"; + }) + ->then($runNextCase); }; $i = 0; diff --git a/tests/ab/docker_bootstrap.sh b/tests/ab/docker_bootstrap.sh new file mode 100644 index 0000000..44d4581 --- /dev/null +++ b/tests/ab/docker_bootstrap.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -x + +echo "Running $0" + +echo Adding "$1 host.ratchet.internal" to /etc/hosts file + +echo $1 host.ratchet.internal >> /etc/hosts + +echo /etc/hosts contains: +cat /etc/hosts +echo diff --git a/tests/ab/fuzzingclient.json b/tests/ab/fuzzingclient.json index aa41362..1148d12 100644 --- a/tests/ab/fuzzingclient.json +++ b/tests/ab/fuzzingclient.json @@ -5,7 +5,7 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.1.0" - , "url": "ws://host.docker.internal:9001" + , "url": "ws://host.ratchet.internal:9001" , "options": {"version": 18} }] , "cases": [ diff --git a/tests/ab/fuzzingclient_skip_deflate.json b/tests/ab/fuzzingclient_skip_deflate.json index 3d7780c..7a8fae7 100644 --- a/tests/ab/fuzzingclient_skip_deflate.json +++ b/tests/ab/fuzzingclient_skip_deflate.json @@ -5,10 +5,10 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.1.0" - , "url": "ws://host.docker.internal:9001" + , "url": "ws://host.ratchet.internal:9001" , "options": {"version": 18} }] - , "cases": ["*"] + , "cases": ["9"] , "exclude-cases": ["12.*", "13.*"] , "exclude-agent-cases": {} } diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index 630e806..cbde025 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -36,13 +36,18 @@ sleep 2 php -d memory_limit=256M startServer.php & sleep 3 +if [ "$OSTYPE" = "linux-gnu" ]; then + IPADDR=`hostname -I | cut -f 1 -d ' '` +else + IPADDR=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -1` +fi docker run --rm \ -it \ -v ${PWD}:/config \ -v ${PWD}/reports:/reports \ --name fuzzingclient \ - crossbario/autobahn-testsuite wstest -m fuzzingclient -s /config/fuzzingclient$SKIP_DEFLATE.json + crossbario/autobahn-testsuite /bin/sh -c "sh /config/docker_bootstrap.sh $IPADDR; wstest -m fuzzingclient -s /config/fuzzingclient$SKIP_DEFLATE.json" sleep 1 # send the shutdown command to the PHP echo server diff --git a/tests/ab/startServer.php b/tests/ab/startServer.php index 6d5b46b..f1d3b66 100644 --- a/tests/ab/startServer.php +++ b/tests/ab/startServer.php @@ -11,7 +11,7 @@ require_once __DIR__ . "/../bootstrap.php"; $loop = \React\EventLoop\Factory::create(); -$socket = new \React\Socket\Server('127.0.0.1:9001', $loop); +$socket = new \React\Socket\Server('0.0.0.0:9001', $loop); $closeFrameChecker = new \Ratchet\RFC6455\Messaging\CloseFrameChecker; $negotiator = new \Ratchet\RFC6455\Handshake\ServerNegotiator(new \Ratchet\RFC6455\Handshake\RequestVerifier, PermessageDeflateOptions::permessageDeflateSupported()); @@ -41,7 +41,7 @@ $socket->on('connection', function (React\Socket\ConnectionInterface $connection $negotiatorResponse = $negotiatorResponse->withAddedHeader("Content-Length", "0"); if ($negotiatorResponse->getStatusCode() !== 101 && $psrRequest->getUri()->getPath() === '/shutdown') { - $connection->end(\GuzzleHttp\Psr7\str(new Response(200, [], 'Shutting down echo server.'))); + $connection->end(\GuzzleHttp\Psr7\str(new Response(200, [], 'Shutting down echo server.' . PHP_EOL))); $socket->close(); return; };