From 35fa78c0c1163cbc5dd180ddc8d80d159f0fd317 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 10 Jan 2016 10:42:48 -0500 Subject: [PATCH] Cleanup test automation --- .gitignore | 1 + tests/AbResultsTest.php | 24 +++++++++++++----------- tests/ab/clientRunner.php | 4 ---- tests/ab/fuzzingclient.json | 8 ++++---- tests/ab/fuzzingclient.travis.json | 13 ------------- tests/ab/fuzzingserver.travis.json | 10 ---------- tests/ab/run_ab_tests.sh | 10 ++++++---- tests/ab/startServer.php | 7 ------- 8 files changed, 24 insertions(+), 53 deletions(-) delete mode 100644 tests/ab/fuzzingclient.travis.json delete mode 100644 tests/ab/fuzzingserver.travis.json diff --git a/.gitignore b/.gitignore index 06a6b3b..42ab5d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ composer.lock vendor tests/ab/reports +reports diff --git a/tests/AbResultsTest.php b/tests/AbResultsTest.php index 871d324..9bc502d 100644 --- a/tests/AbResultsTest.php +++ b/tests/AbResultsTest.php @@ -1,28 +1,30 @@ assertFileExists($fileName); +class AbResultsTest extends \PHPUnit_Framework_TestCase { + private function verifyAutobahnResults($fileName) { + if (!file_exists($fileName)) { + return $this->markTestSkipped('Autobahn TestSuite results not found'); + } + $resultsJson = file_get_contents($fileName); $results = json_decode($resultsJson); $agentName = array_keys(get_object_vars($results))[0]; + foreach ($results->$agentName as $name => $result) { if ($result->behavior === "INFORMATIONAL") { continue; } + $this->assertTrue(in_array($result->behavior, ["OK", "NON-STRICT"]), "Autobahn test case " . $name . " in " . $fileName); } } - public function testAutobahnClientResults() - { + + public function testAutobahnClientResults() { $this->verifyAutobahnResults(__DIR__ . '/ab/reports/clients/index.json'); } - public function testAutobahnServerResults() - { + + public function testAutobahnServerResults() { $this->verifyAutobahnResults(__DIR__ . '/ab/reports/servers/index.json'); } -} \ No newline at end of file +} diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php index 8d5c24a..13a99a7 100644 --- a/tests/ab/clientRunner.php +++ b/tests/ab/clientRunner.php @@ -209,8 +209,6 @@ function createReport() { $testPromises = []; getTestCases()->then(function ($count) use ($loop) { - echo "Running " . $count . " test cases.\n"; - $allDeferred = new Deferred(); $runNextCase = function () use (&$i, &$runNextCase, $count, $allDeferred) { @@ -219,7 +217,6 @@ getTestCases()->then(function ($count) use ($loop) { $allDeferred->resolve(); return; } - echo "Running " . $i . "\n"; runTest($i)->then($runNextCase); }; @@ -227,7 +224,6 @@ getTestCases()->then(function ($count) use ($loop) { $runNextCase(); $allDeferred->promise()->then(function () { - echo "Generating report...\n"; createReport(); }); }); diff --git a/tests/ab/fuzzingclient.json b/tests/ab/fuzzingclient.json index 28cdd4a..75b1cc9 100644 --- a/tests/ab/fuzzingclient.json +++ b/tests/ab/fuzzingclient.json @@ -2,11 +2,11 @@ "options": {"failByDrop": false}, "outdir": "./reports/servers", - "servers": [ - {"agent": "AutobahnServer", + "servers": [{ + "agent": "RatchetRFC/0.1.0", "url": "ws://localhost:9001", - "options": {"version": 18}} - ], + "options": {"version": 18} + }], "cases": ["*"], "exclude-cases": ["12.*","13.*"], "exclude-agent-cases": {} diff --git a/tests/ab/fuzzingclient.travis.json b/tests/ab/fuzzingclient.travis.json deleted file mode 100644 index d61bc6a..0000000 --- a/tests/ab/fuzzingclient.travis.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "options": {"failByDrop": false}, - "outdir": "./reports/servers", - - "servers": [ - {"agent": "RatchetRFC/0.0.0", - "url": "ws://localhost:9001", - "options": {"version": 18}} - ], - "cases": ["1.*", "2.*", "3.*", "4.*", "5.*", "6.*", "7.*"], - "exclude-cases": [], - "exclude-agent-cases": {} -} diff --git a/tests/ab/fuzzingserver.travis.json b/tests/ab/fuzzingserver.travis.json deleted file mode 100644 index 4ef6af3..0000000 --- a/tests/ab/fuzzingserver.travis.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "url": "ws://127.0.0.1:9001" - , "options": { - "failByDrop": false -} - , "outdir": "./reports/clients" - , "cases": ["1.*", "2.*", "3.*", "4.*", "5.*", "6.*", "7.*"] - , "exclude-cases": [] - , "exclude-agent-cases": {} -} \ No newline at end of file diff --git a/tests/ab/run_ab_tests.sh b/tests/ab/run_ab_tests.sh index 9cd8467..aeb62d9 100644 --- a/tests/ab/run_ab_tests.sh +++ b/tests/ab/run_ab_tests.sh @@ -1,12 +1,14 @@ cd tests/ab -wstest -m fuzzingserver -s fuzzingserver.travis.json & +wstest -m fuzzingserver -s fuzzingserver.json & sleep 5 php clientRunner.php sleep 2 -php startServer.php 25 & +php startServer.php & sleep 3 -wstest -m fuzzingclient -s fuzzingclient.travis.json -sleep 2 \ No newline at end of file +wstest -m fuzzingclient -s fuzzingclient.json +sleep 2 + +killall php wstest diff --git a/tests/ab/startServer.php b/tests/ab/startServer.php index f0f9d8d..58b7814 100644 --- a/tests/ab/startServer.php +++ b/tests/ab/startServer.php @@ -7,13 +7,6 @@ require_once __DIR__ . "/../bootstrap.php"; $loop = \React\EventLoop\Factory::create(); -if ($argc > 1 && is_numeric($argv[1])) { - echo "Setting test server to stop in " . $argv[1] . " seconds.\n"; - $loop->addTimer($argv[1], function () { - exit; - }); -} - $socket = new \React\Socket\Server($loop); $server = new \React\Http\Server($socket);