| 1 |
## Compression done on client side |
| 2 |
# |
| 3 |
# client->server: Mysqlx.Connection.Compression |
| 4 |
# |
| 5 |
# In which X Plugin compress by default following messages |
| 6 |
# |
| 7 |
# * NOTICE - 11, 0x0b |
| 8 |
# * RESULTSET_COLUMN_META_DATA - 12, 0x0c |
| 9 |
# * RESULTSET_ROW - 13, 0x0d |
| 10 |
# * RESULTSET_FETCH_DONE - 14, 0x0e |
| 11 |
# |
| 12 |
# followed with uncompressed: |
| 13 |
# |
| 14 |
# * SQL_STMT_EXECUTE_OK = 17 0x11 |
| 15 |
# |
| 16 |
# The client is going to use following messages to transfer |
| 17 |
# compressed payload: |
| 18 |
# |
| 19 |
# * COMPRESSION = 46; 0x2E |
| 20 |
# |
| 21 |
# The goal of this test is to verify that after enabling compression, |
| 22 |
# and sending compression messages by the client, following system variables |
| 23 |
# are incremented: |
| 24 |
# |
| 25 |
# * mysqlx_bytes_received_compressed_payload |
| 26 |
# * mysqlx_bytes_received_uncompressed_frame |
| 27 |
# |
| 28 |
--source include/xplugin_preamble.inc |
| 29 |
--source include/xplugin_create_user.inc |
| 30 |
|
| 31 |
## Test starts here |
| 32 |
--write_file $MYSQL_TMP_DIR/check_compression_recv_stats.xpl |
| 33 |
|
| 34 |
use performance_schema; |
| 35 |
|
| 36 |
SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received') , |
| 37 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_compressed_payload'), |
| 38 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_uncompressed_frame') |
| 39 |
INTO @received1,@received_comp1,@received_uncomp1; |
| 40 |
|
| 41 |
varlet %COMMENT1% abcd efghi jklm noprs tuwx yz; |
| 42 |
varlet %COMMENT2% 123 456 790 11 12 13 14 15 16; |
| 43 |
varlet %COMMENT% /*%COMMENT1%%COMMENT2%%COMMENT1%%COMMENT2%%COMMENT2%%COMMENT1%*/; |
| 44 |
|
| 45 |
-->begin_compress SINGLE |
| 46 |
Mysqlx.Sql.StmtExecute { |
| 47 |
stmt: "SELECT 1 %COMMENT%" |
| 48 |
namespace: "sql" |
| 49 |
} |
| 50 |
-->end_compress |
| 51 |
recvresult be-quiet; |
| 52 |
|
| 53 |
SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received') , |
| 54 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_compressed_payload'), |
| 55 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_uncompressed_frame') |
| 56 |
INTO @received2,@received_comp2,@received_uncomp2; |
| 57 |
|
| 58 |
-->begin_compress SINGLE |
| 59 |
Mysqlx.Sql.StmtExecute { |
| 60 |
stmt: "SELECT 2 %COMMENT%" |
| 61 |
namespace: "sql" |
| 62 |
} |
| 63 |
-->end_compress |
| 64 |
recvresult be-quiet; |
| 65 |
|
| 66 |
SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received') , |
| 67 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_compressed_payload'), |
| 68 |
(select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_received_uncompressed_frame') |
| 69 |
INTO @received3,@received_comp3,@received_uncomp3; |
| 70 |
|
| 71 |
import assert_select.macro; |
| 72 |
|
| 73 |
callmacro Assert_select0 1 SELECT @received3 > 0; |
| 74 |
callmacro Assert_select0 1 SELECT @received2 > 0; |
| 75 |
callmacro Assert_select0 1 SELECT @received1 > 0; |
| 76 |
|
| 77 |
callmacro Assert_select0 1 SELECT @received_uncomp3 > 0; |
| 78 |
callmacro Assert_select0 1 SELECT @received_uncomp2 > 0; |
| 79 |
callmacro Assert_select0 1 SELECT @received_uncomp3 > @received_uncomp2; |
| 80 |
|
| 81 |
callmacro Assert_select0 1 SELECT @received_comp3 > 0; |
| 82 |
callmacro Assert_select0 1 SELECT @received_comp2 > 0; |
| 83 |
|
| 84 |
# There is some bug here, doing "SELECT @received_comp3 > @received_comp2" is going to fail ! |
| 85 |
callmacro Assert_select0 1 SELECT @received_comp3 > 0+@received_comp2; |
| 86 |
|
| 87 |
callmacro Assert_select0 1 SELECT (@received_comp2 - @received_comp1) >= (@received_comp3 - @received_comp2); |
| 88 |
|
| 89 |
EOF |
| 90 |
|
| 91 |
|
| 92 |
echo ## 1. Verify compression at client side using ZLIB algorithm; |
| 93 |
exec $MYSQLXTEST |
| 94 |
-ux_root --password='' |
| 95 |
--compression-mode=required |
| 96 |
--compression-algorithm=deflate_stream |
| 97 |
--file=$MYSQL_TMP_DIR/check_compression_recv_stats.xpl 2>&1; |
| 98 |
|
| 99 |
echo ## 2. Verify compression at client side using LZ4Frame algorithm; |
| 100 |
exec $MYSQLXTEST |
| 101 |
-ux_root --password='' |
| 102 |
--compression-mode=required |
| 103 |
--compression-algorithm=lz4_message |
| 104 |
--file=$MYSQL_TMP_DIR/check_compression_recv_stats.xpl 2>&1; |
| 105 |
|
| 106 |
echo ## 3. Verify compression at client side using ZSTD algorithm; |
| 107 |
exec $MYSQLXTEST |
| 108 |
-ux_root --password='' |
| 109 |
--compression-mode=required |
| 110 |
--compression-algorithm=zstd_stream |
| 111 |
--file=$MYSQL_TMP_DIR/check_compression_recv_stats.xpl 2>&1; |
| 112 |
|
| 113 |
## Cleanup |
| 114 |
--source ../include/xplugin_cleanup.inc |