ci: parallelise autobahn tests

This commit is contained in:
jangko 2021-06-20 13:57:07 +07:00
parent dbd76f78e2
commit fef04a1595
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
7 changed files with 66 additions and 44 deletions

View File

@ -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'

View File

@ -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": {}
}

View File

@ -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": ["*"],

View File

@ -6,6 +6,6 @@
"webport": 8080,
"cases": ["*"],
"exclude-cases": ["12.*", "13.*"],
"exclude-cases": [],
"exclude-agent-cases": {}
}

View File

@ -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": {}
}

View File

@ -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

View File

@ -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(