| 1 |
## Preamble |
| 2 |
--source include/xplugin_preamble.inc |
| 3 |
--source include/xplugin_create_user.inc |
| 4 |
|
| 5 |
## TEST STARTS HERE |
| 6 |
--write_file $MYSQL_TMP_DIR/too_large.xpl |
| 7 |
-->import wait_until_disconnect.macro |
| 8 |
-->import connection.macro |
| 9 |
|
| 10 |
# |
| 11 |
# The X Protocol message is defined in following way |
| 12 |
# |
| 13 |
# | <------------------- X Protocol frame ----------------------------------> | |
| 14 |
# | | | |
| 15 |
# | <--- payload-size ---> | <--------------- payload ----------------------> | |
| 16 |
# | | | | |
| 17 |
# | | <-- msg-type --> | <---- Protobuf-payload -----> | |
| 18 |
# | 4 bytes | 1 byte | n bytes | |
| 19 |
|
| 20 |
# |
| 21 |
# Such messages either might be send directly on the wire or compressed and |
| 22 |
# encapsulated inside 'Mysqlx.Connection.Compression' message under payload |
| 23 |
# field. |
| 24 |
# |
| 25 |
# The test will send X protocol frame with empty compression message or with empty |
| 26 |
# payload and observe an error and disconnect. |
| 27 |
# |
| 28 |
|
| 29 |
-->macro New_session_with_caps %SESS% %COMP_ALGO% |
| 30 |
newsession %SESS% -; |
| 31 |
-->quiet |
| 32 |
callmacro Verify_its_xprotocol_connection; |
| 33 |
Mysqlx.Connection.CapabilitiesSet { |
| 34 |
capabilities { |
| 35 |
capabilities { |
| 36 |
name: "compression" |
| 37 |
value { |
| 38 |
type: OBJECT |
| 39 |
obj { |
| 40 |
fld { |
| 41 |
key: "algorithm" |
| 42 |
value { |
| 43 |
type: SCALAR |
| 44 |
scalar { |
| 45 |
type: V_STRING |
| 46 |
v_string { |
| 47 |
value: "%COMP_ALGO%" |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
recvok; |
| 58 |
enable_compression %COMP_ALGO%; |
| 59 |
login; |
| 60 |
-->noquiet |
| 61 |
-->endmacro |
| 62 |
|
| 63 |
-->echo |
| 64 |
-->echo ## 1. Send compressed message with invalid payload |
| 65 |
-->echo # a. Send compressed-message with too long-uncompressed payload size |
| 66 |
-->echo # b. Send compressed-message with invalid compressed-payload |
| 67 |
-->echo ## 2. Send compressed message with invalid message |
| 68 |
-->echo # a. Send compressed-message with StmtExecute and missing fields (not initialized error) |
| 69 |
-->echo # b. Send compressed-message with not know message, and verify that its dispatched |
| 70 |
-->echo # c. Send compressed-message with message that exceeds protobufs nested |
| 71 |
-->echo # messages limit, and verify that its rejected with proper error |
| 72 |
|
| 73 |
-->echo; |
| 74 |
-->echo # 1.a. |
| 75 |
callmacro New_session_with_caps |
| 76 |
SESS_SINGLE1 |
| 77 |
%OPTION_COMPRESSION_ALGORITHM%; |
| 78 |
# |
| 79 |
# uncomp-length=268435456 |
| 80 |
# |
| 81 |
|
| 82 |
-->binparse %BIN_EXPECT_OPEN% Mysqlx.Expect.Open { |
| 83 |
} |
| 84 |
-->compress_bin %VALID_COMPRESS_EXPECT_OPEN% %BIN_EXPECT_OPEN% |
| 85 |
|
| 86 |
Mysqlx.Connection.Compression { |
| 87 |
uncompressed_size: 268435456 |
| 88 |
payload: "%VALID_COMPRESS_EXPECT_OPEN%" |
| 89 |
} |
| 90 |
|
| 91 |
callmacro Wait_until_disconnect; |
| 92 |
|
| 93 |
|
| 94 |
-->echo; |
| 95 |
-->echo # 1.b. |
| 96 |
callmacro New_session_with_caps |
| 97 |
SESS_SINGLE2 |
| 98 |
%OPTION_COMPRESSION_ALGORITHM%; |
| 99 |
# |
| 100 |
# Some garbage as compressed-payload aaaabbbb11223333344ffffeeee1111222 |
| 101 |
# |
| 102 |
Mysqlx.Connection.Compression { |
| 103 |
payload: "%aaaabbbb11223333344ffffeeee1111222%" |
| 104 |
} |
| 105 |
recverror ER_X_DECOMPRESSION_FAILED; |
| 106 |
callmacro Wait_until_disconnect; |
| 107 |
|
| 108 |
|
| 109 |
-->echo; |
| 110 |
-->echo # 2.a. |
| 111 |
callmacro New_session_with_caps |
| 112 |
SESS_SINGLE3 |
| 113 |
%OPTION_COMPRESSION_ALGORITHM%; |
| 114 |
# |
| 115 |
# length=1, msg-type=12=0x0c |
| 116 |
# |
| 117 |
compress_bin %BIN_COMPRESS_EMPTY_STMT_EXECUTE% \x01\x00\x00\x00\x0c; |
| 118 |
Mysqlx.Connection.Compression { |
| 119 |
payload: "%BIN_COMPRESS_EMPTY_STMT_EXECUTE%" |
| 120 |
} |
| 121 |
recverror ER_X_BAD_MESSAGE; |
| 122 |
callmacro Wait_until_disconnect; |
| 123 |
|
| 124 |
|
| 125 |
-->echo; |
| 126 |
-->echo # 2.b. |
| 127 |
callmacro New_session_with_caps |
| 128 |
SESS_SINGLE4 |
| 129 |
%OPTION_COMPRESSION_ALGORITHM%; |
| 130 |
# |
| 131 |
# length=1, msg-type=12=0xfc (unknown) |
| 132 |
# |
| 133 |
compress_bin %BIN_COMPRESS_UNKNOWN_MESSAGE% \x01\x00\x00\x00\xfc; |
| 134 |
|
| 135 |
Mysqlx.Expect.Open { |
| 136 |
cond {condition_key:1} |
| 137 |
} |
| 138 |
recvok; |
| 139 |
|
| 140 |
Mysqlx.Connection.Compression { |
| 141 |
payload: "%BIN_COMPRESS_UNKNOWN_MESSAGE%" |
| 142 |
} |
| 143 |
|
| 144 |
recverror ER_UNKNOWN_COM_ERROR; |
| 145 |
|
| 146 |
stmtadmin ping; |
| 147 |
recverror ER_X_EXPECT_NO_ERROR_FAILED; |
| 148 |
Mysqlx.Expect.Close{ |
| 149 |
} |
| 150 |
recverror ER_X_EXPECT_NO_ERROR_FAILED; |
| 151 |
stmtadmin ping; |
| 152 |
recvresult; |
| 153 |
|
| 154 |
|
| 155 |
-->echo; |
| 156 |
-->echo # 2.c. |
| 157 |
# |
| 158 |
# Please look into message_protobuf_nested.test for more details. |
| 159 |
callmacro New_session_with_caps |
| 160 |
SESS_SINGLE5 |
| 161 |
%OPTION_COMPRESSION_ALGORITHM%; |
| 162 |
-->stmtadmin ensure_collection {"schema":"xtest", "name":"coll"} |
| 163 |
-->recvresult |
| 164 |
|
| 165 |
-->macro Send_crud_find_with_repeated_nested_objects %OBJECTS_TO_NEST% |
| 166 |
-->varlet %NESTED_OBJECTS% |
| 167 |
|
| 168 |
-->varlet %OBJECTS_TO_REPEAT% %OBJECTS_TO_NEST% |
| 169 |
-->varinc %OBJECTS_TO_REPEAT% -3 |
| 170 |
|
| 171 |
-->repeat %OBJECTS_TO_REPEAT% %ITERATION% |
| 172 |
-->varlet %OBJECT_NUMBER% %ITERATION% |
| 173 |
-->varinc %OBJECT_NUMBER% 4 |
| 174 |
-->varlet %NESTED_OBJECTS% %NESTED_OBJECTS% value { type: ARRAY array { value { type: LITERAL literal { type: V_SINT v_signed_int: %OBJECT_NUMBER% } } |
| 175 |
-->endrepeat |
| 176 |
|
| 177 |
-->repeat %OBJECTS_TO_REPEAT% |
| 178 |
-->varlet %NESTED_OBJECTS% %NESTED_OBJECTS% } } |
| 179 |
-->endrepeat |
| 180 |
|
| 181 |
-->quiet |
| 182 |
-->begin_compress |
| 183 |
Mysqlx.Crud.Find { |
| 184 |
collection { |
| 185 |
name: "coll" |
| 186 |
schema: "test" |
| 187 |
} |
| 188 |
data_model: DOCUMENT |
| 189 |
criteria { |
| 190 |
type: OPERATOR |
| 191 |
operator { |
| 192 |
name: "==" |
| 193 |
param { |
| 194 |
type: IDENT |
| 195 |
identifier { |
| 196 |
document_path { |
| 197 |
type: MEMBER |
| 198 |
value: "ARR0" |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
param { |
| 203 |
type: ARRAY |
| 204 |
array { |
| 205 |
value { |
| 206 |
type: LITERAL |
| 207 |
literal { |
| 208 |
type: V_SINT |
| 209 |
v_signed_int: 3 |
| 210 |
} |
| 211 |
} |
| 212 |
%NESTED_OBJECTS% |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
} |
| 218 |
-->end_compress |
| 219 |
-->noquiet |
| 220 |
-->endmacro |
| 221 |
|
| 222 |
-->echo Try to send number of object more than the X Protocol limit 101 (2 * 51) |
| 223 |
-->callmacro Send_crud_find_with_repeated_nested_objects 51 |
| 224 |
|
| 225 |
## -->expecterror ER_X_BAD_MESSAGE |
| 226 |
## -->recvresult |
| 227 |
## It's because, error is always printed with message. |
| 228 |
## X Plugin error message depends on Protobuf version, thus |
| 229 |
## this test must not check it. |
| 230 |
noquery_result; |
| 231 |
recvmessage Mysqlx.Error { |
| 232 |
code: 5000 |
| 233 |
}; |
| 234 |
query_result; |
| 235 |
echo Received error message with code: ER_X_BAD_MESSAGE; |
| 236 |
|
| 237 |
callmacro Wait_until_disconnect; |
| 238 |
|
| 239 |
EOF |
| 240 |
|
| 241 |
CREATE SCHEMA xtest; |
| 242 |
|
| 243 |
# Set the timeout for connection to 300 seconds |
| 244 |
# which is must be greater than the peerdisc/timeout |
| 245 |
SET GLOBAL mysqlx_connect_timeout = 300; |
| 246 |
SET GLOBAL mysqlx_wait_timeout = 300; |
| 247 |
SET GLOBAL mysqlx_max_allowed_packet = 1000; |
| 248 |
|
| 249 |
echo; |
| 250 |
echo ## A. Execute the test with deflate; |
| 251 |
echo #; |
| 252 |
--replace_regex /payload: *\".*\"/payload: "BINARY"/ |
| 253 |
exec $MYSQLXTEST |
| 254 |
-u x_root |
| 255 |
--compression-mode=required |
| 256 |
--compression-algorithm=deflate_stream |
| 257 |
--schema xtest |
| 258 |
--file=$MYSQL_TMP_DIR/too_large.xpl 2>&1; |
| 259 |
|
| 260 |
echo; |
| 261 |
echo ## B. Execute the test with lz4; |
| 262 |
echo #; |
| 263 |
--replace_regex /payload: *\".*\"/payload: "BINARY"/ |
| 264 |
exec $MYSQLXTEST |
| 265 |
-u x_root |
| 266 |
--compression-mode=preferred |
| 267 |
--compression-algorithm=lz4_message |
| 268 |
--schema xtest |
| 269 |
--file=$MYSQL_TMP_DIR/too_large.xpl 2>&1; |
| 270 |
|
| 271 |
echo; |
| 272 |
echo ## C. Execute the test with zstd; |
| 273 |
echo #; |
| 274 |
--replace_regex /payload: *\".*\"/payload: "BINARY"/ |
| 275 |
exec $MYSQLXTEST |
| 276 |
-u x_root |
| 277 |
--compression-mode=preferred |
| 278 |
--compression-algorithm=zstd_stream |
| 279 |
--schema xtest |
| 280 |
--file=$MYSQL_TMP_DIR/too_large.xpl 2>&1; |
| 281 |
|
| 282 |
## Cleanup |
| 283 |
SET GLOBAL mysqlx_connect_timeout= DEFAULT; |
| 284 |
SET GLOBAL mysqlx_wait_timeout = DEFAULT; |
| 285 |
SET GLOBAL mysqlx_max_allowed_packet = DEFAULT; |
| 286 |
--source ../include/xplugin_cleanup.inc |