Configuration for testing with minikube:
Clone policy-docker and navigate to policy-db-migrator folder
On a terminal do the following
- Download and install minikube on linux
- minikube config set driver docker
- minikube start -- mount -- mount-string ="/git/docker:/mnt" (that's where docker repo was cloned)
/git/docker/policy-db-migrator/src/main/docker folder should contain the following files: db-migrator, drools_policy_init.sh, prepare_downgrade.sh and prepare_upgrade.sh
- copy pom.xml to /git/docker/policy-db-migrator
- cd /git/docker/policy-db-migrator
- eval $(minikube -p minikube docker-env)
- mvn clean install (this will install the db-migrator image to minikube docker)
- ssh -i $(minikube ssh-key) docker@$(minikube ip)
- docker images – you should see the onap/policy-db-migrator image
- exit out of minikube
- kubectl create -f db.yaml
- kubectl get pods
- kubectl logs <db-migrator image name>
- kubectl delete -f db.yaml
- minikube stop
Test scenarios:
- Fresh install Honolulu
DB migrator should configure the database on Honolulu scripts.
Schema shouldn't exist
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o upgrade -t 0800
Expected result: schema is created and populated with tables and indexes.
- Fresh install Istanbul
DB migrator should configure the database on Istanbul scripts.
Expected result: schema is created and populated with tables and indexes.
- Downgrade Istanbul to Honolulu
DB migrator should change tables and indexes based on Istanbul downgrade scripts.
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o downgrade
Expected result: tables and indexes altered, but no data loss.
- Upgrade Honolulu to Istanbul
DB migrator should change tables and indexes based on Istanbul upgrade scripts.
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o upgrade
Expected result: tables and indexes altered, but no data loss.
- Upgrade Istanbul to Honolulu (fail scenario) (need to confirm if target is by number)
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o upgrade -t 0800 -f 0900
DB migrator should fail when upgrading to a down version.
Expected result: no changes on database, script has error result.
- Downgrade Honolulu to Istanbul (fail scenario)
DB migrator should fail when downgrading to an upper version.
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o downgrade -t 0900 -f 0800
Expected result: no changes on database, script has error result.
- Downgrade Honolulu
DB migrator should change tables and indexes based on Honolulu downgrade scripts.
Command: /opt/app/policy/bin/db-migrator -s policyadmin -o downgrade -t 0800
Expected result: tables and indexes are all dropped.
- Partial upgrade
- Upgrade to Honolulu
- Drop a table that is to be altered in Istanbul
- Upgrade to Istanbul
Expected result: script halts at the given table's upgrade script and updates the metadata table to indicate that it failed
- Downgrade to Honolulu
Expected result: script skips the missing table and completes successfully (though it doesn't re-create the table)
- Upgrade to Istanbul
Expected result: script halts at the given table's upgrade script and updates the metadata table to indicate that it failed
- Manually recreate the table
- Upgrade to Istanbul
Expected result: success
- Partial downgrade
- Upgrade to Istanbul
- Drop a table that is to be altered in Honolulu
- Downgrade to Honolulu
Expected result: script halts at the given table's upgrade script and updates the metadata table to indicate that it failed
- Upgrade to Istanbul
Expected result: script skips the missing table and completes successfully (though it doesn't re-create the table)
- Downgrade to Honolulu
Expected result: script halts at the given table's upgrade script and updates the metadata table to indicate that it failed
- Manually recreate the table
- Downgrade to Honolulu
Expected result: success
- Metadata database fails
When DB migrator starts, a metadata for historical changes is created/updated.
If metadata schema verification fails, script should return error.
Expected result: no changes on database, script has error result.
- Database information check fails
Username and password for accessing/creating schemas are invalid.
Expected result: no changes on database, script has error result.
- Database cannot connect
Server is unavailable.
Expected result: no changes on database, script has error result.
- Current schema already exists
If operation is valid, scripts should run with no issues.
Expected result: schema is populated with tables and indexes or tables and indexes are altered.