musicbrainz-server icon indicating copy to clipboard operation
musicbrainz-server copied to clipboard

Add an `--initial-sql` flag to InitDb.pl; allow configuring the `REPLICATION_TYPE` for create_test_db.sh

Open mwiencek opened this issue 11 months ago • 1 comments

This is based on top of https://github.com/metabrainz/musicbrainz-server/pull/3194

Problem

This resolves two problems:

  • ./admin/InitDb.pl currently always runs admin/sql/InsertDefaultRows.sql on the database, and this cannot be configured (e.g., to specify a different initialization script, or use none at all).
  • ./script/create_test_db.sh currently cannot be used to initialize a mirror test database (i.e., one without foreign keys or triggers).

I'd like to fix these issues in order to improve the test suites that make use of replication packets (and thus require separate master/mirror test databases).

Solution

With this PR, you can set the REPLICATION_TYPE environment variable before running ./script/create_test_db.sh:

REPLICATION_TYPE=1 ./script/create_test_db.sh # master
REPLICATION_TYPE=2 ./script/create_test_db.sh # mirror
REPLICATION_TYPE=3 ./script/create_test_db.sh # standalone

See associated commits for details.

Testing

Just manual invocations of the create_test_db.sh and InitDb.pl commands, plus automated tests.

mwiencek avatar Mar 06 '24 21:03 mwiencek

About testing. What has been tested so far? Is there a setup that you would like us to test in particular?

Mainly the commands I listed in the PR description:

REPLICATION_TYPE=1 ./script/create_test_db.sh # master
REPLICATION_TYPE=2 ./script/create_test_db.sh # mirror
REPLICATION_TYPE=3 ./script/create_test_db.sh # standalone

and making sure the created databases have the appropriate customizations (e.g., mirrors should be without foreign keys/triggers, masters should have replication triggers).

mwiencek avatar May 27 '24 19:05 mwiencek