tools: Fix postgres-init-*-db cache handling.

Previously, it didn't properly update the stamp files that determine
our caching behavior, so if one ran test-backend afterwards, nothing
would happen.

A secondary issue that this commit does not fix is that provision will
end up rerunning the whole thing.
This commit is contained in:
Tim Abbott 2019-06-17 16:09:07 -07:00
parent 544f9c74ce
commit 9760c8cfc9
3 changed files with 17 additions and 8 deletions

View File

@ -140,11 +140,6 @@ def make_deploy_path():
timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
return os.path.join(DEPLOYMENTS_DIR, timestamp)
if __name__ == '__main__':
cmd = sys.argv[1]
if cmd == 'make_deploy_path':
print(make_deploy_path())
TEMPLATE_DATABASE_DIR = "test-backend/databases"
def get_dev_uuid_var_path(create_if_missing=False):
# type: (bool) -> str
@ -477,3 +472,10 @@ def get_or_create_dev_uuid_var_path(path: str) -> str:
absolute_path = '{}/{}'.format(get_dev_uuid_var_path(), path)
os.makedirs(absolute_path, exist_ok=True)
return absolute_path
if __name__ == '__main__':
cmd = sys.argv[1]
if cmd == 'make_deploy_path':
print(make_deploy_path())
elif cmd == 'get_dev_uuid':
print(get_dev_uuid_var_path())

View File

@ -25,15 +25,17 @@ if [[ $# == 0 ]]; then
PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)
DBNAME=zulip
SEARCH_PATH="$USERNAME",public
elif [[ $# == 4 ]]; then
STATUS_FILE_NAME="migration_status_dev"
elif [[ $# == 5 ]]; then
USERNAME=$1
PASSWORD=$2
DBNAME=$3
SEARCH_PATH=$4
STATUS_FILE_NAME=$5
else
echo "Usage Instructions"
echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)"
echo "or specify <db-username> <password> <db-name> <user-schema-search-path>"
echo "or specify <db-username> <password> <db-name> <user-schema-search-path> <migration-status-path>"
exit
fi
@ -49,6 +51,11 @@ if ! pg_isready -U "$POSTGRES_USER" -q; then
exit 1
fi
# We need to remove the stamp file indicating that the database
# is properly provisioned with migrations.
uuid_var_path=$($(readlink -f "$(dirname "$0")/../../scripts/lib/zulip_tools.py") get_dev_uuid)
rm -f "$uuid_var_path/$STATUS_FILE_NAME"
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DEFAULT_DB" << EOF
DO \$\$BEGIN
CREATE USER $USERNAME;

View File

@ -2,4 +2,4 @@
set -x
set -e
"$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public
"$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public migration_status_test