Debian Codegraph @

mysql-test/suite/x/t/status_variables_compression_server.test

raw
1 ## Compression done on server side
2 #
3 # server->client: 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 server is going to use following messages to transfer
17 # compressed payload:
18 #
19 # * COMPRESSION = 19; 0x13
20 #
21 # The goal of this test is to verify that after enabling compression,
22 # and sending compressed messages be the server, following system variables
23 # are incremented:
24 #
25 # * Mysqlx_bytes_sent_compressed_payload
26 # * Mysqlx_bytes_sent_uncompressed_frame
27 #
28
29 --source include/xplugin_preamble.inc
30 --source include/xplugin_create_user.inc
31
32 ## Test starts here
33 --write_file $MYSQL_TMP_DIR/compression_server.xpl
34 -->import connection.macro
35 use performance_schema;
36
37 SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_sent') ,
38 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_compressed_payload'),
39 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_uncompressed_frame')
40 INTO @send1,@send_comp1,@send_uncomp1;
41
42 stmtsql SHOW STATUS LIKE 'Mysqlx_%';
43 recvresult be-quiet;
44
45 SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_sent') ,
46 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_compressed_payload'),
47 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_uncompressed_frame')
48 INTO @send2,@send_comp2,@send_uncomp2;
49
50 stmtsql SHOW STATUS LIKE 'Mysqlx_%';
51 recvresult be-quiet;
52
53 SELECT (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'mysqlx_bytes_sent') ,
54 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_compressed_payload'),
55 (select VARIABLE_VALUE from session_status WHERE VARIABLE_NAME like 'Mysqlx_bytes_sent_uncompressed_frame')
56 INTO @send3,@send_comp3,@send_uncomp3;
57
58 #
59 #Following SQL code may give different results of different configurations, machines, linking liblaries.
60 #
61 ## echo;
62 ## echo # Compression ratio only for the first query;
63 ## SELECT @send2-@send1 as tot_bytes_in_last_query , (@send_uncomp2 - @send_uncomp1) as uncompressed,
64 ## (@send_comp2 - @send_comp1) as compressed, (@send_uncomp2 -@send_uncomp1) / (@send_comp2 - @send_comp1) as ratio;
65 ##
66 ##
67 ## echo;
68 ## echo # Compression ratio only for the second query;
69 ## SELECT @send3-@send2 as tot_bytes_in_last_query , (@send_uncomp3 - @send_uncomp2) as uncompressed, (@send_comp3 - @send_comp2) as compressed,
70 ## (@send_uncomp3 -@send_uncomp2) / (@send_comp3 - @send_comp2) as ratio;
71 #
72 # Thus it can't be tested here directly, instead it will test if relations between cocnrete variables.
73 #
74
75 import assert_select.macro;
76
77 callmacro Assert_select0 1 SELECT @send3 > 0;
78 callmacro Assert_select0 1 SELECT @send2 > 0;
79 callmacro Assert_select0 1 SELECT @send1 > 0;
80
81 callmacro Assert_select0 1 SELECT @send_uncomp3 > 0;
82 callmacro Assert_select0 1 SELECT @send_uncomp2 > 0;
83 callmacro Assert_select0 1 SELECT @send_uncomp3 > 0+@send_uncomp2;
84
85 callmacro Assert_select0 1 SELECT @send_comp3 > 0;
86 callmacro Assert_select0 1 SELECT @send_comp2 > 0;
87 # There is some bug here, doing "SELECT @send_comp3 > @send_comp2" is going to fail !
88 callmacro Assert_select0 1 SELECT @send_comp3 > 0+@send_comp2;
89
90 # Following SQL is not true for every algorithm.
91 # Only stream algorithm will improved ratio after processing more data.
92 #
93 ##SELECT (@send_comp2 - @send_comp1), (@send_comp3 - @send_comp2);
94 ##callmacro Assert_select0 1 SELECT (@send_comp2 - @send_comp1) > (@send_comp3 - @send_comp2);
95 #
96
97 EOF
98
99 echo ## 1. Verify compression at server side using ZLIB algorithm;
100 exec $MYSQLXTEST
101 --compression-mode=required
102 --compression-algorithm=deflate_stream
103 --compression-combine-mixed-messages=1
104 --compression-max-combine-messages=0
105 -ux_root --password='' --file=$MYSQL_TMP_DIR/compression_server.xpl 2>&1;
106
107 echo ## 2. Verify compression at server side using LZ4frame algorithm;
108 exec $MYSQLXTEST
109 --compression-mode=required
110 --compression-algorithm=lz4_message
111 --compression-combine-mixed-messages=1
112 --compression-max-combine-messages=0
113 -ux_root --password='' --file=$MYSQL_TMP_DIR/compression_server.xpl 2>&1;
114
115 echo ## 3. Verify compression at server side using ZSTD algorithm;
116 exec $MYSQLXTEST
117 --compression-mode=required
118 --compression-algorithm=zstd_stream
119 --compression-combine-mixed-messages=1
120 --compression-max-combine-messages=0
121 -ux_root --password='' --file=$MYSQL_TMP_DIR/compression_server.xpl 2>&1;
122
123 ## Cleanup
124 --source ../include/xplugin_cleanup.inc