1 .. This work is licensed under a Creative Commons Attribution
2 .. 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
5 Policy DB Migrator Smoke Tests
6 ##############################
11 Check number of files in each release
16 ls 0800/upgrade/*.sql | wc -l = 96
17 ls 0900/upgrade/*.sql | wc -l = 13
18 ls 0800/downgrade/*.sql | wc -l = 96
19 ls 0900/downgrade/*.sql | wc -l = 13
27 /opt/app/policy/bin/prepare_upgrade.sh policyadmin
28 /opt/app/policy/bin/db-migrator -s policyadmin -o upgrade
31 You can also run db-migrator upgrade with the -t and -f options
39 /opt/app/policy/bin/prepare_downgrade.sh policyadmin
40 /opt/app/policy/bin/db-migrator -s policyadmin -o downgrade -f 0900 -t 0800
42 Db migrator initialization script
43 =================================
45 Update /oom/kubernetes/policy/resources/config/db_migrator_policy_init.sh with the appropriate upgrade/downgrade calls.
47 The policy version you are deploying should either be an upgrade or downgrade from the current db migrator schema version.
49 Every time you modify db_migrator_policy_init.sh you will have to undeploy, make and redeploy before updates are applied.
58 * - Number of files run
60 * - Tables in policyadmin
67 2. Downgrade to Honolulu (0800)
68 *******************************
70 Modify db_migrator_policy_init.sh - remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
72 Make/Redeploy to run downgrade.
78 * - Number of files run
80 * - Tables in policyadmin
87 3. Upgrade to Istanbul (0900)
88 *****************************
90 Modify db_migrator_policy_init.sh - remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts".
92 Make/Redeploy to run upgrade.
98 * - Number of files run
100 * - Tables in policyadmin
107 4. Upgrade to Istanbul (0900) without any information in the migration schema
108 *****************************************************************************
110 Ensure you are on release 0800. (This may require running a downgrade before starting the test)
112 Drop db-migrator tables in migration schema:
117 DROP TABLE schema_versions;
118 DROP TABLE policyadmin_schema_changelog;
120 Modify db_migrator_policy_init.sh - remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts".
122 Make/Redeploy to run upgrade.
128 * - Number of files run
130 * - Tables in policyadmin
137 5. Upgrade to Istanbul (0900) after failed downgrade
138 ****************************************************
140 Ensure you are on release 0900.
142 Rename pdpstatistics table in policyadmin schema:
146 RENAME TABLE pdpstatistics TO backup_pdpstatistics;
148 Modify db_migrator_policy_init.sh - remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
150 Make/Redeploy to run downgrade
152 This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
154 Rename backup_pdpstatistic table in policyadmin schema:
158 RENAME TABLE backup_pdpstatistics TO pdpstatistics;
160 Modify db_migrator_policy_init.sh - Remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
162 Make/Redeploy to run upgrade
168 * - Number of files run
170 * - Tables in policyadmin
177 6. Downgrade to Honolulu (0800) after failed downgrade
178 ******************************************************
180 Ensure you are on release 0900.
182 Add timeStamp column to papdpstatistics_enginestats:
186 ALTER TABLE jpapdpstatistics_enginestats ADD COLUMN timeStamp datetime DEFAULT NULL NULL AFTER UPTIME;
188 Modify db_migrator_policy_init.sh - remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
190 Make/Redeploy to run downgrade
192 This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
194 Remove timeStamp column from jpapdpstatistics_enginestats:
198 ALTER TABLE jpapdpstatistics_enginestats DROP COLUMN timeStamp;
200 The config job will retry 5 times. If you make your fix before this limit is reached you won't need to redeploy.
202 Redeploy to run downgrade
208 * - Number of files run
210 * - Tables in policyadmin
217 7. Downgrade to Honolulu (0800) after failed upgrade
218 ****************************************************
220 Ensure you are on release 0800.
222 Modify db_migrator_policy_init.sh - remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
224 Update pdpstatistics:
228 ALTER TABLE pdpstatistics ADD COLUMN POLICYUNDEPLOYCOUNT BIGINT DEFAULT NULL NULL AFTER POLICYEXECUTEDSUCCESSCOUNT;
230 Make/Redeploy to run upgrade
232 This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
234 Once the retry count has been reached, update pdpstatistics:
238 ALTER TABLE pdpstatistics DROP COLUMN POLICYUNDEPLOYCOUNT;
240 Modify db_migrator_policy_init.sh - Remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
242 Make/Redeploy to run downgrade
248 * - Number of files run
250 * - Tables in policyadmin
257 8. Upgrade to Istanbul (0900) after failed upgrade
258 **************************************************
260 Ensure you are on release 0800.
262 Modify db_migrator_policy_init.sh - remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
268 ALTER TABLE pdp ADD COLUMN LASTUPDATE datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER HEALTHY;
270 Make/Redeploy to run upgrade
272 This should result in an error (last row in policyadmin_schema_changelog will have a success value of 0)
278 ALTER TABLE pdp DROP COLUMN LASTUPDATE;
280 The config job will retry 5 times. If you make your fix before this limit is reached you won't need to redeploy.
282 Redeploy to run upgrade
288 * - Number of files run
290 * - Tables in policyadmin
297 9. Downgrade to Honolulu (0800) with data in pdpstatistics and jpapdpstatistics_enginestats
298 *******************************************************************************************
300 Ensure you are on release 0900.
302 Check pdpstatistics and jpapdpstatistics_enginestats are populated with data.
307 SELECT count(*) FROM pdpstatistics;
308 SELECT count(*) FROM jpapdpstatistics_enginestats;
310 Modify db_migrator_policy_init.sh - remove any lines referencing upgrade and add the 2 lines under "Downgrade scripts"
312 Make/Redeploy to run downgrade
314 Check the tables to ensure the number records is the same.
319 SELECT count(*) FROM pdpstatistics;
320 SELECT count(*) FROM jpapdpstatistics_enginestats;
322 Check pdpstatistics to ensure the primary key has changed:
326 SELECT column_name, constraint_name FROM information_schema.key_column_usage WHERE table_name='pdpstatistics';
328 Check jpapdpstatistics_enginestats to ensure id column has been dropped and timestamp column added.
332 SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_name = 'jpapdpstatistics_enginestats';
334 Check the pdp table to ensure the LASTUPDATE column has been dropped.
338 SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_name = 'pdp';
345 * - Number of files run
347 * - Tables in policyadmin
354 10. Upgrade to Istanbul (0900) with data in pdpstatistics and jpapdpstatistics_enginestats
355 ******************************************************************************************
357 Ensure you are on release 0800.
359 Check pdpstatistics and jpapdpstatistics_enginestats are populated with data.
364 SELECT count(*) FROM pdpstatistics;
365 SELECT count(*) FROM jpapdpstatistics_enginestats;
367 Modify db_migrator_policy_init.sh - remove any lines referencing downgrade and add the 2 lines under "Upgrade scripts"
369 Make/Redeploy to run upgrade
371 Check the tables to ensure the number records is the same.
376 SELECT count(*) FROM pdpstatistics;
377 SELECT count(*) FROM jpapdpstatistics_enginestats;
379 Check pdpstatistics to ensure the primary key has changed:
383 SELECT column_name, constraint_name FROM information_schema.key_column_usage WHERE table_name='pdpstatistics';
385 Check jpapdpstatistics_enginestats to ensure timestamp column has been dropped and id column added.
389 SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_name = 'jpapdpstatistics_enginestats';
391 Check the pdp table to ensure the LASTUPDATE column has been added and the value has defaulted to the CURRENT_TIMESTAMP.
395 SELECT table_name, column_name, data_type, column_default FROM information_schema.columns WHERE table_name = 'pdp';
401 * - Number of files run
403 * - Tables in policyadmin
411 The number of records added may vary depnding on the number of retries.