1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix all ports for the servers started in websocket_test.v

This commit is contained in:
Delyan Angelov 2023-02-25 14:33:22 +02:00
parent e7bf33b206
commit a7ae3bfa78
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -2,7 +2,6 @@ import os
import net import net
import net.websocket import net.websocket
import time import time
import rand
struct WebsocketTestResults { struct WebsocketTestResults {
pub mut: pub mut:
@ -26,9 +25,7 @@ fn test_ws_ipv6() {
if should_skip { if should_skip {
return return
} }
port := 30000 + rand.intn(1024) or { 0 } spawn start_server(.ip6, 30001)
eprintln('> port ipv6: ${port}')
spawn start_server(.ip6, port)
time.sleep(1500 * time.millisecond) time.sleep(1500 * time.millisecond)
ws_test(.ip6, 'ws://localhost:${port}') or { ws_test(.ip6, 'ws://localhost:${port}') or {
eprintln('> error while connecting .ip6, err: ${err}') eprintln('> error while connecting .ip6, err: ${err}')
@ -41,9 +38,7 @@ fn test_ws_ipv4() {
if should_skip { if should_skip {
return return
} }
port := 30000 + rand.intn(1024) or { 0 } spawn start_server(.ip, 30002)
eprintln('> port ipv4: ${port}')
spawn start_server(.ip, port)
time.sleep(1500 * time.millisecond) time.sleep(1500 * time.millisecond)
ws_test(.ip, 'ws://localhost:${port}') or { ws_test(.ip, 'ws://localhost:${port}') or {
eprintln('> error while connecting .ip, err: ${err}') eprintln('> error while connecting .ip, err: ${err}')
@ -52,6 +47,7 @@ fn test_ws_ipv4() {
} }
fn start_server(family net.AddrFamily, listen_port int) ! { fn start_server(family net.AddrFamily, listen_port int) ! {
eprintln('> start_server family:${family} | listen_port: ${listen_port}')
mut s := websocket.new_server(family, listen_port, '') mut s := websocket.new_server(family, listen_port, '')
// make that in execution test time give time to execute at least one time // make that in execution test time give time to execute at least one time
s.ping_interval = 1 s.ping_interval = 1
@ -129,8 +125,7 @@ fn ws_test(family net.AddrFamily, uri string) ! {
} }
fn test_on_close_when_server_closing_connection() ! { fn test_on_close_when_server_closing_connection() ! {
port := 30000 + rand.intn(1024) or { 0 } mut ws := websocket.new_server(.ip, 30003, '')
mut ws := websocket.new_server(.ip, port, '')
ws.on_message(fn (mut cli websocket.Client, msg &websocket.Message) ! { ws.on_message(fn (mut cli websocket.Client, msg &websocket.Message) ! {
if msg.opcode == .text_frame { if msg.opcode == .text_frame {
cli.close(1000, 'closing connection')! cli.close(1000, 'closing connection')!
@ -158,8 +153,7 @@ fn test_on_close_when_server_closing_connection() ! {
} }
fn test_on_close_when_client_closing_connection() ! { fn test_on_close_when_client_closing_connection() ! {
port := 30000 + rand.intn(1024) or { 0 } mut ws := websocket.new_server(.ip, 30004, '')
mut ws := websocket.new_server(.ip, port, '')
spawn ws.listen() spawn ws.listen()
mut client := websocket.new_client('ws://localhost:${port}')! mut client := websocket.new_client('ws://localhost:${port}')!