You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add protocol variant convention to UTS integration specs (G1)
Establish a convention for running data-path integration tests with both
JSON and msgpack protocols. Each annotated spec gets a Protocol Variants
section and uses PROTOCOL == "msgpack" instead of hardcoded
useBinaryProtocol: false.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: uts/docs/integration-testing.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,6 +236,66 @@ The goal is: every await in the test is bounded, and the suite timeout is genero
236
236
- Proxy tests should use proxy event logs for verification rather than timing-dependent assertions
237
237
- When tests pass in isolation but fail in the full suite, suspect sandbox rate limiting or connection exhaustion — increase the suite timeout rather than adding retries
238
238
239
+
## Protocol Variants
240
+
241
+
The Ably client library spec (G1) requires that tests run with all supported protocols. Integration tests that exercise the data encoding/decoding path must run with both JSON and msgpack to verify data integrity through the full encode-transmit-decode pipeline.
242
+
243
+
### Which tests need both protocols?
244
+
245
+
Only tests on the **data path** need both protocols. These are tests where messages, presence data, or other payloads pass through the SDK's encoding layer, through the server, and back. Examples include publish/subscribe round-trips, history retrieval, presence data, delta decoding, and mutable message operations.
246
+
247
+
Tests for **connection lifecycle**, **authentication**, **channel attach/detach**, and other protocol-agnostic behaviours do not need protocol variants. These tests exercise control-plane operations whose correctness does not depend on the wire encoding of message payloads.
248
+
249
+
**Proxy tests always use JSON.** The proxy only supports text WebSocket frames, so proxy-based tests cannot use msgpack.
250
+
251
+
### Spec file convention
252
+
253
+
A spec file that requires protocol variant testing includes a `## Protocol Variants` section immediately after `## Test Type`:
254
+
255
+
```markdown
256
+
## Test Type
257
+
Integration test against Ably sandbox
258
+
259
+
## Protocol Variants
260
+
json, msgpack
261
+
262
+
Each test in this file runs once per protocol variant. The `PROTOCOL` variable
263
+
is set to `"json"` or `"msgpack"` for the current run. Client options should set
264
+
`useBinaryProtocol: PROTOCOL == "msgpack"`.
265
+
```
266
+
267
+
The `PROTOCOL` variable is available in pseudocode and is set to `"json"` or `"msgpack"` for the current run. Client options use the standard pattern:
268
+
269
+
```pseudo
270
+
client = Rest(options: ClientOptions(
271
+
key: api_key,
272
+
endpoint: "nonprod:sandbox",
273
+
useBinaryProtocol: PROTOCOL == "msgpack"
274
+
))
275
+
```
276
+
277
+
### Default behaviour
278
+
279
+
Spec files **without** a `## Protocol Variants` section default to JSON only. No special handling is required in derived test implementations for these specs.
280
+
281
+
### Annotated specs
282
+
283
+
The following integration test specs are annotated with `## Protocol Variants`:
The proxy mediates between the SDK and the real Ably server. It is not a mock server. Tests should be written to rely on actual server responses as much as possible, with the proxy intervening only where necessary to create the specific fault or error condition under test.
Copy file name to clipboardExpand all lines: uts/docs/writing-test-specs.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ This guide provides comprehensive guidance for writing portable test specificati
15
15
- Run against `https://sandbox.realtime.ably-nonprod.net`
16
16
- Provision apps via `POST /apps` with body from `ably-common/test-resources/test-app-setup.json`
17
17
- Use `endpoint: "nonprod:sandbox"` in ClientOptions
18
+
-**Protocol variants:** Data-path tests (publish, history, presence, etc.) must run with both JSON and msgpack. Add a `## Protocol Variants` section after `## Test Type` and use `useBinaryProtocol: PROTOCOL == "msgpack"` in ClientOptions. See `docs/integration-testing.md` for the full convention. Specs without this header default to JSON only.
18
19
19
20
### Proxy Integration Tests (Ably Sandbox via Proxy)
20
21
- Run against Ably Sandbox through a programmable proxy ([ably/uts-proxy](https://github.com/ably/uts-proxy))
0 commit comments