1# Janus testing
2
3The files in this sub-folder are intended to be used for testing Janus.
4
5## aiortc functional testing
6
7We implemented some RTC Python clients based on [aiortc](https://github.com/aiortc/aiortc).
8In order to use them you'll need Python >= 3.4 (Python 3.6 is recommended).
9
10Also you'll need all of the [aiortc requirements](https://github.com/aiortc/aiortc#requirements) and the following python libraries:
11
12```bash
13pip3 install setuptools websockets aiortc
14```
15
16### echo.py
17
18This script does a quick echotest with a specified Janus instance.
19The source code has been largely inspired by the examples on the aiortc repository.
20The program basically initiates a Janus session through a WebSocket connection, then creates a new echotest handle and starts an audio/video negotiation according to the echotest API.
21
22Once everything has been succesfully set up, the client waits for 5 seconds and then checks the following assertions:
23* WebSocket is connected
24* ICE Connection State is completed
25* DTLS state is connected
26* outbound RTP packets are greater or equal than inbound RTP packets
27
28If any of these assertion fails, the client returns a non-zero value.
29No assertion has been made on the RTP packets to check if they contains valid media or not, I guess this is something that might be added in future.
30
31The script is invoked like this:
32
33```bash
34python3 echo.py ws://localhost:8188/ --play-from media_file --verbose
35```
36
37The websocket endpoint default is `ws://localhost:8188/`.
38The media_file is optional and if omitted dummy audio/video tracks will be generated.
39
40### The test_aiortc.sh helper script
41
42We have added a `test_aiortc.sh` helper script in order to easily launch a Janus aiortc-based test.
43The scripts must be invoked like this:
44
45```bash
46./test_aiortc.sh echo.py ws://localhost:8188/
47```
48
49It will start a Janus instance in the background taking the binary files from the Janus sources directory.
50Then it will wait for some seconds before invoking the Python script specified in the first parameter.
51Finally it will check the exit status of the Python script and kill the Janus instance.
52