github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/download-integration-test-binaries.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2023 PingCAP, Inc. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # download-integration-test-binaries.sh will 16 # * download all the binaries you need for dm integration testing 17 18 # Notice: 19 # Please don't try the script locally, 20 # it downloads files for linux platform. 21 22 set -o errexit 23 set -o nounset 24 set -o pipefail 25 26 # See https://misc.flogisoft.com/bash/tip_colors_and_formatting. 27 color-green() { # Green 28 echo -e "\x1B[1;32m${*}\x1B[0m" 29 } 30 31 function download() { 32 local url=$1 33 local file_name=$2 34 local file_path=$3 35 if [[ -f "${file_path}" ]]; then 36 echo "file ${file_name} already exists, skip download" 37 return 38 fi 39 echo ">>>" 40 echo "download ${file_name} from ${url}" 41 wget --no-verbose --retry-connrefused --waitretry=1 -t 3 -O "${file_path}" "${url}" 42 } 43 44 # Specify the download branch. 45 branch=$1 46 47 # PingCAP file server URL. 48 file_server_url="http://fileserver.pingcap.net" 49 50 # Get sha1 based on branch name. 51 tidb_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb/${branch}/sha1") 52 tikv_sha1=$(curl "${file_server_url}/download/refs/pingcap/tikv/${branch}/sha1") 53 pd_sha1=$(curl "${file_server_url}/download/refs/pingcap/pd/${branch}/sha1") 54 tidb_tools_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb-tools/master/sha1") 55 56 # All download links. 57 tidb_download_url="${file_server_url}/download/builds/pingcap/tidb/${tidb_sha1}/centos7/tidb-server.tar.gz" 58 tikv_download_url="${file_server_url}/download/builds/pingcap/tikv/${tikv_sha1}/centos7/tikv-server.tar.gz" 59 pd_download_url="${file_server_url}/download/builds/pingcap/pd/${pd_sha1}/centos7/pd-server.tar.gz" 60 tidb_tools_download_url="${file_server_url}/download/builds/pingcap/tidb-tools/${tidb_tools_sha1}/centos7/tidb-tools.tar.gz" 61 62 gh_os_download_url="https://github.com/github/gh-ost/releases/download/v1.1.0/gh-ost-binary-linux-20200828140552.tar.gz" 63 minio_download_url="${file_server_url}/download/minio.tar.gz" 64 65 # Some temporary dir. 66 rm -rf tmp 67 rm -rf third_bin 68 69 mkdir -p third_bin 70 mkdir -p tmp 71 mkdir -p bin 72 73 color-green "Download binaries..." 74 download "$tidb_download_url" "tidb-server.tar.gz" "tmp/tidb-server.tar.gz" 75 tar -xz -C third_bin bin/tidb-server -f tmp/tidb-server.tar.gz && mv third_bin/bin/tidb-server third_bin/ 76 download "$pd_download_url" "pd-server.tar.gz" "tmp/pd-server.tar.gz" 77 tar -xz -C third_bin 'bin/*' -f tmp/pd-server.tar.gz && mv third_bin/bin/* third_bin/ 78 download "$tikv_download_url" "tikv-server.tar.gz" "tmp/tikv-server.tar.gz" 79 tar -xz -C third_bin bin/tikv-server -f tmp/tikv-server.tar.gz && mv third_bin/bin/tikv-server third_bin/ 80 download "$tidb_tools_download_url" "tidb-tools.tar.gz" "tmp/tidb-tools.tar.gz" 81 tar -xz -C third_bin 'bin/sync_diff_inspector' -f tmp/tidb-tools.tar.gz && mv third_bin/bin/sync_diff_inspector third_bin/ 82 download "$minio_download_url" "minio.tar.gz" "tmp/minio.tar.gz" 83 tar -xz -C third_bin -f tmp/minio.tar.gz 84 download "$gh_os_download_url" "gh-ost-binary-linux-20200828140552.tar.gz" "tmp/gh-ost-binary-linux-20200828140552.tar.gz" 85 tar -xz -C third_bin -f tmp/gh-ost-binary-linux-20200828140552.tar.gz 86 87 chmod a+x third_bin/* 88 89 # Copy it to the bin directory in the root directory. 90 rm -rf tmp 91 rm -rf bin/bin 92 mv third_bin/* ./bin 93 rm -rf third_bin 94 95 color-green "Download SUCCESS"