#!/bin/bash
set -e

echo "Running Migrations...."
python manage.py migrate --settings=pari.settings.test --noinput

echo "Running Collectstatic...."
python manage.py collectstatic --noinput

echo "Starting Server..........."
python manage.py runserver --settings=pari.settings.test > /dev/null 2>&1 &

expected_response=200
end=$((SECONDS+60))

while [ "$SECONDS" -lt "$end" ];
do
  sleep 2
  response=`curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/pages/donate/`

  echo "Waiting for service to start...."
  if [ "$response" == "$expected_response" ]
  then
    is_service_started='true'
    echo "Service Started........."
    break
  fi
done
if [ "$is_service_started" != 'true' ];
then
   echo "Unable to start the service........"
   exit 1
fi

echo "Running test......."
python manage.py test --settings=pari.settings.test --keepdb --nologcapture --verbosity=2
#!/bin/bash
set -e

echo "Running Migrations...."
python manage.py migrate --settings=pari.settings.test --noinput

echo "Running Collectstatic...."
python manage.py collectstatic --noinput

echo "Starting Server..........."
python manage.py runserver --settings=pari.settings.test > /dev/null 2>&1 &

CURRENT_TIME='date +%s'
TIMEOUT_TIME=$((`eval $CURRENT_TIME`+60))

while [ `eval $CURRENT_TIME` -lt "$TIMEOUT_TIME" ];
do
  sleep 2
  response=`curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/pages/donate/`

  echo "Waiting for service to start...."
  if [ $response -eq 200 ]
  then
    is_service_started='true'
    echo "Service Started........."
    break
  fi
done
if [ "$is_service_started" != 'true' ];
then
   echo "Unable to start the service........"
   exit 1
fi

echo "Running test......."
python manage.py test --settings=pari.settings.test --keepdb --nologcapture --verbosity=2
Fix wait condition of the script
Fix wait condition of the script
