diff --git a/.travis.yml b/.travis.yml index c65dedb..a7be1be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: php +services: docker + php: - 5.6 - 7.0 @@ -7,11 +9,14 @@ php: - 7.2 - 7.3 - 7.4 + - nightly + +matrix: + allow_failures: + - php: nightly before_install: - - export PATH=$HOME/.local/bin:$PATH - - pip install --user autobahntestsuite - - pip list --user autobahntestsuite + - docker pull crossbario/autobahn-testsuite before_script: - composer install diff --git a/composer.json b/composer.json index b758876..c7f22c7 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "guzzlehttp/psr7": "^1.0" }, "require-dev": { - "phpunit/phpunit": "4.8.*", + "phpunit/phpunit": "5.7.*", "react/socket": "^1.3" }, "scripts": { diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php index 1c28d74..d41a645 100644 --- a/tests/ab/clientRunner.php +++ b/tests/ab/clientRunner.php @@ -107,7 +107,8 @@ function getTestCases() { return $deferred->promise(); } -$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator(PermessageDeflateOptions::createEnabled()); +$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator( + PermessageDeflateOptions::permessageDeflateSupported() ? PermessageDeflateOptions::createEnabled() : null); function runTest($case) { @@ -120,7 +121,8 @@ function runTest($case) $deferred = new Deferred(); $connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred, $casePath, $case) { - $cn = new ClientNegotiator(PermessageDeflateOptions::createEnabled()); + $cn = new ClientNegotiator( + PermessageDeflateOptions::permessageDeflateSupported() ? PermessageDeflateOptions::createEnabled() : null); $cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001' . $casePath)); $rawResponse = ""; @@ -178,7 +180,9 @@ function createReport() { $deferred = new Deferred(); $connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred) { - $reportPath = "/updateReports?agent=" . AGENT . "&shutdownOnComplete=true"; + // $reportPath = "/updateReports?agent=" . AGENT . "&shutdownOnComplete=true"; + // we will stop it using docker now instead of just shutting down + $reportPath = "/updateReports?agent=" . AGENT; $cn = new ClientNegotiator(); $cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001' . $reportPath)); @@ -242,6 +246,7 @@ getTestCases()->then(function ($count) use ($loop) { $allDeferred->resolve(); return; } + echo "Running test $i/$count\n"; runTest($i)->then($runNextCase); }; diff --git a/tests/ab/fuzzingclient.json b/tests/ab/fuzzingclient.json index c43d414..fc3869b 100644 --- a/tests/ab/fuzzingclient.json +++ b/tests/ab/fuzzingclient.json @@ -5,32 +5,11 @@ , "outdir": "./reports/servers" , "servers": [{ "agent": "RatchetRFC/0.1.0" - , "url": "ws://localhost:9001" + , "url": "ws://host.docker.internal:9001" , "options": {"version": 18} }] , "cases": [ - "1.*", - "2.*", - "3.*", - "4.*", - "5.*", - "6.*", - "7.*", - "8.*", - "9.*", - "10.*", - "12.1.1", - "12.2.1", - "12.3.1", - "12.4.1", - "12.5.1", - "13.1.1", - "13.2.1", - "13.3.1", - "13.4.1", - "13.5.1", - "13.6.1", - "13.7.1" + "*" ] , "exclude-cases": [] , "exclude-agent-cases": {} diff --git a/tests/ab/fuzzingserver.json b/tests/ab/fuzzingserver.json index 9f921a4..3a59bab 100644 --- a/tests/ab/fuzzingserver.json +++ b/tests/ab/fuzzingserver.json @@ -5,28 +5,7 @@ } , "outdir": "./reports/clients" , "cases": [ - "1.*", - "2.*", - "3.*", - "4.*", - "5.*", - "6.*", - "7.*", - "8.*", - "9.*", - "10.*", - "12.1.1", - "12.2.1", - "12.3.1", - "12.4.1", - "12.5.1", - "13.1.1", - "13.2.1", - "13.3.1", - "13.4.1", - "13.5.1", - "13.6.1", - "13.7.1" + "*" ] , "exclude-cases": [] , "exclude-agent-cases": {} diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index 4ccbc8f..630e806 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -9,16 +9,43 @@ if [ $(phpenv version-name) = "hhvm" -o $(phpenv version-name) = "5.4" -o $(phpe fi fi -wstest -m fuzzingserver -s fuzzingserver$SKIP_DEFLATE.json & +docker run --rm \ + -d \ + -v ${PWD}:/config \ + -v ${PWD}/reports:/reports \ + -p 9001:9001 \ + --name fuzzingserver \ + crossbario/autobahn-testsuite wstest -m fuzzingserver -s /config/fuzzingserver$SKIP_DEFLATE.json sleep 5 -php clientRunner.php +if [ "$TRAVIS" != "true" ]; then + echo "Running tests vs Autobahn test client" + ###docker run -it --rm --name abpytest crossbario/autobahn-testsuite wstest --mode testeeclient -w ws://host.docker.internal:9001 +fi +php -d memory_limit=256M clientRunner.php + +docker ps -a + +docker logs fuzzingserver + +docker stop fuzzingserver + + sleep 2 -php startServer.php & +php -d memory_limit=256M startServer.php & sleep 3 -wstest -m fuzzingclient -s fuzzingclient$SKIP_DEFLATE.json -sleep 1 -kill $(ps aux | grep 'php startServer.php' | awk '{print $2}' | head -n 1) + +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 +sleep 1 + +# send the shutdown command to the PHP echo server +wget -O - -q http://127.0.0.1:9001/shutdown + diff --git a/tests/ab/startServer.php b/tests/ab/startServer.php index fa30394..6d5b46b 100644 --- a/tests/ab/startServer.php +++ b/tests/ab/startServer.php @@ -1,4 +1,6 @@ on('connection', function (React\Socket\ConnectionInterface $connection) use ($negotiator, $closeFrameChecker, $uException) { +$socket->on('connection', function (React\Socket\ConnectionInterface $connection) use ($negotiator, $closeFrameChecker, $uException, $socket) { $headerComplete = false; $buffer = ''; $parser = null; - $connection->on('data', function ($data) use ($connection, &$parser, &$headerComplete, &$buffer, $negotiator, $closeFrameChecker, $uException) { + $connection->on('data', function ($data) use ($connection, &$parser, &$headerComplete, &$buffer, $negotiator, $closeFrameChecker, $uException, $socket) { if ($headerComplete) { $parser->onData($data); return; @@ -38,6 +40,12 @@ $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.'))); + $socket->close(); + return; + }; + $connection->write(\GuzzleHttp\Psr7\str($negotiatorResponse)); if ($negotiatorResponse->getStatusCode() !== 101) {