mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
GitHub is unreliable; copy-paste code from Stackoverflow to solve it
This commit is contained in:
parent
d4a35f7682
commit
78ed8a6d69
@ -360,7 +360,7 @@ if [ "$DISABLE_BC_CHECK" -ne "1" ]; then
|
|||||||
echo "Clone previous release repository"
|
echo "Clone previous release repository"
|
||||||
git clone https://github.com/ClickHouse/ClickHouse.git --no-tags --progress --branch=$previous_release_tag --no-recurse-submodules --depth=1 previous_release_repository
|
git clone https://github.com/ClickHouse/ClickHouse.git --no-tags --progress --branch=$previous_release_tag --no-recurse-submodules --depth=1 previous_release_repository
|
||||||
|
|
||||||
echo "Download previous release server"
|
echo "Download clickhouse-server from the previous release"
|
||||||
mkdir previous_release_package_folder
|
mkdir previous_release_package_folder
|
||||||
|
|
||||||
echo $previous_release_tag | download_release_packages && echo -e 'Download script exit code\tOK' >> /test_output/test_results.tsv \
|
echo $previous_release_tag | download_release_packages && echo -e 'Download script exit code\tOK' >> /test_output/test_results.tsv \
|
||||||
|
@ -15,23 +15,23 @@ CLICKHOUSE_TAGS_URL = "https://api.github.com/repos/ClickHouse/ClickHouse/tags"
|
|||||||
DOWNLOAD_PREFIX = (
|
DOWNLOAD_PREFIX = (
|
||||||
"https://github.com/ClickHouse/ClickHouse/releases/download/v{version}-{type}/"
|
"https://github.com/ClickHouse/ClickHouse/releases/download/v{version}-{type}/"
|
||||||
)
|
)
|
||||||
CLICKHOUSE_COMMON_STATIC_PACKET_NAME = "clickhouse-common-static_{version}_amd64.deb"
|
CLICKHOUSE_COMMON_STATIC_PACKAGE_NAME = "clickhouse-common-static_{version}_amd64.deb"
|
||||||
CLICKHOUSE_COMMON_STATIC_DBG_PACKET_NAME = (
|
CLICKHOUSE_COMMON_STATIC_DBG_PACKAGE_NAME = (
|
||||||
"clickhouse-common-static-dbg_{version}_amd64.deb"
|
"clickhouse-common-static-dbg_{version}_amd64.deb"
|
||||||
)
|
)
|
||||||
CLICKHOUSE_SERVER_PACKET_NAME = "clickhouse-server_{version}_amd64.deb"
|
CLICKHOUSE_SERVER_PACKAGE_NAME = "clickhouse-server_{version}_amd64.deb"
|
||||||
CLICKHOUSE_SERVER_PACKET_FALLBACK = "clickhouse-server_{version}_all.deb"
|
CLICKHOUSE_SERVER_PACKAGE_FALLBACK = "clickhouse-server_{version}_all.deb"
|
||||||
CLICKHOUSE_CLIENT_PACKET_NAME = "clickhouse-client_{version}_amd64.deb"
|
CLICKHOUSE_CLIENT_PACKAGE_NAME = "clickhouse-client_{version}_amd64.deb"
|
||||||
CLICKHOUSE_CLIENT_PACKET_FALLBACK = "clickhouse-client_{version}_all.deb"
|
CLICKHOUSE_CLIENT_PACKAGE_FALLBACK = "clickhouse-client_{version}_all.deb"
|
||||||
|
|
||||||
PACKETS_DIR = "previous_release_package_folder/"
|
PACKAGES_DIR = "previous_release_package_folder/"
|
||||||
VERSION_PATTERN = r"((?:\d+\.)?(?:\d+\.)?(?:\d+\.)?\d+-[a-zA-Z]*)"
|
VERSION_PATTERN = r"((?:\d+\.)?(?:\d+\.)?(?:\d+\.)?\d+-[a-zA-Z]*)"
|
||||||
|
|
||||||
|
|
||||||
def download_packet(url, out_path, retries=10, backoff_factor=0.3):
|
def download_package(url, out_path, retries=10, backoff_factor=0.3):
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
retry = Retry(
|
retry = Retry(
|
||||||
total=retries, read=retries, connect=retries, backoff_factor=backoff_factor
|
total=retries, read=retries, connect=retries, backoff_factor=backoff_factor, status_forcelist=[500, 502, 503, 504]
|
||||||
)
|
)
|
||||||
adapter = HTTPAdapter(max_retries=retry)
|
adapter = HTTPAdapter(max_retries=retry)
|
||||||
session.mount("http://", adapter)
|
session.mount("http://", adapter)
|
||||||
@ -43,7 +43,7 @@ def download_packet(url, out_path, retries=10, backoff_factor=0.3):
|
|||||||
fd.write(response.content)
|
fd.write(response.content)
|
||||||
|
|
||||||
|
|
||||||
def download_packets(release, dest_path=PACKETS_DIR):
|
def download_packages(release, dest_path=PACKAGES_DIR):
|
||||||
if not os.path.exists(dest_path):
|
if not os.path.exists(dest_path):
|
||||||
os.makedirs(dest_path)
|
os.makedirs(dest_path)
|
||||||
|
|
||||||
@ -53,35 +53,35 @@ def download_packets(release, dest_path=PACKETS_DIR):
|
|||||||
return os.path.join(dest_path, pkg_name)
|
return os.path.join(dest_path, pkg_name)
|
||||||
|
|
||||||
for pkg in (
|
for pkg in (
|
||||||
CLICKHOUSE_COMMON_STATIC_PACKET_NAME,
|
CLICKHOUSE_COMMON_STATIC_PACKAGE_NAME,
|
||||||
CLICKHOUSE_COMMON_STATIC_DBG_PACKET_NAME,
|
CLICKHOUSE_COMMON_STATIC_DBG_PACKAGE_NAME,
|
||||||
):
|
):
|
||||||
url = (DOWNLOAD_PREFIX + pkg).format(version=release.version, type=release.type)
|
url = (DOWNLOAD_PREFIX + pkg).format(version=release.version, type=release.type)
|
||||||
pkg_name = get_dest_path(pkg.format(version=release.version))
|
pkg_name = get_dest_path(pkg.format(version=release.version))
|
||||||
download_packet(url, pkg_name)
|
download_package(url, pkg_name)
|
||||||
|
|
||||||
for pkg, fallback in (
|
for pkg, fallback in (
|
||||||
(CLICKHOUSE_SERVER_PACKET_NAME, CLICKHOUSE_SERVER_PACKET_FALLBACK),
|
(CLICKHOUSE_SERVER_PACKAGE_NAME, CLICKHOUSE_SERVER_PACKAGE_FALLBACK),
|
||||||
(CLICKHOUSE_CLIENT_PACKET_NAME, CLICKHOUSE_CLIENT_PACKET_FALLBACK),
|
(CLICKHOUSE_CLIENT_PACKAGE_NAME, CLICKHOUSE_CLIENT_PACKAGE_FALLBACK),
|
||||||
):
|
):
|
||||||
url = (DOWNLOAD_PREFIX + pkg).format(version=release.version, type=release.type)
|
url = (DOWNLOAD_PREFIX + pkg).format(version=release.version, type=release.type)
|
||||||
pkg_name = get_dest_path(pkg.format(version=release.version))
|
pkg_name = get_dest_path(pkg.format(version=release.version))
|
||||||
try:
|
try:
|
||||||
download_packet(url, pkg_name)
|
download_package(url, pkg_name)
|
||||||
except Exception:
|
except Exception:
|
||||||
url = (DOWNLOAD_PREFIX + fallback).format(
|
url = (DOWNLOAD_PREFIX + fallback).format(
|
||||||
version=release.version, type=release.type
|
version=release.version, type=release.type
|
||||||
)
|
)
|
||||||
pkg_name = get_dest_path(fallback.format(version=release.version))
|
pkg_name = get_dest_path(fallback.format(version=release.version))
|
||||||
download_packet(url, pkg_name)
|
download_package(url, pkg_name)
|
||||||
|
|
||||||
|
|
||||||
def download_last_release(dest_path):
|
def download_last_release(dest_path):
|
||||||
current_release = get_previous_release(None)
|
current_release = get_previous_release(None)
|
||||||
download_packets(current_release, dest_path=dest_path)
|
download_packages(current_release, dest_path=dest_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
release = ReleaseInfo(input())
|
release = ReleaseInfo(input())
|
||||||
download_packets(release)
|
download_packages(release)
|
||||||
|
Loading…
Reference in New Issue
Block a user