From fef04a15955d1af99370e14de4f8241254aa8521 Mon Sep 17 00:00:00 2001 From: jangko Date: Sun, 20 Jun 2021 13:57:07 +0700 Subject: [PATCH] ci: parallelise autobahn tests --- .github/workflows/ci.yml | 50 +++++++++++++++++++-------------- autobahn/fuzzingclient.json | 20 ++++++------- autobahn/fuzzingclient_tls.json | 4 +-- autobahn/fuzzingserver.json | 2 +- autobahn/fuzzingserver_tls.json | 6 ++-- examples/autobahn_client.nim | 19 +++++++++---- examples/server.nim | 9 +++++- 7 files changed, 66 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bcd69f176..3c8290c521 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -226,31 +226,39 @@ jobs: nim c -d:release examples/server.nim examples/server & - pid=$! - cd autobahn - wstest --mode fuzzingclient --spec fuzzingclient.json - kill $pid - cd .. + server1=$! - nim c -d:tls -d:release examples/server.nim - examples/server & - pid=$! - cd autobahn - wstest --mode fuzzingclient --spec fuzzingclient_tls.json - kill $pid - - wstest --mode fuzzingserver --spec fuzzingserver.json & - pid=$! - cd .. - nim c -r -d:release examples/autobahn_client - kill $pid + nim c -d:tls -d:release -o:examples/tls_server examples/server.nim + examples/tls_server & + server2=$! cd autobahn - wstest --mode fuzzingserver --spec fuzzingserver_tls.json & - pid=$! + wstest --webport=0 --mode fuzzingserver --spec fuzzingserver.json & + server3=$! + + wstest --webport=0 --mode fuzzingserver --spec fuzzingserver_tls.json & + server4=$! + + wstest --mode fuzzingclient --spec fuzzingclient.json & + client1=$! + + wstest --mode fuzzingclient --spec fuzzingclient_tls.json & + client2=$! + cd .. - nim c -r -d:tls -d:release examples/autobahn_client - kill $pid + nim c -d:release examples/autobahn_client + examples/autobahn_client & + client3=$! + + nim c -d:tls -d:release -o:examples/autobahn_tlsclient examples/autobahn_client + examples/autobahn_tlsclient & + client4=$! + + wait $client1 $client2 $client3 $client4 + kill $server1 + kill $server2 + kill $server3 + kill $server4 - name: Deploy autobahn report. if: runner.os == 'linux' && matrix.target.cpu == 'amd64' && github.event_name == 'push' diff --git a/autobahn/fuzzingclient.json b/autobahn/fuzzingclient.json index dc036ce40f..c3da4dd8d8 100644 --- a/autobahn/fuzzingclient.json +++ b/autobahn/fuzzingclient.json @@ -1,12 +1,12 @@ { - "outdir": "./reports/server", - "servers": [ - { - "agent": "nim-ws example server", - "url": "ws://127.0.0.1:8888/ws" - } - ], - "cases": ["*"], - "exclude-cases": [], - "exclude-agent-cases": {} + "outdir": "./reports/server", + + "servers": [{ + "agent": "nim-ws server", + "url": "ws://127.0.0.1:8888/ws" + }], + + "cases": ["*"], + "exclude-cases": [], + "exclude-agent-cases": {} } diff --git a/autobahn/fuzzingclient_tls.json b/autobahn/fuzzingclient_tls.json index fab38ddb41..4f824ef6ae 100644 --- a/autobahn/fuzzingclient_tls.json +++ b/autobahn/fuzzingclient_tls.json @@ -2,8 +2,8 @@ "outdir": "./reports/server_tls", "servers": [{ - "agent": "nim-ws tls server", - "url": "wss://127.0.0.1:8888/wss" + "agent": "nim-wss server", + "url": "wss://127.0.0.1:8889/wss" }], "cases": ["*"], diff --git a/autobahn/fuzzingserver.json b/autobahn/fuzzingserver.json index e409ac34fd..91f1ba485a 100644 --- a/autobahn/fuzzingserver.json +++ b/autobahn/fuzzingserver.json @@ -6,6 +6,6 @@ "webport": 8080, "cases": ["*"], - "exclude-cases": ["12.*", "13.*"], + "exclude-cases": [], "exclude-agent-cases": {} } diff --git a/autobahn/fuzzingserver_tls.json b/autobahn/fuzzingserver_tls.json index 587c485bd7..a10512cf8c 100644 --- a/autobahn/fuzzingserver_tls.json +++ b/autobahn/fuzzingserver_tls.json @@ -1,13 +1,13 @@ { - "url": "wss://127.0.0.1:9001", + "url": "wss://127.0.0.1:9002", "key": "tls/server.key", "cert": "tls/server.crt", "options": {"failByDrop": false}, "outdir": "./reports/client_tls", - "webport": 8080, + "webport": 8081, "cases": ["*"], - "exclude-cases": ["12.*", "13.*"], + "exclude-cases": [], "exclude-agent-cases": {} } diff --git a/examples/autobahn_client.nim b/examples/autobahn_client.nim index 2ede92c391..8629145c83 100644 --- a/examples/autobahn_client.nim +++ b/examples/autobahn_client.nim @@ -15,16 +15,23 @@ import const clientFlags = {NoVerifyHost, NoVerifyServerName} -const agent = when defined tls: - "nim-ws-tls-client" - else: - "nim-ws-client" -const secure = defined tls +# we want to run parallel tests in CI, +# so we are using different port +when defined tls: + const + agent = "nim-wss-client" + secure = true + serverPort = 9002 +else: + const + agent = "nim-ws-client" + secure = false + serverPort = 9001 proc connectServer(path: string): Future[WSSession] {.async.} = let ws = await WebSocket.connect( host = "127.0.0.1", - port = Port(9001), + port = Port(serverPort), path = path, secure=secure, flags=clientFlags diff --git a/examples/server.nim b/examples/server.nim index b8ccf00089..ff826c19ff 100644 --- a/examples/server.nim +++ b/examples/server.nim @@ -41,9 +41,16 @@ proc handle(request: HttpRequest) {.async.} = error "WebSocket error:", exception = exc.msg when isMainModule: + # we want to run parallel tests in CI + # so we are using different port + const serverAddr = when defined tls: + "127.0.0.1:8889" + else: + "127.0.0.1:8888" + proc main() {.async.} = let - address = initTAddress("127.0.0.1:8888") + address = initTAddress(serverAddr) socketFlags = {ServerFlags.TcpNoDelay, ServerFlags.ReuseAddr} server = when defined tls: TlsHttpServer.create(