]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/clean/server/test.sh
Cleanup tests
[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"
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"
17 }
18
19 dropRedis () {
20 redis-cli KEYS "bull-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL
21 redis-cli KEYS "redis-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL
22 }
23
24 seq=$(seq 1 6)
25
26 if [ ! -z ${1+x} ]; then
27 seq=$1
28 fi
29
30
31 for i in $seq; do
32 recreateDB "$i" &
33 dropRedis "$i" &
34 removeFiles "$i" &
35 done
36
37 wait