2
1

test.sh 878 B

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