Debian Codegraph @

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

raw
1 ########### ../t/crud_debug.test #########
2 ## #
3 ## This test aims to run crud message with debug sync point. #
4 ## debug sync point from server code will be set for crash and #
5 # xmessage which touches this debug sync point will be run through #
6 # mysqlxtest client. #
7 ## - DEBUG='+d,crash_commit_before' #
8 ## - DEBUG='+d,crash_commit_after' #
9 #######################################################################
10
11
12 # # 1. Need to create table with Innodb
13 # # 2. Valgrind would complain about memory leaks when we crash on purpose.
14 # # 3. DEBUG_SYNC must be compiled in.
15 # # 4. Avoid CrashReporter popup on Mac
16 --source include/not_valgrind.inc
17 --source include/have_debug_sync.inc
18 --source include/not_crashrep.inc
19 --source include/xplugin_preamble.inc
20 --source include/xplugin_create_user.inc
21
22
23 ## Test starts here
24 --write_file $MYSQL_TMP_DIR/mysqlx-in.xpl
25 -->sql
26 #-- "Creating database for testcase"
27 DROP DATABASE IF EXISTS xplugintest;
28 CREATE DATABASE xplugintest;
29 USE xplugintest;
30 CREATE TABLE table1 ( _id INT PRIMARY KEY, doc JSON ) ;
31 -->endsql
32
33 #-- "Create table table2 in xplugintest "
34
35 -->stmtadmin create_collection {"schema":"xplugintest","name":"table2"}
36 -->recvresult
37
38 #-- "Set debyg sync point in server code to crash before committing record"
39 Mysqlx.Sql.StmtExecute {
40 stmt : "SET DEBUG='+d,crash_commit_before'";
41 }
42 -->recvresult
43
44 #-- "Insert will cause commit point to hit and server crashes"
45 #-- "Records not saved as DEBUG='+d,crash_commit_before'"
46 -->echo Insert multiple rows into a Document column
47 Mysqlx.Crud.Insert {
48 collection {
49 name: "table2"
50 schema: "xplugintest"
51 }
52 data_model: DOCUMENT
53 row {
54 field {
55 type: LITERAL
56 literal {
57 type: V_STRING
58 v_string {
59 value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}"
60 }
61 }
62 }}
63 row {
64 field {
65 type: LITERAL
66 literal {
67 type: V_STRING
68 v_string {
69 value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}"
70 }
71 }}
72 }
73 }
74 -->recvresult
75 -->sql
76 SELECT * FROM xplugintest.table2;
77 -->endsql
78
79 EOF
80
81 # Request a crash, and restart the server.
82 # Write file to make mysql-test-run.pl restart the server
83 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
84 --source include/xplugin_wait_for_interfaces.inc
85 --error 1
86 --exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.xpl >$MYSQL_TMP_DIR/mysqlx-out.xpl 2>&1
87 #--cat_file $MYSQL_TMP_DIR/mysqlx-out.xpl
88 --remove_file $MYSQL_TMP_DIR/mysqlx-in.xpl
89 --remove_file $MYSQL_TMP_DIR/mysqlx-out.xpl
90 --enable_reconnect
91 --source include/wait_until_connected_again.inc
92 # No rows
93 SELECT * FROM xplugintest.table2;
94
95 --write_file $MYSQL_TMP_DIR/mysqlx-in.xpl
96 #-- "Index with unique(true), index column NOT NULL (true)"
97 -->stmtadmin create_collection_index {"schema":"xplugintest", "collection":"table2", "name":"name_index" , "unique":true, "fields":{"field":"$.name", "type":"TEXT(50)","required":true}}
98 -->recvresult
99
100 -->echo Insert multiple rows into a Document column
101 Mysqlx.Crud.Insert {
102 collection {
103 name: "table2"
104 schema: "xplugintest"
105 }
106 data_model: DOCUMENT
107 row {
108 field {
109 type: LITERAL
110 literal {
111 type: V_STRING
112 v_string {
113 value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}"
114 }
115 }
116 }}
117 row {
118 field {
119 type: LITERAL
120 literal {
121 type: V_STRING
122 v_string {
123 value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}"
124 }
125 }}
126 }
127 }
128 -->recvresult
129
130 -->sql
131 SHOW CREATE TABLE xplugintest.table2;
132 SELECT * FROM xplugintest.table2;
133 -->endsql
134 #-- "Set crash point after commit. Update will hit this point"
135 Mysqlx.Sql.StmtExecute {
136 stmt : "SET DEBUG='+d,crash_commit_after'";
137 }
138 -->recvresult
139 #-- "Update will cause commit point to hit and server crashes"
140 #-- "Records not saved as DEBUG='+d,crash_commit_before'"
141 -->echo Update decimal value with a corner value plus 1
142 Mysqlx.Crud.Update {
143 collection {
144 name: "table2"
145 schema: "xplugintest"
146 }
147 data_model: DOCUMENT
148 criteria {
149 type: OPERATOR
150 operator {
151 name: "=="
152 param {
153 type: IDENT
154 identifier {
155 name: "_id"
156 }
157 }
158 param {
159 type: LITERAL
160 literal {
161 type: V_SINT
162 v_signed_int: 2
163 }
164 }
165 }
166 }
167 operation {
168 source {
169 document_path {
170 type: MEMBER
171 value: "name"
172 }
173 }
174 operation: ITEM_SET
175 value {
176 type: LITERAL
177 literal {
178 type: V_STRING
179 v_string {
180 value: "\"Omar Argentina\""
181 }
182 }
183 }
184 }
185
186
187 }
188 -->recvresult
189
190 EOF
191
192 # Request a crash, and restart the server.
193 # Write file to make mysql-test-run.pl restart the server
194 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
195 --source include/xplugin_wait_for_interfaces.inc
196 --error 1
197 --exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.xpl >$MYSQL_TMP_DIR/mysqlx-out.xpl 2>&1
198 #--cat_file $MYSQL_TMP_DIR/mysqlx-out.xpl
199 --enable_reconnect
200 --source include/wait_until_connected_again.inc
201
202 USE xplugintest;
203 SHOW TABLES;
204 # Updated record found
205 SELECT * FROM xplugintest.table2;
206
207 ## Cleanup
208 DROP DATABASE IF EXISTS xplugintest;
209 --source ../include/xplugin_cleanup.inc