chore: Add option of skipping migrations and using init-db script #19382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
It currently takes
~49 seconds
for a Postgres integration test to start-up locally, before executing any tests. (Different machines may have different results)This is not ideal for local development.
Looking into why it takes so long, revealed this info:
Goal
This PR aims to try to allow quicker running of integration tests locally.
This can be achieved by:
init-db.sql
script indhis2-core/dhis-2/dhis-support/dhis-support-test/src/main/resources/db
postgresTestDhis.conf
test config file withflyway.skip_migration = true
Without supplying this new file or changing the test properties, Flyway and tests operate as they always have. This just gives us the option of running quicker integration tests locally if we choose to.
Using this approach reduces start-up time from
~49 seconds
to~24 seconds
.Applying this setup locally
If this option is to be used, the following steps can be followed:
pg_dump --schema-only --no-owner dhis2 > ~/Documents/scripts/init-db.sql
(dhis2
is the DB name in this command)Then any time you want to use the new setup:
cp init-db.sql dhis2-core/dhis-2/dhis-support/dhis-support-test/src/main/resources/db
Of course, the
init-db.sql
would have to be refreshed from time to time (takes a few seconds).