From 6fc5a491a76735823aa11bb3b827309ed340891a Mon Sep 17 00:00:00 2001 From: nhsmw Date: Thu, 5 Sep 2024 11:00:05 +0800 Subject: [PATCH] test(ticdc,dm): modify download-integration-test-binaries script (#11564) close pingcap/tiflow#11563 --- .../download-integration-test-binaries.sh | 19 +++++++++++--- scripts/download-integration-test-binaries.sh | 25 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/dm/tests/download-integration-test-binaries.sh b/dm/tests/download-integration-test-binaries.sh index 21a505664d9..34dab604e85 100755 --- a/dm/tests/download-integration-test-binaries.sh +++ b/dm/tests/download-integration-test-binaries.sh @@ -41,6 +41,19 @@ function download() { wget --no-verbose --retry-connrefused --waitretry=1 -t 3 -O "${file_path}" "${url}" } +function get_sha1() { + local repo="$1" + local branch="$2" + file_server_url="http://fileserver.pingcap.net" + sha1=$(curl -s "${file_server_url}/download/refs/pingcap/${repo}/${branch}/sha1") + if [ $? -ne 0 ] || echo "$sha1" | grep -q "Error"; then + echo "Failed to get sha1 with repo ${repo} branch ${branch}: $sha1. use branch master to instead" >&2 + branch=master + sha1=$(curl -s "${file_server_url}/download/refs/pingcap/${repo}/${branch}/sha1") + fi + echo $sha1 +} + # Specify the download branch. branch=$1 @@ -48,9 +61,9 @@ branch=$1 file_server_url="http://fileserver.pingcap.net" # Get sha1 based on branch name. -tidb_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb/${branch}/sha1") -tikv_sha1=$(curl "${file_server_url}/download/refs/pingcap/tikv/${branch}/sha1") -pd_sha1=$(curl "${file_server_url}/download/refs/pingcap/pd/${branch}/sha1") +tidb_sha1=$(get_sha1 "tidb" "$branch") +tikv_sha1=$(get_sha1 "tikv" "$branch") +pd_sha1=$(get_sha1 "pd" "$branch") tidb_tools_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb-tools/master/sha1") # All download links. diff --git a/scripts/download-integration-test-binaries.sh b/scripts/download-integration-test-binaries.sh index 537dd260c1b..6a11a08b5d5 100755 --- a/scripts/download-integration-test-binaries.sh +++ b/scripts/download-integration-test-binaries.sh @@ -108,22 +108,37 @@ function download_community_binaries() { chmod a+x third_bin/* } +function get_sha1() { + local repo="$1" + local branch="$2" + file_server_url="http://fileserver.pingcap.net" + sha1=$(curl -s "${file_server_url}/download/refs/pingcap/${repo}/${branch}/sha1") + if [ $? -ne 0 ] || echo "$sha1" | grep -q "Error"; then + echo "Failed to get sha1 with repo ${repo} branch ${branch}: $sha1. use branch master to instead" >&2 + branch=master + sha1=$(curl -s "${file_server_url}/download/refs/pingcap/${repo}/${branch}/sha1") + fi + echo "$branch:$sha1" +} + function download_binaries() { color-green "Download binaries..." # PingCAP file server URL. file_server_url="http://fileserver.pingcap.net" # Get sha1 based on branch name. - tidb_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb/${branch}/sha1") - tikv_sha1=$(curl "${file_server_url}/download/refs/pingcap/tikv/${branch}/sha1") - pd_sha1=$(curl "${file_server_url}/download/refs/pingcap/pd/${branch}/sha1") - tiflash_sha1=$(curl "${file_server_url}/download/refs/pingcap/tiflash/${branch}/sha1") + tidb_sha1=$(get_sha1 "tidb" "$branch" | cut -d':' -f2) + tikv_sha1=$(get_sha1 "tikv" "$branch" | cut -d':' -f2) + pd_sha1=$(get_sha1 "pd" "$branch" | cut -d':' -f2) + tiflash_branch_sha1=$(get_sha1 "tiflash" "$branch") + tiflash_branch=$(echo "$tiflash_branch_sha1" | cut -d':' -f1) + tiflash_sha1=$(echo "$tiflash_branch_sha1" | cut -d':' -f2) # All download links. tidb_download_url="${file_server_url}/download/builds/pingcap/tidb/${tidb_sha1}/centos7/tidb-server.tar.gz" tikv_download_url="${file_server_url}/download/builds/pingcap/tikv/${tikv_sha1}/centos7/tikv-server.tar.gz" pd_download_url="${file_server_url}/download/builds/pingcap/pd/${pd_sha1}/centos7/pd-server.tar.gz" - tiflash_download_url="${file_server_url}/download/builds/pingcap/tiflash/${branch}/${tiflash_sha1}/centos7/tiflash.tar.gz" + tiflash_download_url="${file_server_url}/download/builds/pingcap/tiflash/${tiflash_branch}/${tiflash_sha1}/centos7/tiflash.tar.gz" minio_download_url="${file_server_url}/download/minio.tar.gz" go_ycsb_download_url="${file_server_url}/download/builds/pingcap/go-ycsb/test-br/go-ycsb" etcd_download_url="${file_server_url}/download/builds/pingcap/cdc/etcd-v3.4.7-linux-amd64.tar.gz"