ws-test

module
v0.0.0-...-b92263b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2022 License: MIT

README

Web-socket test util

Build Status Go Report Card Docker

About

Tool for test web-socket tuned infrastructure.

Binary/container working modes:
  • Server
    • EPoll-based, unix systems only
    • Goroutine-based
  • Client
    • Goroutine-based
Communication protocol

Messages format: proto

  1. Server listen specified tcp port
  2. Client simultaneously opens configured number of web-socket connections
  3. For each established connection:
    1. Client sends Msg with ClientID, that contains index of client's connection
    2. Server periodically sends Msg with ServerPing
    3. Client answers by Msg with ClientPong
  4. On the client connect error, retries with random-based exponential backoff

Install

  • Build binary: go get -u github.com/e-zhydzetski/ws-test/cmd/ws-test
  • Pull docker image: docker pull zhydzetski/ws-test:latest

Usage

$ docker run --rm zhydzetski/ws-test
 Build time: 20200607111259
 Usage of ./ws-test:
   -client-connect-addr string
         client connect to address (default "ws://127.0.0.1:8888")
   -client-threads int
         parallel client sessions (default 100)
   -debug string
         debug server listen address. Empty - disabled. Use :8000 for http://127.0.0.1:8000/debug/pprof
   -server
         server mode, client otherwise
   -server-epoll
         epoll-based server, goroutines otherwise
   -server-listen-addr string
         server listen address (default ":8888")
   -server-ping-interval duration
         server ping interval (default 10s)
   -server-ws-pool int
         max size of server web-socket goroutine pool (default 10)

... is equal to ./ws-test --help

Working example with docker-compose

$ ./docker-compose up
Starting ws-test_server_1 ... done
Recreating ws-test_client_1 ... done
Attaching to ws-test_server_1, ws-test_client_1
server_1  | 2020/06/07 12:15:58 Debug server listen on :8000
server_1  | 2020/06/07 12:15:58 epoll websocket is listening on [::]:8888
server_1  | 2020/06/07 12:15:58 WS pool size: 10
server_1  | 2020/06/07 12:15:59 accept error: schedule error: timed out; retrying in 5ms
server_1  | 2020/06/07 12:15:59 accept error: schedule error: timed out; retrying in 5ms
client_1  | 2020/06/07 12:16:00 Interval: 26.792042ms ; Connects: 100 ; Writes: 100 ; Reads: 100
server_1  | 2020/06/07 12:16:00 Interval: 21.241459ms ; Connects: 100 ; Writes: 100 ; Reads: 100
client_1  | 2020/06/07 12:16:10 Interval: 19.680935ms ; Connects: 0 ; Writes: 100 ; Reads: 100
server_1  | 2020/06/07 12:16:10 Interval: 19.915359ms ; Connects: 0 ; Writes: 100 ; Reads: 100
Gracefully stopping... (press Ctrl+C again to force)
Stopping ws-test_client_1   ... done
Stopping ws-test_server_1   ... done

Based on

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL