From d5c0684ab4e561cc4d2a6f3dd1deaf0b5c8f1898 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 5 Dec 2021 11:58:52 -0500 Subject: [PATCH 1/3] Update AB test runners Use variable to connect in clientRunner Use new(ish) `host.docker.internal` address provided by Docker to connect to host machine Run client tests port 9002 so suites can be run concurrently --- composer.json | 2 +- tests/ab/clientRunner.php | 14 +++++++------- tests/ab/docker_bootstrap.sh | 12 ------------ tests/ab/fuzzingclient.json | 2 +- tests/ab/fuzzingclient_skip_deflate.json | 2 +- tests/ab/fuzzingserver.json | 2 +- tests/ab/fuzzingserver_skip_deflate.json | 2 +- tests/ab/run_ab_tests.sh | 6 +++--- 8 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 tests/ab/docker_bootstrap.sh diff --git a/composer.json b/composer.json index 0416b58..2ef015d 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "guzzlehttp/psr7": "^1.0" }, "require-dev": { - "phpunit/phpunit": "5.7.*", + "phpunit/phpunit": "^5.7", "react/socket": "^1.3" }, "scripts": { diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php index 8dd964b..cfc534f 100644 --- a/tests/ab/clientRunner.php +++ b/tests/ab/clientRunner.php @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php'; define('AGENT', 'RatchetRFC/0.3'); -$testServer = "127.0.0.1"; +$testServer = "host.docker.internal"; $loop = React\EventLoop\Factory::create(); @@ -55,9 +55,9 @@ function getTestCases() { $deferred = new Deferred(); - $connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred) { + $connector->connect($testServer . ':9002')->then(function (ConnectionInterface $connection) use ($deferred, $testServer) { $cn = new ClientNegotiator(); - $cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001/getCaseCount')); + $cnRequest = $cn->generateRequest(new Uri('ws://' . $testServer . ':9002/getCaseCount')); $rawResponse = ""; $response = null; @@ -120,10 +120,10 @@ function runTest($case) $deferred = new Deferred(); - $connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred, $casePath, $case) { + $connector->connect($testServer . ':9002')->then(function (ConnectionInterface $connection) use ($deferred, $casePath, $case, $testServer) { $cn = new ClientNegotiator( PermessageDeflateOptions::permessageDeflateSupported() ? PermessageDeflateOptions::createEnabled() : null); - $cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001' . $casePath)); + $cnRequest = $cn->generateRequest(new Uri('ws://' . $testServer . ':9002' . $casePath)); $rawResponse = ""; $response = null; @@ -179,12 +179,12 @@ function createReport() { $deferred = new Deferred(); - $connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred) { + $connector->connect($testServer . ':9002')->then(function (ConnectionInterface $connection) use ($deferred, $testServer) { // $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)); + $cnRequest = $cn->generateRequest(new Uri('ws://' . $testServer . ':9002' . $reportPath)); $rawResponse = ""; $response = null; diff --git a/tests/ab/docker_bootstrap.sh b/tests/ab/docker_bootstrap.sh deleted file mode 100644 index 44d4581..0000000 --- a/tests/ab/docker_bootstrap.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 d410be3..b8d34d0 100644 --- a/tests/ab/fuzzingclient.json +++ b/tests/ab/fuzzingclient.json @@ -5,7 +5,7 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.3" - , "url": "ws://host.ratchet.internal:9001" + , "url": "ws://host.docker.internal:9001" , "options": {"version": 18} }] , "cases": [ diff --git a/tests/ab/fuzzingclient_skip_deflate.json b/tests/ab/fuzzingclient_skip_deflate.json index b1fddbe..5031b34 100644 --- a/tests/ab/fuzzingclient_skip_deflate.json +++ b/tests/ab/fuzzingclient_skip_deflate.json @@ -5,7 +5,7 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.3" - , "url": "ws://host.ratchet.internal:9001" + , "url": "ws://host.docker.internal:9001" , "options": {"version": 18} }] , "cases": ["*"] diff --git a/tests/ab/fuzzingserver.json b/tests/ab/fuzzingserver.json index 3a59bab..9f10403 100644 --- a/tests/ab/fuzzingserver.json +++ b/tests/ab/fuzzingserver.json @@ -1,5 +1,5 @@ { - "url": "ws://127.0.0.1:9001" + "url": "ws://127.0.0.1:9002" , "options": { "failByDrop": false } diff --git a/tests/ab/fuzzingserver_skip_deflate.json b/tests/ab/fuzzingserver_skip_deflate.json index 3b90fc3..9323191 100644 --- a/tests/ab/fuzzingserver_skip_deflate.json +++ b/tests/ab/fuzzingserver_skip_deflate.json @@ -1,5 +1,5 @@ { - "url": "ws://127.0.0.1:9001" + "url": "ws://127.0.0.1:9002" , "options": { "failByDrop": false } diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index b924480..65ae3a4 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -14,13 +14,13 @@ if [ "$ABTEST" = "client" ]; then -d \ -v ${PWD}:/config \ -v ${PWD}/reports:/reports \ - -p 9001:9001 \ + -p 9002:9002 \ --name fuzzingserver \ crossbario/autobahn-testsuite wstest -m fuzzingserver -s /config/fuzzingserver$SKIP_DEFLATE.json sleep 5 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 + ###docker run -it --rm --name abpytest crossbario/autobahn-testsuite wstest --mode testeeclient -w ws://host.docker.internal:9002 fi php -d memory_limit=256M clientRunner.php @@ -48,7 +48,7 @@ if [ "$ABTEST" = "server" ]; then -v ${PWD}:/config \ -v ${PWD}/reports:/reports \ --name fuzzingclient \ - crossbario/autobahn-testsuite /bin/sh -c "sh /config/docker_bootstrap.sh $IPADDR; wstest -m fuzzingclient -s /config/fuzzingclient$SKIP_DEFLATE.json" + crossbario/autobahn-testsuite /bin/sh -c "wstest -m fuzzingclient -s /config/fuzzingclient$SKIP_DEFLATE.json" sleep 1 # send the shutdown command to the PHP echo server From 1c6e6ed0870f06c01175102438a73a67af75b831 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 5 Dec 2021 17:04:01 -0500 Subject: [PATCH 2/3] Rever use of host.docker.internal It's only supported on macOS --- tests/ab/clientRunner.php | 2 +- tests/ab/docker_bootstrap.sh | 12 ++++++++++++ tests/ab/fuzzingclient.json | 2 +- tests/ab/fuzzingclient_skip_deflate.json | 2 +- tests/ab/run_ab_tests.sh | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tests/ab/docker_bootstrap.sh diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php index cfc534f..f38a075 100644 --- a/tests/ab/clientRunner.php +++ b/tests/ab/clientRunner.php @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php'; define('AGENT', 'RatchetRFC/0.3'); -$testServer = "host.docker.internal"; +$testServer = $argc > 1 ? $argv[1] : "127.0.0.1"; $loop = React\EventLoop\Factory::create(); 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 b8d34d0..d410be3 100644 --- a/tests/ab/fuzzingclient.json +++ b/tests/ab/fuzzingclient.json @@ -5,7 +5,7 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.3" - , "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 5031b34..b1fddbe 100644 --- a/tests/ab/fuzzingclient_skip_deflate.json +++ b/tests/ab/fuzzingclient_skip_deflate.json @@ -5,7 +5,7 @@ , "outdir": "/reports/servers" , "servers": [{ "agent": "RatchetRFC/0.3" - , "url": "ws://host.docker.internal:9001" + , "url": "ws://host.ratchet.internal:9001" , "options": {"version": 18} }] , "cases": ["*"] diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index 65ae3a4..1d8d0c1 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -48,7 +48,7 @@ if [ "$ABTEST" = "server" ]; then -v ${PWD}:/config \ -v ${PWD}/reports:/reports \ --name fuzzingclient \ - crossbario/autobahn-testsuite /bin/sh -c "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 From 30f6b14634a44cd3381c1038c8570a8a1a585b94 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 7 Dec 2021 16:56:09 +0100 Subject: [PATCH 3/3] Fix docker command to run server tests with GitHub actions --- tests/ab/run_ab_tests.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index ed5ca5a..9c50d66 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -36,7 +36,7 @@ if [ "$ABTEST" = "server" ]; then fi docker run --rm \ - -it \ + -i \ -v ${PWD}:/config \ -v ${PWD}/reports:/reports \ --name fuzzingclient \ @@ -46,5 +46,3 @@ if [ "$ABTEST" = "server" ]; then # send the shutdown command to the PHP echo server wget -O - -q http://127.0.0.1:9001/shutdown fi - -