| 1 | #!/bin/bash |
| 2 | |
| 3 | set -eu -o pipefail |
| 4 | |
| 5 | if [ $# -lt 2 ] |
| 6 | then |
| 7 | echo "USAGE: start-rt-test.sh <uid> <rt-test-id>" |
| 8 | echo " - <uid> is your bastion uid you use to log in to parsoidtest1001/testreduce1002" |
| 9 | echo " - <rt-test-id> is the test id to show up in the testreduce web UI (usually a 8-char prefix of a git hash)" |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | uid=$1 |
| 14 | testid=$2 |
| 15 | |
| 16 | # By convention we truncate testids to 8 characters, but some users |
| 17 | # copy-and-paste full git hashes on the command line. Normalize. |
| 18 | testid=$(echo -n "$testid" | head -c 8) |
| 19 | |
| 20 | # Update code on parsoidtest1001 since RT testing scripts will hit the Parsoid REST API on parsoidtest1001 |
| 21 | echo "---- Updating code on parsoidtest1001 ----" |
| 22 | ssh "$uid"@parsoidtest1001.eqiad.wmnet <<EOF |
| 23 | # No unset vars + early exit on error |
| 24 | set -eu -o pipefail |
| 25 | |
| 26 | umask 0002 # Make sure everyone in wikidev group can write |
| 27 | cd /srv/parsoid-testing |
| 28 | git fetch |
| 29 | git checkout $testid |
| 30 | git log --oneline -n 1 |
| 31 | sudo systemctl restart php7.4-fpm.service |
| 32 | EOF |
| 33 | |
| 34 | echo "---- Starting test run $testid on testreduce1002 ----" |
| 35 | ssh "$uid"@testreduce1002.eqiad.wmnet <<EOF |
| 36 | # No unset vars + early exit on error |
| 37 | set -eu -o pipefail |
| 38 | |
| 39 | # Check if we need to free disk space |
| 40 | df /srv/data --output=pcent | tail -n 1 | awk '0+\$1 > 80 {print; print "Free disk space to continue!\nSee https://wikitech.wikimedia.org/wiki/Parsoid/Common_Tasks#Freeing_disk_space"; exit 1}' |
| 41 | |
| 42 | echo 'Stopping parsoid-rt clients ...' |
| 43 | sudo service parsoid-rt-client stop |
| 44 | |
| 45 | echo 'Updating deploy repo checkout ...' |
| 46 | cd /srv/parsoid-testing |
| 47 | |
| 48 | # Strictly speaking, it is not necessary to update code on testreduce1002 |
| 49 | # It is only needed if rt-testing related code is updated. |
| 50 | # But, it is simpler to just update it every single time. |
| 51 | umask 0002 # Make sure everyone in wikidev group can write |
| 52 | git fetch |
| 53 | git checkout $testid |
| 54 | git log --oneline -n 1 |
| 55 | |
| 56 | echo 'Adding new test id ...' |
| 57 | echo $testid > /srv/parsoid-testing/tests/testreduce/parsoid.rt-test.ids |
| 58 | |
| 59 | echo 'Starting parsoid-rt clients ...' |
| 60 | sudo service parsoid-rt-client restart |
| 61 | |
| 62 | echo "---- Tailing logs from parsoid-rt (^C when you are satisfied) ----" |
| 63 | sudo journalctl -f -u parsoid-rt |
| 64 | EOF |