]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/clean/server/test.sh
1f1c9cec0bec60809a14ca63e5b6e5edd3b9d95e
[github/Chocobozzz/PeerTube.git] / scripts / clean / server / test.sh
1 #!/bin/sh
2
3 set -eu
4
5 recreateDB () {
6 dbname="peertube_test$1"
7
8 dropdb --if-exists "$dbname" 2>&1
9
10 createdb -O peertube "$dbname"
11 psql -c "CREATE EXTENSION pg_trgm;" "$dbname" &
12 psql -c "CREATE EXTENSION unaccent;" "$dbname" &
13 }
14
15 removeFiles () {
16 rm -rf "./test$1" "./config/local-test.json" "./config/local-test-$1.json" ~/.config/PeerTube/CLI-$1
17 }
18
19 dropRedis () {
20 port=$((9000+$1))
21 host="127.0.0.1"
22
23 redis-cli -h "$host" KEYS "bull-127.0.0.1:$port*" | grep -v empty | xargs -r redis-cli -h "$host" DEL
24 redis-cli -h "$host" KEYS "redis-127.0.0.1:$port*" | grep -v empty | xargs -r redis-cli -h "$host" DEL
25 redis-cli -h "$host" KEYS "*redis-127.0.0.1:$port-" | grep -v empty | xargs -r redis-cli -h "$host" DEL
26 }
27
28 seq=$(seq 1 6)
29
30 if [ ! -z ${1+x} ]; then
31 seq=$1
32 fi
33
34
35 for i in $seq; do
36 recreateDB "$i" &
37 dropRedis "$i" &
38 removeFiles "$i" &
39 done
40
41 wait