fix autobahn client to process multi messages test case

turn out the autobahn server not only use single echo
message for all test case, but also use multi messages
response to measure performance.
This commit is contained in:
jangko 2021-06-12 14:58:28 +07:00
parent 3634754621
commit 99d643013b
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 16 additions and 8 deletions

View File

@ -41,6 +41,7 @@ proc getCaseCount(): Future[int] {.async.} =
proc generateReport() {.async.} =
try:
trace "request autobahn server to generate report"
let ws = await connectServer("/updateReports?agent=" & agent)
while true:
let buff = await ws.recv()
@ -55,17 +56,24 @@ proc main() {.async.} =
trace "case count", count=caseCount
for i in 1..caseCount:
trace "runcase", no=i
let path = "/runCase?case=$1&agent=$2" % [$i, agent]
try:
let ws = await connectServer(path)
# echo back
let data = await ws.recv()
let opCode = if ws.binary:
Opcode.Binary
else:
Opcode.Text
await ws.send(data, opCode)
await ws.close()
while ws.readystate != ReadyState.Closed:
# echo back
let data = await ws.recv()
let opCode = if ws.binary:
Opcode.Binary
else:
Opcode.Text
if ws.readyState == ReadyState.Closed:
break
await ws.send(data, opCode)
except WebSocketError as exc:
error "WebSocket error", exception = exc.msg