ci: make vweb and websocket tests more robust to transient errors

pull/8867/head
Delyan Angelov 2021-02-20 20:24:15 +02:00
parent 28088cc494
commit 746dfe6317
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 8 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import io
const (
sport = 12380
exit_after_time = 7000 // milliseconds
exit_after_time = 9000 // milliseconds
vexe = os.getenv('VEXE')
vweb_logfile = os.getenv('VWEB_LOGFILE')
vroot = os.dir(vexe)

View File

@ -1,5 +1,6 @@
import x.websocket
import time
import rand
struct WebsocketTestResults {
pub mut:
@ -9,13 +10,14 @@ pub mut:
// tests with internal ws servers
fn test_ws() {
go start_server()
time.sleep_ms(100)
ws_test('ws://localhost:30000') or { assert false }
port := 30000 + rand.intn(1024)
go start_server(port)
time.sleep_ms(500)
ws_test('ws://localhost:$port') or { assert false }
}
fn start_server() ? {
mut s := websocket.new_server(30000, '')
fn start_server(listen_port int) ? {
mut s := websocket.new_server(listen_port, '')
// make that in execution test time give time to execute at least one time
s.ping_interval = 1