Commit 16a8c954 authored by Boxiang Sun's avatar Boxiang Sun

peertube: restore fixup

parent 8cce20be
......@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum = 05c1fb674758ea66f8509d0710c89b28
md5sum = fb7b8ebb4724495a7d17ab93c8464515
......@@ -40,25 +40,20 @@ echo "Postgresql data directory is ready"
# which means if the postmaster.pid exist, then the postgresql is running.
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
if [ -e "$pid_file" ]; then
echo "postgresql is running, continue."
echo "Postgresql is running, continue."
else
echo "Stop postgresql service"
$${postgresql:bin}/pg_ctl -D $${postgresql:pgdata-directory} stop
wait
echo "Starting postgresql..."
echo ls $${postgresql:pgdata-directory}
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} &
# postgres_pid=$!
# echo $postgres_pid
# wait $postgres_pid
echo "Anyway, the postgresql is running..."
fi
if ! [ -e "$pid_file" ]; then
echo "postgresql exited..."
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}
wait
fi
tpgwait=60
while ! [ -e "$pid_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pid_file not exist"
test $tpgwait = 0 && die "Can not create pid_file"
echo "pid_file not exist; will retry $tpgwait times..." 1>&2
sleep 1
done
......@@ -76,15 +71,15 @@ echo "Ready to check postgresql is running..."
# initial db setup
# ( first quering PG several times waiting a bit till postgresql is started and ready )
# tpgwait=5
# while true; do
# pgtables="$(psql -c '\d' 2>&1)" && break
# tpgwait=$(( $tpgwait - 1 ))
# test $tpgwait = 0 && die "pg query problem"
# echo "I: PostgreSQL is not ready (yet ?); will retry $tpgwait times..." 1>&2
# sleep 1
# done
# echo "I: PostgreSQL ready." 1>&2
tpgwait=10
while true; do
pgtables="$(psql -c '\d' 2>&1)" && break
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pg query problem"
echo "I: PostgreSQL is not ready (yet ?); will retry $tpgwait times..." 1>&2
sleep 1
done
echo "I: PostgreSQL ready." 1>&2
# sleep 5
......@@ -115,4 +110,12 @@ if [ -e "$pid_file" ]; then
pkill -9 -f "$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}"
fi
tpgwait=60
while [ -e "$pid_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "Pid file always exist"
echo "I: Pid file still exist; will retry $tpgwait times..." 1>&2
sleep 1
done
echo "Postgresql process killed"
......@@ -337,7 +337,7 @@ class TestTheiaResiliencePeertube(test_resiliency.TestTheiaResilience):
# Compute backup date in the near future
soon = (datetime.now() + timedelta(minutes=4)).replace(second=0)
frequency = '%d * * * *' % soon.minute
params = '_={"frequency": "%s"}' % frequency
params = '"frequency"="%s"' % frequency
# Update Peertube parameters
print('Requesting Peertube with parameters %s' % params)
......@@ -367,6 +367,10 @@ class TestTheiaResiliencePeertube(test_resiliency.TestTheiaResilience):
postgres_bin = os.path.join(postgresql_partition, 'bin', 'postgres')
postgresql_srv = os.path.join(postgresql_partition, 'srv', 'postgresql')
# Stop all services
print("Stop all services")
self.callSlapos('node', 'stop', 'all')
# Check that the test instance is properly redeployed after restoring postgresql
# This restarts the services and checks the promises of the test instance
# Process twice to propagate state change
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment