├── LICENSE ├── NOTICE.md ├── README.md ├── test-browser.sh ├── test-cron.sh └── test-runner.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 &yet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | # turn-prober.sh 2 | 3 | Copyright (c) 2014, The WebRTC project authors. 4 | https://github.com/GoogleChrome/webrtc/blob/master/samples/web/content/apprtc/turn-prober/turn-prober.sh 5 | https://github.com/GoogleChrome/webrtc/blob/master/LICENSE 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | webrtc-tester 2 | ============= 3 | 4 | WebRTC Deployment Testing Toolkit 5 | 6 | See [this blogpost](https://blog.andyet.com/2014/09/29/testing-webrtc-applications) about how we use this for testing [Talky](https://talky.io) deployments. 7 | 8 | #Required software 9 | * xvfb 10 | * sqlite3 11 | * python-pip 12 | * google-chrome 13 | * chromium-browser 14 | * firefox 15 | * mozrunner (via pip/easy\_install) 16 | 17 | #Recommended reading 18 | The webrtc team has published two excellent blog posts on automatted interop testing between Firefox and Chrome: 19 | * [Chrome - Firefox WebRTC Interop Test - Part 1](http://googletesting.blogspot.se/2014/08/chrome-firefox-webrtc-interop-test-pt-1.html) 20 | * [Chrome - Firefox WebRTC Interop Test - Part 2](http://googletesting.blogspot.se/2014/09/chrome-firefox-webrtc-interop-test-pt-2.html) 21 | 22 | The test scripts in this repository are based on a technique demonstrated by the 23 | [turn-prober.sh](https://github.com/GoogleChrome/webrtc/blob/master/samples/web/content/apprtc/turn-prober/turn-prober.sh) script. 24 | -------------------------------------------------------------------------------- /test-browser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Copyright © 2014 &yet 3 | # 4 | # based on https://github.com/GoogleChrome/webrtc/blob/master/samples/web/content/apprtc/turn-prober/turn-prober.sh 5 | # Copyright (c) 2014, The WebRTC project authors. All rights reserved. 6 | # see https://github.com/GoogleChrome/webrtc/blob/master/LICENSE 7 | 8 | # evaluate command line arguments 9 | BROWSER=$1 10 | HOST=$2 11 | ROOM=$3 12 | COND=$4 13 | URL=https://${HOST}/${ROOM} 14 | 15 | function browser_pids() { 16 | case "$BROWSER" in 17 | "google-chrome" | "google-chrome-stable" | "google-chrome-beta" | "google-chrome-unstable") 18 | ps axuwww|grep $D|grep c[h]rome|awk '{print $2}' 19 | ;; 20 | "chromium-browser") 21 | ps axuwww|grep $D|grep c[h]romium-browser|awk '{print $2}' 22 | ;; 23 | "firefox") 24 | ps axuwww|grep $D|grep f[i]refox|awk '{print $2}' 25 | ;; 26 | esac 27 | } 28 | 29 | function cleanup() { 30 | exec 3>&2 31 | exec 2>/dev/null 32 | while [ ! -z "$(browser_pids)" ]; do 33 | kill -9 $(browser_pids) 34 | done 35 | exec 2>&3 36 | exec 3>&- 37 | rm -rf $D 38 | } 39 | trap cleanup EXIT 40 | 41 | # make a new profile 42 | case "$BROWSER" in 43 | "google-chrome" | "google-chrome-stable" | "google-chrome-beta" | "google-chrome-unstable" | "chromium-browser") 44 | cd $(dirname $0) 45 | D=$(mktemp -d) 46 | ;; 47 | "firefox") 48 | D=`mozprofile --pref="media.navigator.permission.disabled:true" --pref="browser.dom.window.dump.enabled:true"` 49 | ;; 50 | esac 51 | 52 | # prefill localstorage 53 | case "$BROWSER" in 54 | "google-chrome" | "google-chrome-stable" | "google-chrome-beta" | "google-chrome-unstable" | "chromium-browser") 55 | LOCALSTORAGE_DIR="${D}/Default/Local Storage/" 56 | mkdir -p "${LOCALSTORAGE_DIR}" 57 | sqlite3 "${LOCALSTORAGE_DIR}/https_${HOST}_0.localstorage" << EOF 58 | PRAGMA encoding = "UTF-16"; 59 | CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL); 60 | INSERT INTO ItemTable (key, value) VALUES ("debug", "true"); 61 | INSERT INTO ItemTable (key, value) VALUES ("skipHaircheck", "true"); 62 | EOF 63 | ;; 64 | "firefox") 65 | REVERSEHOST=`echo ${HOST} | rev` 66 | sqlite3 "${D}/webappsstore.sqlite" << EOF 67 | CREATE TABLE webappsstore2 (scope TEXT, key TEXT, value TEXT, secure INTEGER, owner TEXT); 68 | CREATE UNIQUE INDEX scope_key_index ON webappsstore2(scope, key); 69 | INSERT INTO webappsstore2 (scope, key, value) VALUES ("${REVERSEHOST}.:https:443", "debug", "true"); 70 | INSERT INTO webappsstore2 (scope, key, value) VALUES ("${REVERSEHOST}.:https:443", "skipHaircheck", "true"); 71 | INSERT INTO webappsstore2 (scope, key, value) VALUES ("${REVERSEHOST}.:https:443", "useFirefoxFakeDevice", "true"); 72 | EOF 73 | ;; 74 | esac 75 | 76 | # create log file 77 | LOG_FILE="${D}/browser.log" 78 | touch $LOG_FILE 79 | 80 | # setup xvfb 81 | XVFB="xvfb-run -a -e $LOG_FILE -s '-screen 0 1024x768x24'" 82 | if [ -n "$DISPLAY" ]; then 83 | XVFB="" 84 | fi 85 | 86 | # run xvfb 87 | # "eval" below is required by $XVFB containing a quoted argument. 88 | case "$BROWSER" in 89 | "google-chrome" | "google-chrome-stable" | "google-chrome-beta" | "google-chrome-unstable" | "chromium-browser") 90 | eval $XVFB $BROWSER \ 91 | --enable-logging=stderr \ 92 | --no-first-run \ 93 | --no-default-browser-check \ 94 | --disable-translate \ 95 | --user-data-dir=$D \ 96 | --use-fake-ui-for-media-stream \ 97 | --use-fake-device-for-media-stream \ 98 | --vmodule="*media/*=3,*turn*=3" \ 99 | "${URL}" > $LOG_FILE 2>&1 & 100 | PID=$! 101 | ;; 102 | "firefox") 103 | eval $XVFB mozrunner \ 104 | -p ${D} \ 105 | --binary ${BROWSER} \ 106 | --app-arg=${URL} > $LOG_FILE 2>&1 & 107 | PID=$! 108 | ;; 109 | esac 110 | 111 | # wait for stop condition to appear in log 112 | while ! grep -q "${COND}" $LOG_FILE && browser_pids|grep -q .; do 113 | sleep 0.1 114 | done 115 | 116 | # give the peer a little time to notice 117 | sleep 5 118 | 119 | # evaluate whether we were successful 120 | DONE=$(grep "${COND}" $LOG_FILE) 121 | EXIT_CODE=0 122 | if ! grep -q "${COND}" $LOG_FILE; then 123 | cat $LOG_FILE 124 | EXIT_CODE=1 125 | fi 126 | 127 | exit $EXIT_CODE 128 | -------------------------------------------------------------------------------- /test-cron.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Argument 1: host 3 | if [ -z "$1" ]; then 4 | echo "missing 'host' argument (string)" 5 | exit 1 6 | fi 7 | 8 | # Argument 2: condition 9 | if [ -z "$2" ]; then 10 | echo "missing 'condition' argument (string)" 11 | exit 1 12 | fi 13 | 14 | # Run test 15 | cd /opt/sbin/webrtc-tester/ 16 | TEST=$(./test-runner.sh "$1" "$2") 17 | 18 | # A pass produces no output, so test for string for a test fail 19 | if [ -n "$TEST" ]; then 20 | echo "[alert] $1: WEBRTC TEST FAIL" | tee /opt/sbin/webrtc-tester/test.log 21 | echo "$TEST" | tee -a /opt/sbin/webrtc-tester/test.log 22 | 23 | # Send your alert 24 | /opt/sbin/send-alert.sh /opt/sbin/webrtc-tester/test.log 25 | fi -------------------------------------------------------------------------------- /test-runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TIMEOUT="90" 3 | DISPLAY= 4 | HOST=${1:-"beta.talky.io"} 5 | ROOM="automatedtesting_${RANDOM}" 6 | COND=${2:-"P2P connected"} # talky 7 | #COND="data channel open" # talky pro 8 | #COND="ICE connection state changed to: connected" # apprtc 9 | #COND="onCallActive" # go 10 | #COND="Data channel opened" # meet 11 | 12 | # make sure we kill any Xvfb instances 13 | function cleanup() { 14 | function xvfb_pids() { 15 | ps x -o "%r %p %c" | grep X[v]fb | grep $$ | awk '{print $2}' 16 | } 17 | exec 3>&2 18 | exec 2>/dev/null 19 | while [ ! -z "$(xvfb_pids)" ]; do 20 | kill $(xvfb_pids) 21 | done 22 | pkill -HUP -P $pidwatch 23 | pkill -HUP -P $pidwatch2 24 | exec 2>&3 25 | exec 3>&- 26 | } 27 | trap cleanup EXIT 28 | 29 | # this timeout is for the overall test process 30 | ( sleep ${TIMEOUT} ) & 31 | pidwatcher=$! 32 | 33 | # browser #1 34 | ( ./test-browser.sh google-chrome $HOST "${ROOM}" "${COND}" >> log1.log 2>&1 ; kill $pidwatcher 2> /dev/null ) 2>/dev/null & 35 | pidwatch=$! 36 | 37 | # browser #2 38 | ( ./test-browser.sh chromium-browser $HOST "${ROOM}" "${COND}" >> log2.log 2>&1 ; kill $pidwatcher 2> /dev/null ) 2>/dev/null & 39 | pidwatch2=$! 40 | 41 | #echo "${pidwatcher} watching ${pidwatch} ${pidwatch2}" 42 | 43 | if wait $pidwatcher 2>/dev/null; then 44 | echo "--- timedout" 45 | cat log1.log 46 | cat log2.log 47 | fi 48 | # do nothing in the case of success 49 | --------------------------------------------------------------------------------