Debian Codegraph @

mysql-test/suite/ndb_big/smoke.test

raw
1 --source suite/ndb_big/suite.inc
2 --source include/have_ndb.inc
3 --source suite/ndb/include/ndb_info.inc
4 --source suite/ndb/include/backup_restore_setup.inc
5 # --call mtr.force_restart()
6 set new=on;
7
8 select version();
9
10 #
11 # Table with many columns will fill up to 15% of memory
12 #
13
14 --let $num_cols= 125
15 --let $fill_percentage= 15
16 --echo # Table with $num_cols columns will fill up to $fill_percentage% of memory
17
18 --let $sql= CREATE TABLE manycol (pri int(11) NOT NULL
19 --let $c= $num_cols
20 while ($c)
21 {
22 --let $sql=$sql, c$c CHAR(2) NULL
23 --dec $c
24 }
25 --let $sql= $sql, PRIMARY KEY (pri)) ENGINE=NDB DEFAULT CHARSET=utf8 PARTITION BY HASH (pri)
26 --source suite/ndb_big/run_query_with_retry.inc
27
28 --source suite/ndb/include/memory_usage.inc
29 --echo # Memory usage before inserts: $MTR_NDB_DATA_USAGE_PERCENTAGE%
30 --echo # Inserting rows into the many columns table
31 --source suite/ndb_big/start_timer.inc
32 --disable_query_log
33 --let $row= 0
34 while (`SELECT $MTR_NDB_DATA_USAGE_PERCENTAGE < $fill_percentage`)
35 {
36 --let $sql= INSERT INTO manycol (pri
37 --let $c= $num_cols
38 while ($c)
39 {
40 --let $sql=$sql, c$c
41 --dec $c
42 }
43 --let $sql= $sql) VALUES
44
45 --let $separator=
46 --let $batch_size= 50
47 while ($batch_size)
48 {
49 --inc $row
50 --let $sql= $sql$separator($row
51 --let $c= $num_cols
52 while ($c)
53 {
54 --let $sql=$sql, 'ab'
55 --dec $c
56 }
57 --let $sql= $sql)
58 --dec $batch_size
59 --let $separator= ,
60 }
61 --source suite/ndb_big/run_query_with_retry.inc
62
63 --source suite/ndb/include/memory_usage.inc
64
65 # Workaround for bug#52464, since MTR caches --source file content in while loops
66 --eval SET @content = LOAD_FILE('$MYSQLTEST_VARDIR/tmp/ndb_memory_usage_result.inc')
67 --let $start= `SELECT LOCATE('=', @content) + 1`
68 --let $end = `SELECT LOCATE(CHAR(10), @content)`
69 --let $MTR_NDB_DATA_USAGE_PERCENTAGE= `SELECT CAST(TRIM(SUBSTR(@content, $start, $end - $start)) AS DECIMAL(10,2))`
70 }
71 --enable_query_log
72 --source suite/ndb_big/end_timer.inc
73
74 SELECT COUNT(*) AS 'Rows inserted into manycol table' FROM manycol;
75 --source suite/ndb/include/memory_usage.inc
76 --echo # Memory usage after inserts into manycol table: $MTR_NDB_DATA_USAGE_PERCENTAGE%
77
78 #
79 # Empty table
80 #
81 --echo # Empty table
82 CREATE TABLE empty (pri int(11) NOT NULL) ENGINE=NDB;
83
84
85 #
86 # Table with many data types
87 #
88
89 --let $fill_percentage= 25
90 --echo # Table with many column types will fill up to $fill_percentage% of memory
91
92 CREATE TABLE types (
93 pri int(11) NOT NULL,
94 ti TINYINT,
95 si SMALLINT,
96 mi MEDIUMINT,
97 bi BIGINT,
98 ft FLOAT(20),
99 tt FLOAT(40),
100 du DOUBLE,
101 nu NUMERIC(10, 5),
102 bt BIT(16),
103 da DATE,
104 tm TIME,
105 dt DATETIME,
106 ts TIMESTAMP,
107 ye YEAR,
108 ch CHAR(2),
109 bn BINARY,
110 vc VARCHAR(10),
111 vb VARBINARY(10),
112 en ENUM('one', 'two', 'three'),
113 se SET('one', 'two', 'three'),
114 PRIMARY KEY (pri)
115 ) ENGINE=NDB DEFAULT CHARSET=utf8 PARTITION BY HASH (pri);
116
117 --source suite/ndb/include/memory_usage.inc
118 --echo # Memory usage before inserts: $MTR_NDB_DATA_USAGE_PERCENTAGE%
119 --echo # Inserting rows into the column types table
120 --source suite/ndb_big/start_timer.inc
121 --disable_query_log
122 --let $row= 0
123 while (`SELECT $MTR_NDB_DATA_USAGE_PERCENTAGE < $fill_percentage`)
124 {
125 --let $sql= INSERT INTO types (pri, ti, si, mi, bi, ft, tt, du, nu, bt, da, tm, dt, ts, ye, ch, bn, vc, vb, en, se) VALUES
126
127 --let $batch_size= 50
128 --let $separator=
129 while ($batch_size)
130 {
131 --inc $row
132 --let $sql= $sql$separator($row, 2, 3, 4, 5, 1.2, 3.14, 2.71, 42.42, b'1101', '1977-05-13', '01:23:45', '1980-01-02 01:34:54', NOW(), 2010, 'cd', b'10101', 'xyz', 'abc', 'one', 'one,two')
133 --dec $batch_size
134 --let $separator= ,
135 }
136 --source suite/ndb_big/run_query_with_retry.inc
137
138 --source suite/ndb/include/memory_usage.inc
139
140 # Workaround for bug#52464, since MTR caches --source file content in while loops
141 --eval SET @content = LOAD_FILE('$MYSQLTEST_VARDIR/tmp/ndb_memory_usage_result.inc')
142 --let $start= `SELECT LOCATE('=', @content) + 1`
143 --let $end = `SELECT LOCATE(CHAR(10), @content)`
144 --let $MTR_NDB_DATA_USAGE_PERCENTAGE= `SELECT CAST(TRIM(SUBSTR(@content, $start, $end - $start)) AS DECIMAL(10,2))`
145 }
146 --enable_query_log
147 --source suite/ndb_big/end_timer.inc
148
149 SELECT COUNT(*) AS 'Rows inserted into types table' FROM types;
150 --source suite/ndb/include/memory_usage.inc
151 --echo # Memory usage after inserts into types table: $MTR_NDB_DATA_USAGE_PERCENTAGE%
152 --echo # Index memory usage after inserts: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
153
154 #
155 # Create extra indexes
156 #
157
158 --echo # Creating indexes
159
160 CREATE UNIQUE INDEX types_ints ON types (pri, ti, si, mi, bi);
161 --source suite/ndb/include/memory_usage.inc
162 --echo # Memory usage after create index 1: $MTR_NDB_DATA_USAGE_PERCENTAGE%
163 --echo # Index memory usage after create index 1: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
164 CREATE UNIQUE INDEX types_dec ON types (ft, tt, du, nu, pri);
165 --source suite/ndb/include/memory_usage.inc
166 --echo # Memory usage after create index 2: $MTR_NDB_DATA_USAGE_PERCENTAGE%
167 --echo # Index memory usage after create index 2: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
168 CREATE UNIQUE INDEX types_date ON types (ts, da, tm, dt, pri);
169 --source suite/ndb/include/memory_usage.inc
170 --echo # Memory usage after create index 3: $MTR_NDB_DATA_USAGE_PERCENTAGE%
171 --echo # Index memory usage after create index 3: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
172
173 --source suite/ndb/include/memory_usage.inc
174 --echo # Index memory usage after creating secondary indexes: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
175
176 #
177 # Create BLOB (text) table
178 #
179
180 --echo # Table with BLOB(TEXT) columns
181 CREATE TABLE blobs (pri int(11) NOT NULL, data1 TEXT, data2 TEXT, PRIMARY KEY (pri)) ENGINE=NDB DEFAULT CHARSET=utf8 PARTITION BY HASH (pri);
182
183 --let $fill_percentage= 75
184 --echo # Inserting rows into the blobs table until $fill_percentage% memory fill
185 --source suite/ndb_big/start_timer.inc
186 --disable_query_log
187 --let $row= 0
188 while (`SELECT $MTR_NDB_DATA_USAGE_PERCENTAGE < $fill_percentage`)
189 {
190 --let $sql= INSERT INTO blobs(pri, data1, data2) VALUES
191
192 --let $batch_size= 50
193 --let $separator=
194 while ($batch_size)
195 {
196 --inc $row
197 --let $sql= $sql$separator($row, REPEAT('dt01', 10240 * RAND()), REPEAT('dt02', 1024 * RAND()))
198 --dec $batch_size
199 --let $separator= ,
200 }
201 --source suite/ndb_big/run_query_with_retry.inc
202
203 --source suite/ndb/include/memory_usage.inc
204 # Workaround for bug#52464, since MTR caches --source file content in while loops
205 --eval SET @content = LOAD_FILE('$MYSQLTEST_VARDIR/tmp/ndb_memory_usage_result.inc')
206 --let $start= `SELECT LOCATE('=', @content) + 1`
207 --let $end = `SELECT LOCATE(CHAR(10), @content)`
208 --let $MTR_NDB_DATA_USAGE_PERCENTAGE= `SELECT CAST(TRIM(SUBSTR(@content, $start, $end - $start)) AS DECIMAL(10,2))`
209 }
210 --enable_query_log
211 --source suite/ndb_big/end_timer.inc
212
213 SELECT COUNT(*) AS 'Rows inserted into blobs table' FROM blobs;
214 --source suite/ndb/include/memory_usage.inc
215 --echo # Memory usage after inserts into blobs table: $MTR_NDB_DATA_USAGE_PERCENTAGE%
216 --echo # Index memory usage after inserts into blobs table: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
217
218 #
219 # Fill up with many tables, as long as memory/index usage < 95%
220 #
221 --let $fill_percentage= 95
222 --echo # Creating tables until $fill_percentage% memory/index fill is reached
223
224 --source suite/ndb_big/start_timer.inc
225 --disable_query_log
226 --let $table_id= 0
227 while (`SELECT $MTR_NDB_DATA_USAGE_PERCENTAGE < $fill_percentage AND $MTR_NDB_INDEX_USAGE_PERCENTAGE < $fill_percentage AND $table_id < 1500`)
228 {
229 --inc $table_id
230 --let sql=CREATE TABLE t$table_id (c1 int(11) NOT NULL, c3 text, PRIMARY KEY (c1)) ENGINE=NDB DEFAULT CHARSET=utf8 PARTITION BY HASH (c1)
231 --source suite/ndb_big/run_query_with_retry.inc
232
233 --let $rows= 100
234 --let $batch_size= 50
235 --let $i= `SELECT $rows / $batch_size`
236 while ($i)
237 {
238 --let $batch= $batch_size
239 let $separator= ;
240 --let $sql= INSERT t$table_id (c1, c3) VALUES
241 while($batch)
242 {
243 --let $sql=$sql$separator(($i*$batch_size)+$batch, REPEAT('ks87', 128*RAND()))
244 --dec $batch
245 --let $separator = ,
246 }
247 --source suite/ndb_big/run_query_with_retry.inc
248 --dec $i
249 }
250
251 --source suite/ndb/include/memory_usage.inc
252 # Workaround for bug#52464, since MTR caches --source file content in while loops
253 --eval SET @content = LOAD_FILE('$MYSQLTEST_VARDIR/tmp/ndb_memory_usage_result.inc')
254 --let $start= `SELECT LOCATE('=', @content) + 1`
255 --let $end = `SELECT LOCATE(CHAR(10), @content)`
256 --let $MTR_NDB_DATA_USAGE_PERCENTAGE= `SELECT CAST(TRIM(SUBSTR(@content, $start, $end - $start)) AS DECIMAL(10,2))`
257 --let $index_start= `SELECT LOCATE('=', @content, $start) + 1`
258 --let $index_end = `SELECT LOCATE(CHAR(10), @content, $end + 1)`
259 --let $MTR_NDB_INDEX_USAGE_PERCENTAGE= `SELECT CAST(TRIM(SUBSTR(@content, $index_start, $index_end - $index_start)) AS DECIMAL(10,2))`
260 # --echo # After table t$table_id: data: $MTR_NDB_DATA_USAGE_PERCENTAGE%, index: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
261 }
262
263 --echo # Num tables: $table_id
264 --source suite/ndb/include/memory_usage.inc
265 --echo # Memory usage after inserts into many tables table: $MTR_NDB_DATA_USAGE_PERCENTAGE%
266 --echo # Index memory usage after inserts into many tables table: $MTR_NDB_INDEX_USAGE_PERCENTAGE%
267
268 --append_file $NDB_TOOLS_OUTPUT
269 # ndb_mgm -e "ALL REPORT MemoryUsage"
270 EOF
271 --exec $NDB_MGM -e "ALL REPORT MemoryUsage" >> $NDB_TOOLS_OUTPUT
272
273 ## Backup
274 --echo # Starting backup:
275 --source suite/ndb_big/start_timer.inc
276 --source include/ndb_backup.inc
277 --source suite/ndb_big/end_timer.inc
278
279 ## Random node restart
280 --source suite/ndb_big/start_timer.inc
281 --source suite/ndb/include/restart_random_node.inc
282 --source suite/ndb_big/end_timer.inc
283
284 ## System restart
285 --source suite/ndb_big/start_timer.inc
286 --source suite/ndb/include/restart_cluster.inc
287 --source suite/ndb_big/end_timer.inc
288
289 ## Rolling system restart
290 --source suite/ndb_big/start_timer.inc
291 --source suite/ndb/include/restart_cluster_rolling.inc
292 --source suite/ndb_big/end_timer.inc
293
294 ## Clean up
295 --echo # Dropping tables:
296 --let $t= $table_id
297 --source suite/ndb_big/start_timer.inc
298 while ($t)
299 {
300 --let $sql=drop table t$t
301 --source suite/ndb_big/run_query_with_retry.inc
302 --dec $t
303 }
304 --source suite/ndb_big/end_timer.inc
305
306 DROP TABLE blobs;
307 DROP TABLE types;
308 DROP TABLE manycol;
309 DROP TABLE empty;
310 --source suite/ndb/include/backup_restore_cleanup.inc
311
312 ## Test suceeded
313 exit;
314 --remove_file $NDB_TOOLS_OUTPUT