Skip to content

WebSocket Testing Task

WebSocket Testing Task defines a WebSocket protocol testing task for functionality, performance, stability, and custom testing of WebSocket features.

Main Parameter List

Field NameTypeRequiredLength/RangeDescription
targetenumYes-Task Type Identifier
Fixed value: WEBSOCKET
namestringYes≤400 charsTask Unique Identifier
Example: Real-time Stock Quotes
descriptionstringNo≤800 charsTask Description
Detailed explanation of interface functionality
enabledbooleanYes-Enable Status
true: Enabled (default)
false: Disabled
apisIdinteger(int64)No-Interface Association ID
Links to AngusTester interface ID
Test results will update the corresponding interface
urlstringNo≤2000 charsComplete Request URL
Higher priority than server+endpoint combination
Example: wss://api.example.com/ws
serverobjectNo-Server Configuration
Includes protocol, host, port, etc.
Combined with endpoint to form complete URL
endpointstringNo≤800 charsRequest Endpoint
Combined with server to form complete URL
Example: /market/data
parametersarray[object]No1-7200 itemsRequest Parameters
Includes query parameters, path parameters, etc.
Configuration reference HTTP Request Parameters
modeenumYes-Message Interaction Mode
ONLY_SEND: Send only
ONLY_RECEIVE: Receive only
SEND_AND_RECEIVE: Bidirectional interaction (default)
messagestringNo≤8192 charsMessage Content to Send
Supports variables and Mock functions
Example: {"symbol":"{stockSymbol}"}
messageEncodingenumNo-Message Encoding Format
none: Raw text (default)
base64: Base64 encoded
gzip_base64: Gzip compressed then Base64
assertionsarray[object]No-Response Assertions
Supports content, size, duration validation
Configuration reference HTTP Assertions
datasetsarray[object]No-Test Datasets
Drives parameterized testing
Supports CSV/JSON formats
View Dataset Definition
actionOnEOFenumNo-Dataset End Policy
RECYCLE: Recycle (default)
STOP_THREAD: Stop thread
sharingModeenumNo-Data Sharing Mode
ALL_THREAD: Thread-shared (default)
CURRENT_THREAD: Thread-independent copy

Note

Multiple WebSocket interfaces can be orchestrated simultaneously, but only one WebSocket can be enabled for testing at a time.

Complete WebSocket configuration example:

yaml
- target: WEBSOCKET
  name: The `SEND_AND_RECEIVE` mode example
  description:
    "The client and server simultaneously remoting messages with each other,\
    \ default Mode."
  enabled: true
  url: ws://localhost:8082/example/SEND_AND_RECEIVE
  parameters:
    # Request parameter configuration ...
  mode: SEND_AND_RECEIVE
  message: Hi~
  messageEncoding: none
  assertions:
    # Assertion configuration ...
  datasets:
    # Dataset configuration ...
  actionOnEOF: RECYCLE
  sharingMode: ALL_THREAD

Message Modes (mode)

WebSocket performance testing mode scenarios:


1. ONLY_SEND (Send Only)


Performance Scenarios:

  • Data Reporting Systems: Device status, sensor data continuous reporting
  • Log Collection Systems: Distributed system log real-time transmission
  • Monitoring Data Push: Server metrics batch push

Performance Metrics:

  • Message send rate (msg/s)
  • Connection concurrency
  • Bandwidth utilization

2. ONLY_RECEIVE (Receive Only)


Performance Scenarios:

  • Market Subscription Systems: Stock/cryptocurrency real-time quotes push
  • Real-time Notification Systems: System alerts, order status change notifications
  • Event Broadcast Systems: Match scores, news real-time updates

Performance Metrics:

  • Message receive throughput (msg/s)
  • Message latency (ms)
  • Connection stability

3. SEND_AND_RECEIVE (Send and Receive)


Performance Scenarios:

  • Instant Messaging: Chat application message exchange
  • Device Control: Command sending and status feedback

Performance Metrics:

  • End-to-end latency (ms)
  • Transaction success rate (%)
  • Concurrent session count

Script Examples (target)

Complete Parameter Configuration Example

