Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,21 @@ export LIVEKIT_URL="ws://localhost:7880" # or wss://your-server.livek
export LIVEKIT_TOKEN_A="<first participant token>"
export LIVEKIT_TOKEN_B="<second participant token>"

# Optional: a third participant (same room) for data stream tests that need a
# bystander, e.g. targeted streams. Tests that need it skip when it is unset.
export LIVEKIT_TOKEN_C="<third participant token>"

# Optional (for stress tests)
export RPC_STRESS_DURATION_SECONDS=3600 # Test duration (default: 1 hour)
export RPC_STRESS_CALLER_THREADS=4 # Concurrent caller threads (default: 4)
```

### Generating tokens for the test suites

The easiest path is to source the helper script, which mints both
The easiest path is to source the helper script, which mints the
participant tokens against a local `livekit-server --dev` and exports
`LIVEKIT_TOKEN_A`, `LIVEKIT_TOKEN_B`, and `LIVEKIT_URL` for the current shell:
`LIVEKIT_TOKEN_A`, `LIVEKIT_TOKEN_B`, `LIVEKIT_TOKEN_C`, and `LIVEKIT_URL` for
the current shell:

```bash
source scripts/set-test-tokens.sh
Expand All @@ -103,6 +108,10 @@ export LIVEKIT_TOKEN_B="$(lk token create --api-key devkey --api-secret secret -
--join --valid-for 99999h --room cpp_data_track_test \
--grant '{"canPublish":true,"canSubscribe":true,"canPublishData":true}' \
--token-only)"
export LIVEKIT_TOKEN_C="$(lk token create --api-key devkey --api-secret secret -i cpp-test-c \
--join --valid-for 99999h --room cpp_data_track_test \
--grant '{"canPublish":true,"canSubscribe":true,"canPublishData":true}' \
--token-only)"
```

## Installed SDK packaging tests
Expand Down
7 changes: 6 additions & 1 deletion scripts/set-test-tokens.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ fi
LIVEKIT_ROOM="cpp_data_track_test"
LIVEKIT_IDENTITY_A="cpp-test-a"
LIVEKIT_IDENTITY_B="cpp-test-b"
# Third participant for tests that need a bystander (e.g. targeted data streams).
LIVEKIT_IDENTITY_C="cpp-test-c"

if [[ $# -ne 0 ]]; then
_fail "this script is hard-coded and does not accept arguments" 2
Expand Down Expand Up @@ -107,22 +109,25 @@ _create_token() {

LIVEKIT_TOKEN_A="$(_create_token "$LIVEKIT_IDENTITY_A")"
LIVEKIT_TOKEN_B="$(_create_token "$LIVEKIT_IDENTITY_B")"
LIVEKIT_TOKEN_C="$(_create_token "$LIVEKIT_IDENTITY_C")"

_apply() {
export LIVEKIT_TOKEN_A
export LIVEKIT_TOKEN_B
export LIVEKIT_TOKEN_C
export LIVEKIT_URL
}

_emit_eval() {
printf 'export LIVEKIT_TOKEN_A=%q\n' "$LIVEKIT_TOKEN_A"
printf 'export LIVEKIT_TOKEN_B=%q\n' "$LIVEKIT_TOKEN_B"
printf 'export LIVEKIT_TOKEN_C=%q\n' "$LIVEKIT_TOKEN_C"
printf 'export LIVEKIT_URL=%q\n' "$LIVEKIT_URL"
}

if [[ "$_sourced" -eq 1 ]]; then
_apply
echo "LIVEKIT_TOKEN_A, LIVEKIT_TOKEN_B, and LIVEKIT_URL set for this shell." >&2
echo "LIVEKIT_TOKEN_A, LIVEKIT_TOKEN_B, LIVEKIT_TOKEN_C, and LIVEKIT_URL set for this shell." >&2
else
_emit_eval
echo "set_test_tokens: for this shell run: source $0 or: eval \"\$(bash $0)\"" >&2
Expand Down
Loading
Loading