2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2013-04-01 23:02:24 +02:00
|
|
|
|
2018-05-22 12:24:32 +02:00
|
|
|
export DJANGO_SETTINGS_MODULE=zproject.test_settings
|
|
|
|
|
2018-07-06 16:17:52 +02:00
|
|
|
create_template_database()
|
|
|
|
{
|
2019-04-02 01:00:57 +02:00
|
|
|
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test << EOF
|
2018-07-06 16:17:52 +02:00
|
|
|
DROP DATABASE IF EXISTS zulip_test_template;
|
|
|
|
CREATE DATABASE zulip_test_template TEMPLATE zulip_test;
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
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
|
2019-04-02 01:00:57 +02:00
|
|
|
psql -v ON_ERROR_STOP=1 -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
|
2019-10-01 23:42:35 +02:00
|
|
|
"$(dirname "$0")/../../scripts/setup/flush-memcached"
|
2016-09-13 22:40:13 +02:00
|
|
|
exit 0
|
2013-03-05 23:08:55 +01:00
|
|
|
fi
|
|
|
|
|
2018-04-19 20:17:24 +02:00
|
|
|
mkdir -p zerver/tests/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
|
|
|
|
2019-04-02 01:00:57 +02:00
|
|
|
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF
|
2014-01-30 23:40:37 +01:00
|
|
|
DROP DATABASE IF EXISTS zulip_test;
|
|
|
|
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
|
|
|
|
EOF
|
2019-10-01 23:42:35 +02:00
|
|
|
"$(dirname "$0")/../../scripts/setup/flush-memcached"
|
2014-01-30 23:40:37 +01:00
|
|
|
|
2018-05-22 12:24:32 +02:00
|
|
|
./manage.py migrate --noinput
|
|
|
|
./manage.py get_migration_status --output="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.
|
2018-05-22 12:24:32 +02:00
|
|
|
./manage.py populate_db --test-suite -n30 --threads=1 \
|
|
|
|
--huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
|
|
|
|
./manage.py dumpdata \
|
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 \
|
2018-04-19 20:17:24 +02:00
|
|
|
zerver.DefaultStream > zerver/tests/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.
|
2018-07-06 16:17:52 +02:00
|
|
|
create_template_database
|