yaml
- target: WEBSOCKET
  name: The `SEND_AND_RECEIVE` mode example
  description:
    "The client and server simultaneously remoting messages with each other,\
    \ default Mode."
  enabled: true
  url: ws://localhost:8082/example/SEND_AND_RECEIVE
  parameters:
    - name: access_token
      in: query
      description: Authentication parameters when connecting to WebSocket.
      enabled: true
      type: string
      value: 17062ee76ea94bd28cf4eccc48a85f0e
    - name: ServerMessage
      in: query
      description:
        This is the simulated test client's expectation for the message to
        be returned by the server.
      enabled: true
      type: string
      value: Hi~ {name}
  mode: SEND_AND_RECEIVE
  message: Hi~
  messageEncoding: none
  assertions:
    - name: Assert that the received content includes SUCCESS.
      enabled: true
      type: BODY
      assertionCondition: CONTAIN
      expected: SUCCESS
    - name: Assert that the length of the received content does not exceed 1 KB.
      enabled: true
      type: SIZE
      assertionCondition: LESS_THAN
      expected: 1024
    - name:
        Assert that the time interval for receiving the latest message does not exceed
        200 milliseconds.
      enabled: true
      type: DURATION
      assertionCondition: EQUAL
      expected: 200
  datasets:
    - name: NameDataset
      parameters:
        - name: name
          value: '@Name()'
  actionOnEOF: RECYCLE
  sharingMode: ALL_THREAD

Client Only Sends Messages to Server (ONLY_SEND) Mode Example

yaml
- target: WEBSOCKET
  name: The `ONLY_SEND` mode example
  description: Only send custom messages to the server.
  enabled: true
  url: ws://localhost:8082/example/ONLY_SEND
  parameters:
    - name: access_token
      in: query
      description: Authentication parameters when connecting to WebSocket.
      enabled: true
      type: string
      value: 17062ee76ea94bd28cf4eccc48a85f0e
  mode: ONLY_SEND
  message: Hi~

Client Only Receives Messages from Server (ONLY_RECEIVE) Mode Example

yaml
- target: WEBSOCKET
  name: The `ONLY_RECEIVE` mode example
  description: Only receiving messages from the server and asserting them.
  enabled: true
  url: ws://localhost:8082/example/ONLY_RECEIVE
  parameters:
    - name: access_token
      in: query
      description: Authentication parameters when connecting to WebSocket.
      enabled: true
      type: string
      value: 17062ee76ea94bd28cf4eccc48a85f0e
    - name: ServerMessage
      in: query
      description: This is the simulated test client's expectation for the message to be returned by the server.
      enabled: true
      type: string
      value: This is a `SUCCESS` message returned by the server.
    - name: ServerDelay
      in: query
      description: This is the simulated test client's expectation for the delay(milliseconds) in the message returned by the server.
      enabled: true
      type: string
      value: 20-200
  mode: ONLY_RECEIVE
  assertions:
    - name: Assert that the received content includes SUCCESS.
      enabled: true
      type: BODY
      expected: SUCCESS
      assertionCondition: CONTAIN
    - name: Assert that the length of the received content does not exceed 1 KB.
      enabled: true
      type: SIZE
      expected: 1024
      assertionCondition: LESS_THAN
    - name:
        Assert that the time interval for receiving the latest message does not
        exceed 200 milliseconds.
      enabled: true
      type: DURATION
      expected: 200
      assertionCondition: LESS_THAN

Client Sends and Receives Messages (SEND_AND_RECEIVE) Mode Example

yaml
- target: WEBSOCKET
  name: The `SEND_AND_RECEIVE` mode example
  description: The client and server simultaneously remoting messages with each other, default Mode.
  enabled: true
  url: ws://localhost:8082/example/SEND_AND_RECEIVE
  parameters:
    - name: access_token
      in: query
      description: Authentication parameters when connecting to WebSocket.
      enabled: true
      type: string
      value: 17062ee76ea94bd28cf4eccc48a85f0e
    - name: ServerMessage
      in: query
      description: This is the simulated test client's expectation for the message to be returned by the server.
      enabled: true
      type: string
      value: Hi~
  mode: SEND_AND_RECEIVE
  message: Hi~
  assertions:
    - name: Assert that the received content includes SUCCESS.
      enabled: true
      type: BODY
      expected: Hi~
      assertionCondition: EQUAL

Released under the GPL-3.0 License.