2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2013-04-01 23:02:24 +02:00
|
|
|
|
|
|
|
function migration_status {
|
2016-09-13 22:40:13 +02:00
|
|
|
./manage.py get_migration_status --settings=zproject.test_settings > $1
|
2013-04-01 23:02:24 +02:00
|
|
|
}
|
2013-03-05 23:08:55 +01:00
|
|
|
|
2016-09-13 22:40:13 +02:00
|
|
|
if [ "$1" != "--force" ]; then
|
|
|
|
"$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" zulip zulip_test zulip_test_base zulip_test_template
|
|
|
|
psql -h localhost postgres zulip_test << EOF
|
2014-01-30 23:40:07 +01:00
|
|
|
DROP DATABASE IF EXISTS zulip_test;
|
2013-10-26 04:24:40 +02:00
|
|
|
CREATE DATABASE zulip_test TEMPLATE zulip_test_template;
|
2013-05-08 05:30:42 +02:00
|
|
|
EOF
|
2016-09-13 22:40:13 +02:00
|
|
|
sh "$(dirname "$0")/../../scripts/setup/flush-memcached"
|
|
|
|
exit 0
|
2013-03-05 23:08:55 +01:00
|
|
|
fi
|
|
|
|
|
2013-07-29 23:03:31 +02:00
|
|
|
mkdir -p zerver/fixtures
|
2013-01-10 22:58:01 +01:00
|
|
|
|
2016-05-26 12:40:41 +02:00
|
|
|
"$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" zulip zulip_test zulip_test_base zulip_test_template
|
2015-09-28 19:45:35 +02:00
|
|
|
|
2014-01-30 23:40:37 +01:00
|
|
|
psql -h localhost postgres zulip_test <<EOF
|
|
|
|
DROP DATABASE IF EXISTS zulip_test;
|
|
|
|
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
|
|
|
|
EOF
|
2016-05-26 12:40:41 +02:00
|
|
|
sh "$(dirname "$0")/../../scripts/setup/flush-memcached"
|
2014-01-30 23:40:37 +01:00
|
|
|
|
2016-11-22 01:44:16 +01:00
|
|
|
./manage.py migrate --noinput --settings=zproject.test_settings
|
2017-06-02 21:48:30 +02:00
|
|
|
migration_status "var/migration_status_test"
|
2013-04-01 23:02:24 +02:00
|
|
|
|
2015-08-20 23:47:05 +02:00
|
|
|
# This next line can be simplified to "-n0" once we fix our app (and tests) with 0 messages.
|
2016-11-22 01:44:16 +01:00
|
|
|
./manage.py populate_db --settings=zproject.test_settings --test-suite -n30 \
|
2013-01-08 21:59:52 +01:00
|
|
|
--threads=1 --huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
|
2016-11-22 01:44:16 +01:00
|
|
|
./manage.py dumpdata --settings=zproject.test_settings \
|
2013-07-29 23:03:31 +02:00
|
|
|
zerver.UserProfile zerver.Stream zerver.Recipient \
|
|
|
|
zerver.Subscription zerver.Message zerver.Huddle zerver.Realm \
|
|
|
|
zerver.UserMessage zerver.Client \
|
|
|
|
zerver.DefaultStream > zerver/fixtures/messages.json
|
2013-03-05 23:08:55 +01:00
|
|
|
|
2013-05-08 05:30:42 +02:00
|
|
|
# create pristine template database, for fast fixture restoration after tests are run.
|
2013-10-26 04:24:40 +02:00
|
|
|
psql -h localhost postgres zulip_test << EOF
|
2014-01-30 23:40:07 +01:00
|
|
|
DROP DATABASE IF EXISTS zulip_test_template;
|
2013-10-26 04:24:40 +02:00
|
|
|
CREATE DATABASE zulip_test_template TEMPLATE zulip_test;
|
2013-05-08 05:30:42 +02:00
|
|
|
EOF
|