| 1 |
--source include/have_ndb.inc |
| 2 |
|
| 3 |
## |
| 4 |
# (1) Make a backup. This is the "pre-backup" |
| 5 |
# (2) Create an NDB stored user u@n |
| 6 |
# (3) Make a backup. This is the "post-backup" |
| 7 |
# (4) Stop MySQL server #2 |
| 8 |
# (5) Drop the NDB stored user |
| 9 |
# (6) Stop MySQL server #1 |
| 10 |
# |
| 11 |
# (Test A): Restore the pre-backup using ndb_restore -r -m --include-stored-grants |
| 12 |
# ndb_restore succeeds. The stored user is not created. |
| 13 |
# |
| 14 |
# (Test B): Restore the post-backup using ndb_restore -r -m. |
| 15 |
# ndb_restore succeeds, but the stored user is not created. |
| 16 |
# |
| 17 |
# (Test C): Restore the post-backup using ndb_restore -r -m --include-stored-grants. |
| 18 |
# ndb_restore succeeds and the stored user is created. |
| 19 |
# |
| 20 |
# (7) Use ndb_delete_all to delete all records from ndb_sql_metadata |
| 21 |
# |
| 22 |
# (Test D): Restore the post-backup in two steps, using: |
| 23 |
# ndb_restore -r -m --include-store-grants --disable-indexes |
| 24 |
# ndb_restore -r -m --rebuild-indexes |
| 25 |
# ndb_restore succeeds and the stored user is created. |
| 26 |
# |
| 27 |
# (8) Restart the MySQL servers |
| 28 |
# |
| 29 |
# (Test E): DROP USER u@n |
| 30 |
# This succeeds on both MySQL servers, proving that the user exists |
| 31 |
## |
| 32 |
|
| 33 |
|
| 34 |
# (1) Make a backup. This is the "pre-backup" |
| 35 |
SELECT 1; |
| 36 |
exec $NDB_MGM -e "start backup" >> $NDB_TOOLS_OUTPUT; |
| 37 |
let $pre_id = `SELECT id FROM ndbinfo.backup_id`; |
| 38 |
let $TOPBDIR = $NDB_BACKUP_DIR/BACKUP; |
| 39 |
let $PRE_B = $TOPBDIR/BACKUP-$pre_id; |
| 40 |
|
| 41 |
# (2) Create an NDB stored user u@n |
| 42 |
CREATE USER u@n; |
| 43 |
GRANT ndb_stored_user ON *.* to u@n; |
| 44 |
|
| 45 |
# (3) Make a backup. This is the "post-backup" |
| 46 |
exec $NDB_MGM -e "start backup" >> $NDB_TOOLS_OUTPUT; |
| 47 |
let $post_id = `SELECT id FROM ndbinfo.backup_id`; |
| 48 |
let $POST_B = $TOPBDIR/BACKUP-$post_id; |
| 49 |
|
| 50 |
# (4) Stop MySQL server #2 |
| 51 |
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.1.expect |
| 52 |
wait |
| 53 |
EOF |
| 54 |
--connect (server2,127.0.0.1,root,,test,$MASTER_MYPORT1,) |
| 55 |
--shutdown_server |
| 56 |
--source include/wait_until_disconnected.inc |
| 57 |
|
| 58 |
# (5) Drop the NDB stored user |
| 59 |
--connection default |
| 60 |
DROP USER u@n; |
| 61 |
|
| 62 |
# (6) Stop MySQL server #1 |
| 63 |
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect |
| 64 |
wait |
| 65 |
EOF |
| 66 |
--shutdown_server |
| 67 |
--source include/wait_until_disconnected.inc |
| 68 |
|
| 69 |
# Set a file to collect the output from ndb_restore |
| 70 |
--let R_OUT = $MYSQLTEST_VARDIR/tmp/ndb_restore.out |
| 71 |
|
| 72 |
# (Test A): Restore the pre-backup using ndb_restore -r -m --include-stored-grants |
| 73 |
# ndb_restore succeeds. The stored user is not created. |
| 74 |
--exec echo "Test A" >> $R_OUT |
| 75 |
--exec $NDB_RESTORE -b $pre_id -n 1 -m -r --include-stored-grants $PRE_B >> $R_OUT |
| 76 |
--exec $NDB_RESTORE -b $pre_id -n 2 -r --include-stored-grants $PRE_B >> $R_OUT |
| 77 |
--echo Expect 1 row: |
| 78 |
--exec $NDB_SELECT_COUNT -d mysql ndb_sql_metadata |
| 79 |
|
| 80 |
# (Test B): Restore the post-backup using ndb_restore -r -m. |
| 81 |
# ndb_restore succeeds, but the stored user is not created. |
| 82 |
--exec echo "Test B" >> $R_OUT |
| 83 |
--exec $NDB_RESTORE -b $post_id -n 1 -m -r $POST_B >> $R_OUT |
| 84 |
--exec $NDB_RESTORE -b $post_id -n 2 -r $POST_B >> $R_OUT |
| 85 |
--echo Expect 1 row: |
| 86 |
--exec $NDB_SELECT_COUNT -d mysql ndb_sql_metadata |
| 87 |
|
| 88 |
# (Test C): Restore the post-backup using ndb_restore -r --include-stored-grants. |
| 89 |
# ndb_restore succeeds and the stored user is created. |
| 90 |
--exec echo "Test C" >> $R_OUT |
| 91 |
--exec $NDB_RESTORE -b $post_id -n 1 -m -r --include-stored-grants $POST_B >> $R_OUT |
| 92 |
--exec $NDB_RESTORE -b $post_id -n 2 -r --include-stored-grants $POST_B >> $R_OUT |
| 93 |
--echo Expect 4 rows: |
| 94 |
--exec $NDB_SELECT_COUNT -d mysql ndb_sql_metadata |
| 95 |
|
| 96 |
# |
| 97 |
# (7) Use ndb_delete_all to delete all records from ndb_sql_metadata |
| 98 |
--exec $NDB_DELETE_ALL -d mysql ndb_sql_metadata >> $NDB_TOOLS_OUTPUT |
| 99 |
--echo Expect 0 rows: |
| 100 |
--exec $NDB_SELECT_COUNT -d mysql ndb_sql_metadata |
| 101 |
|
| 102 |
# (Test D): Restore the post-backup in two steps, using: |
| 103 |
# ndb_restore -r -m --include-store-grants --disable-indexes |
| 104 |
# ndb_restore -r -m --rebuild-indexes |
| 105 |
# ndb_restore succeeds and the stored user is created. |
| 106 |
--exec echo "Test D (Disable Indexes)" >> $R_OUT |
| 107 |
--exec $NDB_RESTORE -b $post_id -n 1 -m -r --include-stored-grants --disable-indexes $POST_B >> $R_OUT |
| 108 |
--exec $NDB_RESTORE -b $post_id -n 2 -r --include-stored-grants --disable-indexes $POST_B >> $R_OUT |
| 109 |
--exec echo "Test D (Rebuild Indexes)" >> $R_OUT |
| 110 |
--exec $NDB_RESTORE -b $post_id -n 1 --rebuild-indexes $POST_B >> $R_OUT |
| 111 |
--exec $NDB_RESTORE -b $post_id -n 2 --rebuild-indexes $POST_B >> $R_OUT |
| 112 |
--echo Expect 4 rows: |
| 113 |
--exec $NDB_SELECT_COUNT -d mysql ndb_sql_metadata |
| 114 |
|
| 115 |
# (8) Restart the MySQL servers |
| 116 |
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.1.expect |
| 117 |
restart |
| 118 |
EOF |
| 119 |
|
| 120 |
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect |
| 121 |
restart |
| 122 |
EOF |
| 123 |
|
| 124 |
--connection default |
| 125 |
--let $wait_counter= 10000 |
| 126 |
--enable_reconnect |
| 127 |
--source include/wait_until_connected_again.inc |
| 128 |
|
| 129 |
--connection server2 |
| 130 |
--let $wait_counter= 10000 |
| 131 |
--enable_reconnect |
| 132 |
--source include/wait_until_connected_again.inc |
| 133 |
|
| 134 |
# (Test E): DROP USER u@n |
| 135 |
# This succeeds on both MySQL servers, proving that the user exists |
| 136 |
--connection default |
| 137 |
DROP USER u@n; |
| 138 |
|
| 139 |
|
| 140 |
# Cleanup |
| 141 |
--force-rmdir $TOPBDIR |
| 142 |
--remove_file $R_OUT |
| 143 |
--remove_file $NDB_TOOLS_OUTPUT |
| 144 |
|