| 1 |
## Test get_collection_options command |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
## Tests start here |
| 7 |
|
| 8 |
CREATE SCHEMA xtest; |
| 9 |
CREATE USER test_user@localhost; |
| 10 |
|
| 11 |
--let $xtest_file= $MYSQL_TMP_DIR/admin_get_collection_options.xpl |
| 12 |
--write_file $xtest_file |
| 13 |
-->import validation_schema.macro |
| 14 |
-->import assert_status_variable.macro |
| 15 |
|
| 16 |
-->macro Get_collection_options %COLLECTION% |
| 17 |
stmtadmin get_collection_options |
| 18 |
{"schema": "xtest", "name": "%COLLECTION%", "options": ["validation"]}; |
| 19 |
-->recvresult |
| 20 |
-->endmacro |
| 21 |
|
| 22 |
|
| 23 |
-->echo |
| 24 |
-->echo |
| 25 |
-->echo ## I. Check invalid option setting for get_collection_options command. |
| 26 |
-->echo # |
| 27 |
-->echo # 1. Check just an invalid option. |
| 28 |
-->echo # 2. Check both valid and invalid options. |
| 29 |
-->echo |
| 30 |
-->echo ## II. Check get_collection_options when used for not existing schema. |
| 31 |
-->echo |
| 32 |
-->echo ## III. Check get_collection_options that returns a validation. |
| 33 |
-->echo # |
| 34 |
-->echo # 1. Get default validation schema. |
| 35 |
-->echo # 2. Get custom validation schema. |
| 36 |
-->echo # 3. Get custom validation schema and non-default validation level. |
| 37 |
-->echo # 4. Check command that returns string with special characters. |
| 38 |
-->echo |
| 39 |
-->echo ## IV. Get option for a collection user has no access to. |
| 40 |
-->echo # |
| 41 |
-->echo # 1. Collection does not exist. |
| 42 |
-->echo # 2. Collection exists. |
| 43 |
-->echo |
| 44 |
-->echo ## V. Check Mysqlx_stmt_get_collection_options variable. |
| 45 |
|
| 46 |
-->echo |
| 47 |
-->echo # |
| 48 |
-->echo # I.1 |
| 49 |
stmtadmin get_collection_options |
| 50 |
{"schema": "xtest", "name": "test_coll", "options": ["foo"]}; |
| 51 |
-->expecterror ER_X_COLLECTION_OPTION_DOESNT_EXISTS |
| 52 |
-->recvresult |
| 53 |
|
| 54 |
-->echo |
| 55 |
-->echo # |
| 56 |
-->echo # I.2 |
| 57 |
stmtadmin get_collection_options |
| 58 |
{"schema": "xtest", "name": "test_coll", "options": ["validation", "foo"]}; |
| 59 |
-->expecterror ER_X_COLLECTION_OPTION_DOESNT_EXISTS |
| 60 |
-->recvresult |
| 61 |
|
| 62 |
|
| 63 |
-->echo # I.3 |
| 64 |
stmtadmin get_collection_options |
| 65 |
{"schema": "xtest", "name": "test_coll", "options": []}; |
| 66 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 67 |
-->recvresult |
| 68 |
|
| 69 |
-->echo # I.4 |
| 70 |
stmtadmin get_collection_options |
| 71 |
{"schema": "xtest", "name": "test_coll", "options": [[]]}; |
| 72 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 73 |
-->recvresult |
| 74 |
|
| 75 |
-->echo # I.5 |
| 76 |
stmtadmin get_collection_options |
| 77 |
{"schema": "xtest", "name": "test_coll", "options": [[ "validation" ]]}; |
| 78 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 79 |
-->recvresult |
| 80 |
|
| 81 |
|
| 82 |
-->echo |
| 83 |
-->echo # |
| 84 |
-->echo # II |
| 85 |
-->expecterror ER_NO_SUCH_TABLE |
| 86 |
-->callmacro Get_collection_options test_coll |
| 87 |
|
| 88 |
-->echo |
| 89 |
-->echo # |
| 90 |
-->echo # III.1 |
| 91 |
-->stmtadmin create_collection {"schema": "xtest", "name": "test_coll"} |
| 92 |
-->recvresult |
| 93 |
-->callmacro Get_collection_options test_coll |
| 94 |
-->callmacro Drop_collection test_coll |
| 95 |
|
| 96 |
-->echo |
| 97 |
-->echo # |
| 98 |
-->echo # III.2 |
| 99 |
stmtadmin create_collection {"schema": "xtest", "name": "test_coll", "options": { |
| 100 |
"validation": { |
| 101 |
"schema": {"description": "test"} |
| 102 |
} |
| 103 |
}}; |
| 104 |
-->recvresult |
| 105 |
-->callmacro Get_collection_options test_coll |
| 106 |
-->callmacro Drop_collection test_coll |
| 107 |
|
| 108 |
-->echo |
| 109 |
-->echo # |
| 110 |
-->echo # III.3 |
| 111 |
stmtadmin create_collection {"schema": "xtest", "name": "test_coll", "options": { |
| 112 |
"validation": { |
| 113 |
"schema": {"description": "test"}, "level": "off" |
| 114 |
} |
| 115 |
}}; |
| 116 |
-->recvresult |
| 117 |
-->callmacro Get_collection_options test_coll |
| 118 |
-->callmacro Drop_collection test_coll |
| 119 |
|
| 120 |
-->echo |
| 121 |
-->echo # |
| 122 |
-->echo # III.4 |
| 123 |
stmtadmin create_collection {"schema": "xtest", "name": "test_coll", "options": { |
| 124 |
"validation": { |
| 125 |
"schema": {"description": "t`y\\p\"e o`b`\\\\c\"\"t"} |
| 126 |
} |
| 127 |
}}; |
| 128 |
-->recvresult |
| 129 |
stmtadmin get_collection_options |
| 130 |
{"schema": "xtest", "name": "test_coll", "options": ["validation"]}; |
| 131 |
-->recvresult |
| 132 |
-->callmacro Drop_collection test_coll |
| 133 |
|
| 134 |
-->echo |
| 135 |
-->echo # |
| 136 |
-->echo # IV.1 |
| 137 |
-->newsession temp test_user |
| 138 |
-->expecterror ER_TABLEACCESS_DENIED_ERROR |
| 139 |
-->callmacro Get_collection_options test_coll |
| 140 |
-->closesession |
| 141 |
|
| 142 |
-->echo |
| 143 |
-->echo # |
| 144 |
-->echo # IV.2 |
| 145 |
-->stmtadmin create_collection {"schema": "xtest", "name": "test_coll"} |
| 146 |
-->recvresult |
| 147 |
-->newsession temp test_user |
| 148 |
-->expecterror ER_TABLEACCESS_DENIED_ERROR |
| 149 |
-->callmacro Get_collection_options test_coll |
| 150 |
-->closesession |
| 151 |
-->callmacro Drop_collection test_coll |
| 152 |
|
| 153 |
-->echo |
| 154 |
-->echo # |
| 155 |
-->echo # V |
| 156 |
-->newsession temp |
| 157 |
-->quiet |
| 158 |
-->stmtadmin create_collection {"schema": "xtest", "name": "test_coll"} |
| 159 |
-->recvresult |
| 160 |
# Initial value. |
| 161 |
-->callmacro Assert_status_variable Mysqlx_stmt_get_collection_options 0 |
| 162 |
stmtadmin get_collection_options |
| 163 |
{"schema": "xtest", "name": "test_coll", "options": ["validation"]}; |
| 164 |
-->recvresult |
| 165 |
# After successful get_collection_options operation. |
| 166 |
-->callmacro Assert_status_variable Mysqlx_stmt_get_collection_options 1 |
| 167 |
stmtadmin get_collection_options |
| 168 |
{"schema": "xtest", "name": "test_coll", "options": ["foo"]}; |
| 169 |
-->recverror ER_X_COLLECTION_OPTION_DOESNT_EXISTS |
| 170 |
# After unsuccessful get_collection_options operation. |
| 171 |
-->callmacro Assert_status_variable Mysqlx_stmt_get_collection_options 2 |
| 172 |
stmtadmin get_collection_options |
| 173 |
{"schema": "xtest", "name": "test_coll", "options": ["validation"]}; |
| 174 |
-->recvresult |
| 175 |
# After next successful get_collection_options operation. |
| 176 |
-->callmacro Assert_status_variable Mysqlx_stmt_get_collection_options 3 |
| 177 |
-->callmacro Drop_collection test_coll |
| 178 |
-->closesession |
| 179 |
|
| 180 |
EOF |
| 181 |
|
| 182 |
--exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1 |
| 183 |
|
| 184 |
|
| 185 |
## Cleanup |
| 186 |
--source ../include/xplugin_cleanup.inc |
| 187 |
DROP USER test_user@localhost; |