github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/http_api_tls/run.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 6 source $CUR/../_utils/test_prepare 7 WORK_DIR=$OUT_DIR/$TEST_NAME 8 CDC_BINARY=cdc.test 9 SINK_TYPE=$1 10 TLS_DIR=$(cd $CUR/../_certificates && pwd) 11 MAX_RETRIES=20 12 13 function run() { 14 # storage and kafka are the same as mysql 15 if [ "$SINK_TYPE" != "mysql" ]; then 16 return 17 fi 18 19 sudo python3 -m pip install -U requests==2.26.0 20 21 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 22 23 start_tidb_cluster --workdir $WORK_DIR 24 start_tls_tidb_cluster --workdir $WORK_DIR --tlsdir $TLS_DIR 25 26 cd $WORK_DIR 27 28 echo " \ 29 [security] 30 ca-path = \"$TLS_DIR/ca.pem\" 31 cert-path = \"$TLS_DIR/server.pem\" 32 key-path = \"$TLS_DIR/server-key.pem\" 33 cert-allowed-cn = [\"fake_cn\"] 34 " >$WORK_DIR/server.toml 35 36 run_cdc_server \ 37 --workdir $WORK_DIR \ 38 --binary $CDC_BINARY \ 39 --logsuffix "_${TEST_NAME}_tls1" \ 40 --pd "https://${TLS_PD_HOST}:${TLS_PD_PORT}" \ 41 --addr "127.0.0.1:8300" \ 42 --config "$WORK_DIR/server.toml" \ 43 --tlsdir "$TLS_DIR" \ 44 --cert-allowed-cn "client" # The common name of client.pem 45 46 sleep 2 47 48 run_cdc_server \ 49 --workdir $WORK_DIR \ 50 --binary $CDC_BINARY \ 51 --logsuffix "_${TEST_NAME}_tls2" \ 52 --pd "https://${TLS_PD_HOST}:${TLS_PD_PORT}" \ 53 --addr "127.0.0.1:8301" \ 54 --config "$WORK_DIR/server.toml" \ 55 --tlsdir "$TLS_DIR" \ 56 --cert-allowed-cn "client" # The common name of client.pem 57 58 # wait for cdc run 59 sleep 2 60 61 SINK_URI="mysql://normal:123456@127.0.0.1:3306/" 62 63 python3 $CUR/util/test_case.py check_health $TLS_DIR 64 python3 $CUR/util/test_case.py get_status $TLS_DIR 65 66 python3 $CUR/util/test_case.py create_changefeed $TLS_DIR "$SINK_URI" 67 # wait for all changefeed created 68 ensure $MAX_RETRIES check_changefeed_state "https://${TLS_PD_HOST}:${TLS_PD_PORT}" "changefeed-test1" "normal" "null" ${TLS_DIR} 69 ensure $MAX_RETRIES check_changefeed_state "https://${TLS_PD_HOST}:${TLS_PD_PORT}" "changefeed-test2" "normal" "null" ${TLS_DIR} 70 ensure $MAX_RETRIES check_changefeed_state "https://${TLS_PD_HOST}:${TLS_PD_PORT}" "changefeed-test3" "normal" "null" ${TLS_DIR} 71 ensure $MAX_RETRIES check_changefeed_state "https://${TLS_PD_HOST}:${TLS_PD_PORT}" "changefeed-test4" "normal" "null" ${TLS_DIR} 72 73 # test processor query with no attached tables 74 #TODO: comment this test temporary 75 #python $CUR/util/test_case.py get_processor $TLS_DIR 76 77 run_sql "CREATE table test.simple0(id int primary key, val int);" 78 run_sql "CREATE table test.\`simple-dash\`(id int primary key, val int);" 79 run_sql "CREATE table test.simple1(id int primary key, val int);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 80 --ssl-ca=$TLS_DIR/ca.pem \ 81 --ssl-cert=$TLS_DIR/server.pem \ 82 --ssl-key=$TLS_DIR/server-key.pem 83 run_sql "CREATE table test.simple2(id int primary key, val int);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 84 --ssl-ca=$TLS_DIR/ca.pem \ 85 --ssl-cert=$TLS_DIR/server.pem \ 86 --ssl-key=$TLS_DIR/server-key.pem 87 run_sql "INSERT INTO test.simple1(id, val) VALUES (1, 1);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 88 --ssl-ca=$TLS_DIR/ca.pem \ 89 --ssl-cert=$TLS_DIR/server.pem \ 90 --ssl-key=$TLS_DIR/server-key.pem 91 run_sql "INSERT INTO test.simple1(id, val) VALUES (2, 2);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 92 --ssl-ca=$TLS_DIR/ca.pem \ 93 --ssl-cert=$TLS_DIR/server.pem \ 94 --ssl-key=$TLS_DIR/server-key.pem 95 run_sql "CREATE table test.verify_table_eligible(id int primary key, val int);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 96 --ssl-ca=$TLS_DIR/ca.pem \ 97 --ssl-cert=$TLS_DIR/server.pem \ 98 --ssl-key=$TLS_DIR/server-key.pem 99 run_sql "CREATE table test.verify_table_ineligible(id int, val int);" ${TLS_TIDB_HOST} ${TLS_TIDB_PORT} \ 100 --ssl-ca=$TLS_DIR/ca.pem \ 101 --ssl-cert=$TLS_DIR/server.pem \ 102 --ssl-key=$TLS_DIR/server-key.pem 103 # wait for above sql done in the up source 104 sleep 2 105 106 check_table_exists test.simple1 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 107 108 sequential_cases=( 109 "list_changefeed" 110 "get_changefeed" 111 "pause_changefeed" 112 "update_changefeed" 113 "resume_changefeed" 114 "rebalance_table" 115 "list_processor" 116 "get_processor" 117 "move_table" 118 "set_log_level" 119 "remove_changefeed" 120 "resign_owner" 121 "get_tso" 122 "verify_table" 123 "create_changefeed_v2" 124 "delete_changefeed_v2" 125 "unsafe_apis" 126 ) 127 128 for case in ${sequential_cases[@]}; do 129 python3 $CUR/util/test_case.py "$case" $TLS_DIR 130 sleep 1 131 done 132 133 cleanup_process $CDC_BINARY 134 } 135 136 trap stop_tidb_cluster EXIT 137 run $* 138 check_logs $WORK_DIR 139 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"