Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to prepare platform setup to run automation tests. #317

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions setup-e2e-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Script to load update-automation-snapshot into our database (to public schema)
# It needs the docker compose from saleor platform repository: https://github.com/saleor/saleor-platform
# Tested only on MacOs

DIR="$( cd "$( dirname "$0" )" && pwd )"
SNAPSHOT=$DIR"/update-automation-snapshot.sql"
# make sure to use `public` schema
sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT
sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT

# please note that you should not use this password on production services
DB_URL="postgresql://saleor:saleor@localhost:5432/"
# use different database for testing purpose
FULL_DB_URL=$DB_URL"e2e"

# drop previous database
psql $DB_URL -c 'DROP DATABASE IF EXISTS e2e WITH(FORCE);'

# create new database and make sure to install needed extensions
psql $DB_URL -c 'CREATE DATABASE e2e;'
psql $FULL_DB_URL -c 'CREATE EXTENSION IF NOT EXISTS btree_gin; CREATE EXTENSION IF NOT EXISTS pg_trgm;'

# load the snapshot
psql $FULL_DB_URL -f $SNAPSHOT

# make sure to run migrations in case snapshot is not up to date with `core` migrations
docker compose exec api python manage.py migrate
Loading