Have travis use docker for wstest while testing

This commit is contained in:
Matt Bonneau 2020-04-09 17:39:37 -04:00
parent 1cb14114c3
commit 7ef269aca1
7 changed files with 64 additions and 61 deletions

View File

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

View File

@ -25,7 +25,7 @@
"guzzlehttp/psr7": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
"phpunit/phpunit": "5.7.*",
"react/socket": "^1.3"
},
"scripts": {

View File

@ -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);
};

View File

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

View File

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

View File

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

View File

@ -1,4 +1,6 @@
<?php
use GuzzleHttp\Psr7\Response;
use Ratchet\RFC6455\Handshake\PermessageDeflateOptions;
use Ratchet\RFC6455\Messaging\MessageBuffer;
use Ratchet\RFC6455\Messaging\MessageInterface;
@ -12,16 +14,16 @@ $loop = \React\EventLoop\Factory::create();
$socket = new \React\Socket\Server('127.0.0.1:9001', $loop);
$closeFrameChecker = new \Ratchet\RFC6455\Messaging\CloseFrameChecker;
$negotiator = new \Ratchet\RFC6455\Handshake\ServerNegotiator(new \Ratchet\RFC6455\Handshake\RequestVerifier, true);
$negotiator = new \Ratchet\RFC6455\Handshake\ServerNegotiator(new \Ratchet\RFC6455\Handshake\RequestVerifier, PermessageDeflateOptions::permessageDeflateSupported());
$uException = new \UnderflowException;
$socket->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) {