Skip to content

Commit

Permalink
Update dev-tools.sh script to install extension and run JDBC tests in…
Browse files Browse the repository at this point in the history
… multi-db migration mode by default (#2991)

This commit updates dev-tools.sh script to install Babelfish extension and run JDBC tests in multi-db migration mode by default.

Signed-off-by: Sumit Jaiswal [email protected]
  • Loading branch information
sumitj824 authored Sep 30, 2024
1 parent d74ad40 commit 2b0b6d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions INSTALLING.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,16 @@ ${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "CREATE EXTENSION IF N
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "GRANT ALL ON SCHEMA sys to babelfish_user;"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "ALTER USER babelfish_user CREATEDB;"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db';"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "SELECT pg_reload_conf();"
```


By default, the `migration_mode` is `single-db`. To deploy in `multi-db` mode, you need to modify the Babelfish configuration file before initializing the database:
The recommended `migration_mode` is `multi-db`. To run in `single-db` mode, you need to modify the Babelfish configuration file before initializing the database:

```sh
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "ALTER DATABASE babelfish_db SET babelfishpg_tsql.migration_mode = 'multi-db';"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'single-db';"
${BABELFISH_HOME}/bin/psql -d babelfish_db -U postgres -c "SELECT pg_reload_conf();"
```

> For more information about the `migration_mode`, see [Single vs. multiple instances](https://babelfishpg.org/docs/installation/single-multiple/) and [Choosing a migration mode](https://babelfishpg.org/docs/installation/single-multiple/#choosing-a-migration-mode).
Expand Down
4 changes: 2 additions & 2 deletions dev-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [ ! $1 ]; then
echo " run pg_upgrade from SOURCE_WS to TARGET_WS"
echo ""
echo " test normal [MIGRATION_MODE] [TEST_BASE_DIR]"
echo " run a normal JDBC test, default migration mode and test dir are single-db and input, respectively"
echo " run a normal JDBC test, default migration mode and test dir are multi-db and input, respectively"
echo ""
echo " test TEST_MODE MIGRATION_MODE TEST_BASE_DIR"
echo " run a prepare/verify JDBC test using a schedule file in TEST_BASE_DIR"
Expand Down Expand Up @@ -89,7 +89,7 @@ elif [ "$1" == "test" ]; then
MIGRATION_MODE=$3
if [ ! ${MIGRATION_MODE} ]; then
if [ "${TEST_MODE?}" == "normal" ]; then
MIGRATION_MODE="single-db"
MIGRATION_MODE="multi-db"
else
echo "Error: MIGRATION_MODE should be specified, single-db or multi-db" 1>&2
exit 1
Expand Down
1 change: 1 addition & 0 deletions test/JDBC/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ psql -d postgres -U "$USER" << EOF
\c jdbc_testdb
CALL sys.remove_babelfish();
ALTER SYSTEM RESET babelfishpg_tsql.database_name;
ALTER SYSTEM RESET babelfishpg_tsql.migration_mode;
SELECT pg_reload_conf();
\c postgres
DROP DATABASE jdbc_testdb WITH (FORCE);
Expand Down
2 changes: 2 additions & 0 deletions test/JDBC/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GRANT ALL ON SCHEMA sys to jdbc_user;
ALTER USER jdbc_user CREATEDB;
\c jdbc_testdb
ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';
ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';
SELECT pg_reload_conf();
\c jdbc_testdb
show babelfishpg_tsql.database_name;
Expand All @@ -51,6 +52,7 @@ GRANT ALL ON SCHEMA sys to jdbc_user;
ALTER USER jdbc_user CREATEDB;
\c jdbc_testdb
ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';
ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';
ALTER SYSTEM SET parallel_setup_cost = 0;
ALTER SYSTEM SET parallel_tuple_cost = 0;
ALTER SYSTEM SET min_parallel_index_scan_size = 0;
Expand Down

0 comments on commit 2b0b6d5

Please sign in to comment.