|
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | | -set -x |
17 | | - |
18 | 16 | TIDB_TEST_STORE_NAME=$TIDB_TEST_STORE_NAME |
19 | 17 | TIKV_PATH=$TIKV_PATH |
20 | | -START_TIDB_CLUSTER=$START_TIDB_CLUSTER |
21 | | - |
22 | | -# Variables to set paths for each server binary |
23 | | -TIDB_BIN="./third_bin/tidb-server" |
24 | | -TIKV_BIN="./third_bin/tikv-server" |
25 | | -PD_BIN="./third_bin/pd-server" |
26 | | -DUMPLING_BIN="./third_bin/dumpling" |
27 | | -TICDC_BIN="./third_bin/cdc" |
28 | | -TIFLASH_BIN="./third_bin/tiflash-server" |
29 | | - |
30 | | -# Variables to set data directories |
31 | | -PD_DATA_DIR="./data/pd_data" |
32 | | -PD_DATA_DIR2="./data/pd_data2" |
33 | | -TIKV_DATA_DIR="./data/tikv_data" |
34 | | -TIKV_DATA_DIR2="./data/tikv_data2" |
35 | | -TIFLASH_DATA_DIR="./data/tiflash_data" |
36 | | -TIFLASH_DATA_DIR2="./data/tiflash_data2" |
37 | | -TICDC_DATA_DIR="./data/ticdc_data" |
38 | | - |
39 | | -rm -rf ./data |
40 | | -mkdir ./data |
41 | | - |
42 | | -TIDB_LOG_FILE="./logs/tidb.log" |
43 | | -TIDB_LOG_FILE2="./logs/tidb2.log" |
44 | | -TIKV_LOG_FILE="./logs/tikv.log" |
45 | | -TIKV_LOG_FILE2="./logs/tikv2.log" |
46 | | -TIFLASH_LOG_FILE="./logs/tiflash.log" |
47 | | -TIFLASH_LOG_FILE2="./logs/tiflash2.log" |
48 | | -PD_LOG_FILE="./logs/pd.log" |
49 | | -PD_LOG_FILE2="./logs/pd2.log" |
50 | | -TICDC_LOG_FILE="./logs/ticdc.log" |
51 | | - |
52 | | -rm -rf ./logs |
53 | | -mkdir ./logs |
54 | 18 |
|
55 | 19 | build=1 |
56 | 20 | mysql_tester="./mysql_tester" |
57 | 21 | tidb_server="" |
58 | | -ticdc_server=$TICDC_BIN |
59 | 22 | portgenerator="" |
60 | 23 | mysql_tester_log="./integration-test.out" |
61 | 24 | tests="" |
@@ -249,155 +212,22 @@ rm -rf $mysql_tester_log |
249 | 212 | ports=($(find_multiple_available_ports 4000 2)) |
250 | 213 | port=${ports[0]} |
251 | 214 | status=${ports[1]} |
252 | | -# PD Server Configuration |
253 | | -start_pd_server() { |
254 | | - client_port=${1:-2379} |
255 | | - peer_port=${2:-2380} |
256 | | - data_dir=${3:-$PD_DATA_DIR} |
257 | | - log_dir=${4:-$PD_LOG_FILE} |
258 | | - |
259 | | - echo "Starting PD server..." |
260 | | - mkdir -p $data_dir |
261 | | - |
262 | | - $PD_BIN --name="pd" --data-dir="$data_dir" --log-file="$log_dir" \ |
263 | | - --client-urls="http://127.0.0.1:$client_port" \ |
264 | | - --peer-urls="http://127.0.0.1:$peer_port" \ |
265 | | - --advertise-client-urls="http://127.0.0.1:$client_port" \ |
266 | | - --advertise-peer-urls="http://127.0.0.1:$peer_port" & |
267 | | -# --config="config/pd.toml" |
268 | | - sleep 5 # Wait for PD to sart |
269 | | -} |
270 | | - |
271 | | -# TiKV Server Configuration |
272 | | -start_tikv_server() { |
273 | | - pd_client_port=${1:-2379} |
274 | | - tikv_port=${2:-20160} |
275 | | - tikv_status_port=${3:-20180} |
276 | | - data_dir=${4:-$TIKV_DATA_DIR} |
277 | | - log_dir=${5:-$TIKV_LOG_FILE} |
278 | | - |
279 | | - echo "Starting TiKV server..." |
280 | | - mkdir -p $data_dir |
281 | | - |
282 | | - $TIKV_BIN --pd="http://127.0.0.1:$pd_client_port" \ |
283 | | - --addr="127.0.0.1:$tikv_port" \ |
284 | | - --advertise-addr="127.0.0.1:$tikv_port" \ |
285 | | - --status-addr="127.0.0.1:$tikv_status_port" \ |
286 | | - --data-dir="$data_dir" \ |
287 | | - --log-file="$log_dir" & |
288 | | - sleep 5 # Wait for TiKV to connect to PD |
289 | | -} |
290 | | - |
291 | | -# TiFlash Server Configuration |
292 | | -start_tiflash_server() { |
293 | | - echo "Starting TiFlash server..." |
294 | | - mkdir -p $TIFLASH_DATA_DIR |
295 | | - $TIFLASH_BIN --data-dir=$TIFLASH_DATA_DIR --log-file=tiflash.log & |
296 | | - |
297 | | - sleep 5 # Wait for TiFlash to connect |
298 | | -} |
299 | 215 |
|
300 | 216 | function start_tidb_server() |
301 | 217 | { |
302 | | - pd_client_addr=${1:-127.0.0.1:2379} |
303 | | - tidb_port=${2:-4000} |
304 | | - tidb_status_port=${3:-10080} |
305 | | - log_file=${4:-$TIDB_LOG_FILE} |
306 | | - |
307 | 218 | config_file="config.toml" |
308 | 219 | if [[ $enabled_new_collation = 0 ]]; then |
309 | 220 | config_file="disable_new_collation.toml" |
310 | 221 | fi |
311 | | - echo "start tidb-server, log file: $log_file" |
| 222 | + echo "start tidb-server, log file: $mysql_tester_log" |
312 | 223 | if [ "${TIDB_TEST_STORE_NAME}" = "tikv" ]; then |
313 | | - $tidb_server -P "$tidb_port" \ |
314 | | - -status "$tidb_status_port" \ |
315 | | - -config $config_file \ |
316 | | - -store tikv \ |
317 | | - -path "${pd_client_addr}" > $log_file 2>&1 & |
| 224 | + $tidb_server -P "$port" -status "$status" -config $config_file -store tikv -path "${TIKV_PATH}" > $mysql_tester_log 2>&1 & |
318 | 225 | SERVER_PID=$! |
319 | 226 | else |
320 | | - $tidb_server -P "$tidb_port" \ |
321 | | - -status "$tidb_status_port" \ |
322 | | - -config $config_file \ |
323 | | - -store unistore \ |
324 | | - -path "" > $log_file 2>&1 & |
| 227 | + $tidb_server -P "$port" -status "$status" -config $config_file -store unistore -path "" > $mysql_tester_log 2>&1 & |
325 | 228 | SERVER_PID=$! |
326 | 229 | fi |
327 | | - echo "tidb-server(PID: $SERVER_PID) started, port: $tidb_port" |
328 | | -} |
329 | | - |
330 | | -function start_ticdc_server() { |
331 | | - pd_client_addr=${1:-http://127.0.0.1:2379} |
332 | | - ticdc_port=${2:-8300} |
333 | | - downstream_port=${3:-4100} |
334 | | - |
335 | | - echo "Starting TiCDC server..." |
336 | | - mkdir -p $TICDC_DATA_DIR |
337 | | - $TICDC_BIN server --pd=$pd_client_addr --addr=127.0.0.1:$ticdc_port --data-dir=$TICDC_DATA_DIR --log-file=$TICDC_LOG_FILE & |
338 | | - sleep 5 # Wait for TiCDC to connect |
339 | | - |
340 | | - $TICDC_BIN cli changefeed create --server=127.0.0.1:$ticdc_port --sink-uri="mysql://root:@127.0.0.1:$downstream_port/" --changefeed-id="simple-replication-task" |
341 | | - sleep 5 # Wait for changefeed to connect |
342 | | -} |
343 | | - |
344 | | -function start_tidb_cluster() |
345 | | -{ |
346 | | - local ports=($(find_multiple_available_ports 2379 2)) |
347 | | - if [ $? -ne 0 ]; then |
348 | | - echo "Error: Could not find multiple available ports." >&2 |
349 | | - exit 1 |
350 | | - fi |
351 | | - pd_client_port=${ports[0]} |
352 | | - pd_peer_port=${ports[1]} |
353 | | - upstream_pd_client_port=$pd_client_port |
354 | | - start_pd_server $pd_client_port $pd_peer_port $PD_DATA_DIR $PD_LOG_FILE |
355 | | - |
356 | | - local ports=($(find_multiple_available_ports 20160 2)) |
357 | | - if [ $? -ne 0 ]; then |
358 | | - echo "Error: Could not find multiple available ports." >&2 |
359 | | - exit 1 |
360 | | - fi |
361 | | - tikv_port=${ports[0]} |
362 | | - tikv_status_port=${ports[1]} |
363 | | - start_tikv_server $pd_client_port $tikv_port $tikv_status_port $TIKV_DATA_DIR $TIKV_LOG_FILE |
364 | | - |
365 | | - tidb_port=$(find_available_port 4000) |
366 | | - # Tricky: update `port` here. |
367 | | - port=$tidb_port |
368 | | - tidb_status_port=$(find_available_port 10080) |
369 | | - start_tidb_server "127.0.0.1:$pd_client_port" $tidb_port $tidb_status_port $TIDB_LOG_FILE |
370 | | - |
371 | | - local ports=($(find_multiple_available_ports 2379 2)) |
372 | | - if [ $? -ne 0 ]; then |
373 | | - echo "Error: Could not find multiple available ports." >&2 |
374 | | - exit 1 |
375 | | - fi |
376 | | - pd_client_port=${ports[0]} |
377 | | - pd_peer_port=${ports[1]} |
378 | | - start_pd_server $pd_client_port $pd_peer_port $PD_DATA_DIR2 $PD_LOG_FILE2 |
379 | | - |
380 | | - local ports=($(find_multiple_available_ports 20160 2)) |
381 | | - if [ $? -ne 0 ]; then |
382 | | - echo "Error: Could not find multiple available ports." >&2 |
383 | | - exit 1 |
384 | | - fi |
385 | | - tikv_port=${ports[0]} |
386 | | - tikv_status_port=${ports[1]} |
387 | | - start_tikv_server $pd_client_port $tikv_port $tikv_status_port $TIKV_DATA_DIR2 $TIKV_LOG_FILE2 |
388 | | - |
389 | | - tidb_port=$(find_available_port 4000) |
390 | | - tidb_status_port=$(find_available_port 10080) |
391 | | - start_tidb_server "127.0.0.1:$pd_client_port" $tidb_port $tidb_status_port $TIDB_LOG_FILE2 |
392 | | - |
393 | | - echo "TiDB cluster started successfully!" |
394 | | - read -p "Press [Enter] key to go on..." |
395 | | - |
396 | | - ticdc_port=$(find_available_port 8300) |
397 | | - start_ticdc_server "http://127.0.0.1:$upstream_pd_client_port" $ticdc_port $tidb_port |
398 | | - |
399 | | - echo "TiCDC started successfully!" |
400 | | - read -p "Press [Enter] key to go on..." |
| 230 | + echo "tidb-server(PID: $SERVER_PID) started" |
401 | 231 | } |
402 | 232 |
|
403 | 233 | function run_mysql_tester() |
@@ -474,21 +304,24 @@ function check_case_name() { |
474 | 304 | check_case_name |
475 | 305 | if [[ $collation_opt = 0 || $collation_opt = 2 ]]; then |
476 | 306 | enabled_new_collation=0 |
477 | | -else |
478 | | - enabled_new_collation=1 |
| 307 | + start_tidb_server |
| 308 | + run_mysql_tester |
| 309 | + kill -15 $SERVER_PID |
| 310 | + while ps -p $SERVER_PID > /dev/null; do |
| 311 | + sleep 1 |
| 312 | + done |
| 313 | + check_data_race |
479 | 314 | fi |
480 | 315 |
|
481 | | -if [ -z "$START_TIDB_CLUSTER" ]; then |
| 316 | +if [[ $collation_opt = 1 || $collation_opt = 2 ]]; then |
| 317 | + enabled_new_collation=1 |
482 | 318 | start_tidb_server |
483 | | -else |
484 | | - start_tidb_cluster |
| 319 | + run_mysql_tester |
| 320 | + kill -15 $SERVER_PID |
| 321 | + while ps -p $SERVER_PID > /dev/null; do |
| 322 | + sleep 1 |
| 323 | + done |
| 324 | + check_data_race |
485 | 325 | fi |
486 | 326 |
|
487 | | -run_mysql_tester |
488 | | -kill -15 $SERVER_PID |
489 | | -while ps -p $SERVER_PID > /dev/null; do |
490 | | - sleep 1 |
491 | | -done |
492 | | -check_data_race |
493 | | - |
494 | 327 | echo "integrationtest passed!" |
0 commit comments