Skip to content

Commit

Permalink
Allow Ratchet/RFC6455 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonneau committed Jun 16, 2021
1 parent 920a8a0 commit 50ee890
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.1.4

- Allow Ratchet/RFC6455 0.3

# 2.1.3

- Forward compatibility with voryx/event-loop 3.0 while supporting 2.0

# 2.1.2

- Update deps
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react/http": "^0.7.3 | ^0.8",
"react/http-client": "^0.5.3",
"voryx/event-loop": "^3.0 || ^2.0.2",
"ratchet/rfc6455": "^0.2.2",
"ratchet/rfc6455": "^0.2.2 || ^0.3",
"reactivex/rxphp": "^2.0.1"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestCase extends FunctionalTestCase
{
public function setup()
public function setup(): void
{
parent::setup();

Expand All @@ -29,4 +29,4 @@ public static function resetScheduler()
$prop->setAccessible(false);
}
}
}
}
21 changes: 20 additions & 1 deletion test/ab/clientRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,26 @@
$reportUrl = "ws://127.0.0.1:9001/updateReports?agent=" . AGENT . "&shutdownOnComplete=true";
$client = new \Rx\Websocket\Client($reportUrl);

$client->subscribe();
$client->subscribe(
function (\Rx\Websocket\MessageSubject $messages) {
echo "Report runner connected.\n";
$messages->subscribe(new \Rx\Observer\CallbackObserver(
function ($x) use ($messages) {
echo "Message received by report runner connection: " . $x . "\n";;
},
[$messages, "onError"],
[$messages, "onCompleted"]
));
},
function (Throwable $error) {
echo "Error on report runner connection:" . $error->getMessage() . "\n";
echo "Seeing an error here might be normal. Network trace shows that AB fuzzingserver\n";
echo "disconnects without sending an HTTP response.\n";
},
function () {
echo "Report runner connection completed.\n";
}
);
};

$runIndividualTest = function ($case, $timeout = 60000) {
Expand Down
12 changes: 12 additions & 0 deletions test/ab/docker_bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/ab/fuzzingclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"servers": [
{"agent": "RxWebsocketServer/0.0.0",
"url": "ws://localhost:9001",
"url": "ws://host.ratchet.internal:9001",
"options": {"version": 18}}
],
"cases": ["*"],
Expand Down
52 changes: 46 additions & 6 deletions test/ab/run_ab_tests.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,52 @@
cd test/ab
cd test/ab || exit

wstest -m fuzzingserver -s fuzzingserver.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.json
sleep 5
php clientRunner.php

php -d memory_limit=256M clientRunner.php

docker ps -a

docker logs fuzzingserver

docker stop fuzzingserver

sleep 2

php testServer.php 600 &

php -d memory_limit=256M testServer.php &
SERVER_PID=$!
sleep 3
wstest -m fuzzingclient -s fuzzingclient.json
sleep 12

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 | tr -d 'adr:'`
fi

docker run --rm \
-it \
-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.json"
sleep 1

kill $SERVER_PID

#wstest -m fuzzingserver -s fuzzingserver.json &
#sleep 5
#php clientRunner.php
#
#sleep 2

#php testServer.php 600 &
#sleep 3
#wstest -m fuzzingclient -s fuzzingclient.json
#sleep 12
2 changes: 1 addition & 1 deletion test/ab/testServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$timerObservable = Observable::timer(1000 * $argv[1]);
}

$server = new \Rx\Websocket\Server("tcp://127.0.0.1:9001", true);
$server = new \Rx\Websocket\Server("tcp://0.0.0.0:9001", true);

$server
->takeUntil($timerObservable)
Expand Down

0 comments on commit 50ee890

Please sign in to comment.