From d05c1a1c6013962de379749560ddb141d16c20be Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 7 May 2023 04:45:40 +0200 Subject: [PATCH] Add autobahn on github actions --- .github/workflows/cpp.yml | 2 ++ autobahn/fuzzingclient.json | 26 ++++++++++++++++++++++++++ autobahn/server-test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 autobahn/fuzzingclient.json create mode 100644 autobahn/server-test.js diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index f6c761d..06baf1d 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -72,6 +72,8 @@ jobs: run: make -C uWebSockets/tests smoke - name: Run unit tests run: make -C uWebSockets/tests + - name: Autobahn|Testsuite + run: ~/.deno/bin/deno run -A --unstable uWebSockets/autobahn/server-test.js build_osx: diff --git a/autobahn/fuzzingclient.json b/autobahn/fuzzingclient.json new file mode 100644 index 0000000..c36e247 --- /dev/null +++ b/autobahn/fuzzingclient.json @@ -0,0 +1,26 @@ +{ + "outdir": "./reports/servers", + "servers": [ + { + "agent": "uWebSockets", + "url": "ws://localhost:9001" + } + ], + "cases": [ + "1.*", + "2.*", + "3.*", + "4.*", + "5.*", + "6.*", + "7.*", + "9.*", + "10.*" + ], + "exclude-cases": [ + "11.*", + "12.*", + "13.*" + ], + "exclude-agent-cases": {} +} diff --git a/autobahn/server-test.js b/autobahn/server-test.js new file mode 100644 index 0000000..fee3f23 --- /dev/null +++ b/autobahn/server-test.js @@ -0,0 +1,26 @@ +// Based on https://github.com/denoland/fastwebsockets/blob/main/autobahn/server-test.js + +import { $ } from "https://deno.land/x/dax/mod.ts"; + +const pwd = new URL(".", import.meta.url).pathname; + +const AUTOBAHN_TESTSUITE_DOCKER = + "crossbario/autobahn-testsuite:0.8.2@sha256:5d4ba3aa7d6ab2fdbf6606f3f4ecbe4b66f205ce1cbc176d6cdf650157e52242"; + +const server = $`uWebSockets/EchoServer`.spawn(); +await $`docker run --name fuzzingserver -v ${pwd}/fuzzingclient.json:/fuzzingclient.json:ro -v ${pwd}/reports:/reports -p 9001:9001 --net=host --rm ${AUTOBAHN_TESTSUITE_DOCKER} wstest -m fuzzingclient -s fuzzingclient.json`.cwd(pwd); + +const result = Object.values(JSON.parse(Deno.readTextFileSync("./uWebSockets/autobahn/reports/servers/index.json"))["uWebSockets"]); + +function failed(name) { + return name != "OK" && name != "INFORMATIONAL" && name != "NON-STRICT"; +} + +const failedtests = result.filter((outcome) => failed(outcome.behavior) || failed(outcome.behaviorClose)); + +console.log( + `%c${result.length - failedtests.length} / ${result.length} tests OK`, + `color: ${failedtests.length == 0 ? "green" : "red"}`, +); + +Deno.exit(failedtests.length == 0 ? 0 : 1);