-
Notifications
You must be signed in to change notification settings - Fork 24
[CI] include pum check in CI to test datamodel upgrades #365
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0f70c25
[CI] run pum check to test upgraded datamodel VS initial datamodel
olivierdalang 7001c80
make script executable
olivierdalang ed4fcd3
[delta fix] EXECUTE FUNCTION does not exist before pg11
olivierdalang 6af09d7
pre/post-all scripts should raise exceptions on error
olivierdalang d2f25fe
drop the qwat_sigip schema from the dumps before testing
olivierdalang 3cbd5da
[fix init] add missing documents initialization scripts
olivierdalang 31ac335
[fix delta] fix index name inconsistency
olivierdalang 93802ea
Merge branch 'run-tests-in-ci' into test-pum-upgrade
olivierdalang 0aa4763
bump pum to pre-release
olivierdalang c497981
enable audit triggers in 1.3.6 release for CI
olivierdalang 0d7aadd
(reword comment)
olivierdalang 9be66c6
use new pum release
olivierdalang ab5ea4d
Merge branch 'master' of https://github.com/qwat/qwat-data-model.git …
olivierdalang 9482522
(fix code comment)
olivierdalang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pum | ||
pum>=0.10.0 | ||
psycopg2-binary | ||
pyyaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This tests that the database upgraded by PUM is consistent to the database | ||
# initialized by qwat_init.sh | ||
#It retrieves the | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
INIT_DB=1 | ||
|
||
while [[ $# > 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-h|--help) | ||
echo "Arguments:" | ||
echo -e "\t-h|--help\tShow this help screen" | ||
echo -e "\t-n|--no-init\tDo not init the test database" | ||
exit 0 | ||
;; | ||
-n|--no-init) | ||
INIT_DB=0 | ||
;; | ||
esac | ||
|
||
shift | ||
done | ||
|
||
PGSERVICE1=qwat_test | ||
PGSERVICE2=qwat_test_release | ||
VERSION=1.3.6 | ||
RELEASE_URL=https://github.com/qwat/qwat-data-model/releases/download/${VERSION}/qwat_v${VERSION}_data_and_structure_sample.backup | ||
RELEASE_LOCATION=/tmp/qwat_v${VERSION}.backup | ||
|
||
# Download the release if needed | ||
if [ -f "${RELEASE_LOCATION}" ]; then | ||
echo "Release file '$RELEASE_LOCATION' already exists, skipping download." | ||
else | ||
wget ${RELEASE_URL} -O ${RELEASE_LOCATION} --no-verbose | ||
fi | ||
|
||
# Initialize the databases (qwat_test for the init data, qwat_test_release for restoring the release dump) | ||
if [ "$INIT_DB" = "1" ]; then | ||
cd ${DIR}/.. | ||
./init_qwat.sh -p ${PGSERVICE1} -d | ||
cd - | ||
fi | ||
|
||
# Restore the release to qwat_test_release | ||
psql service=${PGSERVICE1} -c 'DROP DATABASE IF EXISTS qwat_test_release' | ||
psql service=${PGSERVICE1} -c 'CREATE DATABASE qwat_test_release' | ||
pum restore -p ${PGSERVICE2} -x ${RELEASE_LOCATION} | ||
|
||
# Drop qwat_sigip schema that is included in the release but that seems to | ||
# make migrations fail. | ||
# TODO: qwat_sigip should be probably be removed from the dumps, or if really obsolete, | ||
# removed from the source and dumped in a migration | ||
psql service=${PGSERVICE2} -c 'DROP SCHEMA qwat_sigip CASCADE' | ||
# despite being in qwat_od, this seems to be a qwat_sigip customization (created in data-model/.build/customizations/sigip/damage/damage.sql) | ||
psql service=${PGSERVICE2} -c 'DROP TABLE qwat_od.damage CASCADE' | ||
|
||
# Upgrade using pum | ||
pum upgrade -p ${PGSERVICE2} -t qwat_sys.info -d ${DIR}/../update/delta | ||
|
||
# Audit triggers are enabled in the init scripts, but not in the released 1.3.6 dump. | ||
# so we need to enable it, otherwise pum check will detect differences. | ||
psql service=${PGSERVICE2} -c 'SELECT qwat_sys.activate_audit_views()' | ||
|
||
# Compare results | ||
pum check -p1 ${PGSERVICE1} -p2 ${PGSERVICE2} --exclude-schema public --exclude-schema tiger --exclude-schema topology | ||
|
||
echo "Success 😁 !!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- This index was named differently in the delta than it is in the init script | ||
ALTER INDEX qwat_od.fki_leak_type RENAME TO fki_leak_fk_type; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bash builtin long option names with the double-dash prefix. This is an extension from GNU getopt (on macos and bsd-like you have to install gnu-getopt).
More details: #228
and from Denis https://stackoverflow.com/a/37485578 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from
tests.sh
, thus I suggest to keep it like that for consistency(to be honest, no idea what this is about :-D)