CICD-325 · WebSocket connectivity testing
Encyclopedia · Advanced networking and API testing · All snippets
Previous · CICD-324 · Next · CICD-326
1. Where it fits
- Placement CI run step or authorized lab terminal.
- Prerequisites authorized test service, known endpoint or local fixture and the named test CLI.
- Platforms local-linux, github-actions, gitea-actions.
- Parameters
WEBSOCKET_URL.
2. Copy the snippet
bash
printf '%s\n' '{"type":"ping"}' | websocat -1 -t "${WEBSOCKET_URL:?}" | jq -e '.type == "pong"'3. How it works
The tool connects to the supplied WebSocket and exchanges the fixture message over the negotiated session. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.
4. Verify the result
Use a fixture service implementing this ping/pong contract. Wrap with timeout to bound a silent peer.
Validation syntax-validated (Bash parse). Status definitions.