Skip to content

Commit d03d544

Browse files
committed
Revert "Revert "chore(ext/websocket): Add autobahn|testsuite fuzzingclient (#… (denoland#18856)"
This reverts commit 17d1c7e.
1 parent 10ae5ee commit d03d544

File tree

7 files changed

+100
-2
lines changed

7 files changed

+100
-2
lines changed

.dprint.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"associations": "**/*.rs",
1414
"rustfmt": "rustfmt --config imports_granularity=item"
1515
},
16-
"includes": ["**/*.{ts,tsx,js,jsx,json,md,toml,rs}"],
16+
"includes": [
17+
"**/*.{ts,tsx,js,jsx,json,md,toml,rs}"
18+
],
1719
"excludes": [
1820
".cargo_home",
1921
".git",
@@ -48,7 +50,8 @@
4850
"tools/node_compat/TODO.md",
4951
"tools/node_compat/versions",
5052
"tools/wpt/expectation.json",
51-
"tools/wpt/manifest.json"
53+
"tools/wpt/manifest.json",
54+
"ext/websocket/autobahn/reports"
5255
],
5356
"plugins": [
5457
"https://plugins.dprint.dev/typescript-0.84.0.wasm",

.github/workflows/ci.generate.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,15 @@ const ci = {
642642
run:
643643
'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs://dl.deno.land/canary/$(git rev-parse HEAD)/',
644644
},
645+
{
646+
name: "Autobahn testsuite",
647+
if: [
648+
"matrix.job == 'test' && matrix.profile == 'release' &&",
649+
"!startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'ubuntu')",
650+
].join("\n"),
651+
run:
652+
"target/release/deno run -A --unstable ext/websocket/autobahn/fuzzingclient.js",
653+
},
645654
{
646655
name: "Test debug",
647656
if: [

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ jobs:
399399
env:
400400
CLOUDSDK_PYTHON: '${{env.pythonLocation}}\python.exe'
401401
run: 'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs://dl.deno.land/canary/$(git rev-parse HEAD)/'
402+
- name: Autobahn testsuite
403+
if: |-
404+
!(github.event_name == 'pull_request' && matrix.skip_pr) && (matrix.job == 'test' && matrix.profile == 'release' &&
405+
!startsWith(github.ref, 'refs/tags/') && startsWith(matrix.os, 'ubuntu'))
406+
run: target/release/deno run -A --unstable ext/websocket/autobahn/fuzzingclient.js
402407
- name: Test debug
403408
if: |-
404409
!(github.event_name == 'pull_request' && matrix.skip_pr) && (matrix.job == 'test' && matrix.profile == 'debug' &&

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ gclient_config.py_entries
2626
# WPT generated cert files
2727
/tools/wpt/certs/index.txt*
2828
/tools/wpt/certs/serial*
29+
30+
/ext/websocket/autobahn/reports
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2+
import { parse } from "../../../test_util/std/flags/mod.ts";
3+
4+
const { port } = parse(Deno.args, {
5+
number: ["port"],
6+
default: {
7+
port: 6969,
8+
},
9+
});
10+
11+
const { serve } = Deno;
12+
13+
// A message-based WebSocket echo server.
14+
serve((request) => {
15+
const { socket, response } = Deno.upgradeWebSocket(request);
16+
socket.onmessage = (event) => {
17+
socket.send(event.data);
18+
};
19+
return response;
20+
}, { port });
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2+
3+
// deno-lint-ignore-file
4+
5+
import { $ } from "https://deno.land/x/[email protected]/mod.ts";
6+
7+
const pwd = new URL(".", import.meta.url).pathname;
8+
9+
const AUTOBAHN_TESTSUITE_DOCKER =
10+
"crossbario/autobahn-testsuite:0.8.2@sha256:5d4ba3aa7d6ab2fdbf6606f3f4ecbe4b66f205ce1cbc176d6cdf650157e52242";
11+
12+
const self = Deno.execPath();
13+
$`${self} run -A --unstable ${pwd}/autobahn_server.js`.spawn();
14+
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`
15+
.cwd(pwd);
16+
17+
const { deno_websocket } = JSON.parse(
18+
Deno.readTextFileSync(`${pwd}/reports/servers/index.json`),
19+
);
20+
const result = Object.values(deno_websocket);
21+
22+
function failed(name) {
23+
return name != "OK" && name != "INFORMATIONAL" && name != "NON-STRICT";
24+
}
25+
26+
const failedtests = result.filter((outcome) => failed(outcome.behavior));
27+
28+
console.log(
29+
`%c${result.length - failedtests.length} / ${result.length} tests OK`,
30+
`color: ${failedtests.length == 0 ? "green" : "red"}`,
31+
);
32+
33+
Deno.exit(failedtests.length == 0 ? 0 : 1);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"outdir": "./reports/servers",
3+
"servers": [
4+
{
5+
"agent": "deno_websocket",
6+
"url": "ws://localhost:6969"
7+
}
8+
],
9+
"cases": [
10+
"1.*",
11+
"2.*",
12+
"3.*",
13+
"4.*",
14+
"5.*",
15+
"6.*",
16+
"7.*",
17+
"9.*",
18+
"10.*"
19+
],
20+
"exclude-cases": [
21+
"11.*",
22+
"12.*",
23+
"13.*"
24+
],
25+
"exclude-agent-cases": {}
26+
}

0 commit comments

Comments
 (0)