From 23eb34473e6eb7555d23ef877d75e9e6fef20f2f Mon Sep 17 00:00:00 2001 From: csuzhangxc Date: Tue, 17 Dec 2019 17:38:08 +0800 Subject: [PATCH 1/3] *: copy check_http_alive from master --- tests/_utils/check_http_alive | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/_utils/check_http_alive diff --git a/tests/_utils/check_http_alive b/tests/_utils/check_http_alive new file mode 100644 index 0000000000..a258492574 --- /dev/null +++ b/tests/_utils/check_http_alive @@ -0,0 +1,27 @@ +#!/bin/bash +# parameter 1: url, only GET method supported now +# parameter 2: text needs to be contained +# parameter 3: retry count, if check failed we will wait 1s before next retry, until retry time exceeds retry count + +set -eu + +url=$1 +contain=$2 +retry_count=$3 + +shift 3 + +counter=0 +while [ $counter -lt $retry_count ]; do + got=$(curl -s $url | grep "$contain" | wc -l) + if [[ $got -gt 0 ]]; then + echo "HTTP $url is alive" + exit 0 + fi + ((counter+=1)) + echo "wait for HTTP alive for $counter-th time" + sleep 1 +done + +echo "HTTP $url is not alive" +exit 1 From 56f705406581950914aabf5edd46dbf70b2bf3fd Mon Sep 17 00:00:00 2001 From: Xuecheng Zhang Date: Tue, 17 Dec 2019 17:21:31 +0800 Subject: [PATCH 2/3] *: fix DB connection close and all_mode integration test (#403) (cherry picked from commit 6612cf7d71bc45a9037ef6a31279535d273d1b15) --- pkg/conn/baseconn.go | 12 +++++++++++- tests/all_mode/run.sh | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/conn/baseconn.go b/pkg/conn/baseconn.go index 86757872be..ee4b0d8276 100644 --- a/pkg/conn/baseconn.go +++ b/pkg/conn/baseconn.go @@ -15,6 +15,7 @@ package conn import ( "database/sql" + "database/sql/driver" "fmt" "strings" @@ -207,5 +208,14 @@ func (conn *BaseConn) close() error { if conn == nil || conn.DBConn == nil { return nil } - return terror.ErrDBUnExpect.Delegate(conn.DBConn.Close(), "close") + + err := conn.DBConn.Raw(func(dc interface{}) error { + // return an `ErrBadConn` to ensure close the connection, but do not put it back to the pool. + // if we choose to use `Close`, it will always put the connection back to the pool. + return driver.ErrBadConn + }) + if err != driver.ErrBadConn { + return terror.ErrDBUnExpect.Delegate(err, "close") + } + return nil } diff --git a/tests/all_mode/run.sh b/tests/all_mode/run.sh index de61b75765..db36a74e32 100755 --- a/tests/all_mode/run.sh +++ b/tests/all_mode/run.sh @@ -5,6 +5,7 @@ set -eu cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source $cur/../_utils/test_prepare WORK_DIR=$TEST_DIR/$TEST_NAME +API_VERSION="v1alpha1" function run() { export GO_FAILPOINTS="github.com/pingcap/dm/dm/worker/TaskCheckInterval=return(\"500ms\")" @@ -34,6 +35,10 @@ function run() { run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml + # wait for task running + check_http_alive 127.0.0.1:$MASTER_PORT/apis/${API_VERSION}/status/test '"name":"test","stage":"Running"' 10 + sleep 2 # still wait for subtask running on other dm-workers + # kill tidb pkill -hup tidb-server 2>/dev/null || true wait_process_exit tidb-server From c1f8205edc905ff4224865e265762b9c8e031b1a Mon Sep 17 00:00:00 2001 From: csuzhangxc Date: Tue, 17 Dec 2019 17:52:42 +0800 Subject: [PATCH 3/3] *: update permission for check_http_alive --- tests/_utils/check_http_alive | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/_utils/check_http_alive diff --git a/tests/_utils/check_http_alive b/tests/_utils/check_http_alive old mode 100644 new mode 100755