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 nim c -d:release examples/server.nim
examples/server & examples/server &
pid=$! server1=$!
cd autobahn
wstest --mode fuzzingclient --spec fuzzingclient.json
kill $pid
cd ..
nim c -d:tls -d:release examples/server.nim nim c -d:tls -d:release -o:examples/tls_server examples/server.nim
examples/server & examples/tls_server &
pid=$! server2=$!
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
cd autobahn cd autobahn
wstest --mode fuzzingserver --spec fuzzingserver_tls.json & wstest --webport=0 --mode fuzzingserver --spec fuzzingserver.json &
pid=$! 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 .. cd ..
nim c -r -d:tls -d:release examples/autobahn_client nim c -d:release examples/autobahn_client
kill $pid 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. - name: Deploy autobahn report.
if: runner.os == 'linux' && matrix.target.cpu == 'amd64' && github.event_name == 'push' if: runner.os == 'linux' && matrix.target.cpu == 'amd64' && github.event_name == 'push'

View File

@ -1,12 +1,12 @@
{ {
"outdir": "./reports/server", "outdir": "./reports/server",
"servers": [
{ "servers": [{
"agent": "nim-ws example server", "agent": "nim-ws server",
"url": "ws://127.0.0.1:8888/ws" "url": "ws://127.0.0.1:8888/ws"
} }],
],
"cases": ["*"], "cases": ["*"],
"exclude-cases": [], "exclude-cases": [],
"exclude-agent-cases": {} "exclude-agent-cases": {}
} }

View File

@ -2,8 +2,8 @@
"outdir": "./reports/server_tls", "outdir": "./reports/server_tls",
"servers": [{ "servers": [{
"agent": "nim-ws tls server", "agent": "nim-wss server",
"url": "wss://127.0.0.1:8888/wss" "url": "wss://127.0.0.1:8889/wss"
}], }],
"cases": ["*"], "cases": ["*"],

View File

@ -6,6 +6,6 @@
"webport": 8080, "webport": 8080,
"cases": ["*"], "cases": ["*"],
"exclude-cases": ["12.*", "13.*"], "exclude-cases": [],
"exclude-agent-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", "key": "tls/server.key",
"cert": "tls/server.crt", "cert": "tls/server.crt",
"options": {"failByDrop": false}, "options": {"failByDrop": false},
"outdir": "./reports/client_tls", "outdir": "./reports/client_tls",
"webport": 8080, "webport": 8081,
"cases": ["*"], "cases": ["*"],
"exclude-cases": ["12.*", "13.*"], "exclude-cases": [],
"exclude-agent-cases": {} "exclude-agent-cases": {}
} }

View File

@ -15,16 +15,23 @@ import
const const
clientFlags = {NoVerifyHost, NoVerifyServerName} clientFlags = {NoVerifyHost, NoVerifyServerName}
const agent = when defined tls: # we want to run parallel tests in CI,
"nim-ws-tls-client" # so we are using different port
else: when defined tls:
"nim-ws-client" const
const secure = defined tls 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.} = proc connectServer(path: string): Future[WSSession] {.async.} =
let ws = await WebSocket.connect( let ws = await WebSocket.connect(
host = "127.0.0.1", host = "127.0.0.1",
port = Port(9001), port = Port(serverPort),
path = path, path = path,
secure=secure, secure=secure,
flags=clientFlags flags=clientFlags

View File

@ -41,9 +41,16 @@ proc handle(request: HttpRequest) {.async.} =
error "WebSocket error:", exception = exc.msg error "WebSocket error:", exception = exc.msg
when isMainModule: 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.} = proc main() {.async.} =
let let
address = initTAddress("127.0.0.1:8888") address = initTAddress(serverAddr)
socketFlags = {ServerFlags.TcpNoDelay, ServerFlags.ReuseAddr} socketFlags = {ServerFlags.TcpNoDelay, ServerFlags.ReuseAddr}
server = when defined tls: server = when defined tls:
TlsHttpServer.create( TlsHttpServer.create(