The relay refuses a subscription to a track nobody publishes yet (DOES_NOT_EXIST): the example now calls first, or waits for the encoder, and asks again until the gateway's tracks are there. The Rust examples' tests find their binaries under CARGO_TARGET_DIR when it is set. Co-Authored-By: Claude Opus 5.5 <[email protected]>
34 lines
1.8 KiB
Shell
Executable file
34 lines
1.8 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# The encoder-ingest example: `wai create` makes the project, its git dependencies are pointed
|
|
# at this checkout, and `--synthetic 4` sends four seconds over SRT into the room; every group
|
|
# of both tracks must verify against the gateway's receipts at the subscriber (exit 0).
|
|
#
|
|
# bash wai/examples/encoder-ingest/test/encoder-ingest.test.sh
|
|
# Needs wai on PATH and cargo.
|
|
set -uo pipefail
|
|
REPO=$(cd "$(dirname "$0")/../../../.." && pwd)
|
|
T=$(mktemp -d)
|
|
wai create "$T/ingest" --template encoder-ingest > /dev/null || { echo "FAIL wai create"; exit 1; }
|
|
cd "$T/ingest"
|
|
python3 - "$REPO" Cargo.toml <<'PY'
|
|
import sys
|
|
repo, p = sys.argv[1], sys.argv[2]
|
|
crates = {"joule-moq-ingest": "joule-code/joule-code-rs/crates/joule-moq-ingest", "joule-moq-relay": "joule-code/joule-code-rs/crates/joule-moq-relay",
|
|
"joule-moq": "joule-code/joule-code-rs/crates/joule-moq", "joule-contrib": "joule-code/joule-code-rs/crates/joule-contrib",
|
|
"wtransport": "joule-code/joule-code-rs/vendor/wtransport"}
|
|
git = 'git = "https://git.transaction.science/Transaction-Science/open-standards"'
|
|
out = []
|
|
for line in open(p).read().splitlines():
|
|
name = line.split("=")[0].strip()
|
|
if name in crates and git in line:
|
|
line = line.replace(git, f'path = "{repo}/{crates[name]}"')
|
|
out.append(line)
|
|
open(p, "w").write("\n".join(out) + "\n")
|
|
assert git not in open(p).read(), "every git dependency is pointed at the checkout"
|
|
PY
|
|
cargo build --release --quiet 2> build.log || { tail -30 build.log; echo "FAIL the example builds"; exit 1; }
|
|
s=0
|
|
timeout 120 "${CARGO_TARGET_DIR:-$PWD/target}/release/encoder-ingest" --synthetic 4 > run.log 2>&1 || s=$?
|
|
cat run.log
|
|
if [ $s = 0 ]; then echo "ok every group sent over SRT verified against the gateway's receipts at the subscriber"; else echo "FAIL the synthetic encoder's groups (exit $s)"; fi
|
|
exit $s
|