File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ function err() {
1010 echo " $program : Error: $* " 1>&2 ;
1111 exit 2
1212}
13+ alias die=' err'
1314
1415function warn() {
1516 echo " $program : Warning: $* " 1>&2 ;
Original file line number Diff line number Diff line change @@ -47,9 +47,32 @@ say "Setting up the Django settings for the test suite"
4747cd $build
4848
4949settings_local=$( py_module_file " settings_local" )
50- [ " $settings_local " ] || err
50+ [ " $settings_local " ] || die " No setting_local file available "
5151
5252cat $settings_local test/settings_local_test.py > ietf/settings_local.py
5353
54+ # Acquire lock, to prevent running test and database update at the same time
55+
56+ LOCKDIR=$build /test/update-db.lock
57+ PIDFILE=$build /test/update-db.lock/pid
58+
59+ while true ; do
60+ if mkdir $build /test/update-db.lock; then
61+ echo " $$ " > $PIDFILE
62+ break
63+ else
64+ pid=$( < $PIDFILE ) || die " Couldn't read pidfile '$PIDFILE '"
65+ if kill -0 $pid ; then
66+ echo " Pidfile for process $pid exists, and process is running. Sleeping."
67+ sleep 10
68+ else
69+ echo " Pidfile for process $pid exists, but process isn't running."
70+ echo " Removing lock and old pid file $pidfile ."
71+ rm -rf $LOCKDIR
72+ break
73+ fi
74+ fi
75+ done
76+
5477
5578exit $warnings
Original file line number Diff line number Diff line change @@ -19,4 +19,9 @@ if echo "show databases;" | python ietf/manage.py dbshell | grep test_ietf; then
1919 echo " test database removed."
2020fi
2121
22+ # Release database update lock
23+
24+ LOCKDIR=$build /test/update-db.lock
25+ rm -rf $LOCKDIR
26+
2227exit $warnings
You can’t perform that action at this time.
0 commit comments