mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
Merge topic 'ExternalProject-retry-only-recoverable'
116b06870dExternalProject: add INACTIVITY_TIMEOUT argumentf24e34975aExternalProject: retry download on recoverable errors Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5034
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND "")
|
||||
@@ -0,0 +1 @@
|
||||
[^0]
|
||||
@@ -0,0 +1 @@
|
||||
(Timeout was reached)?
|
||||
@@ -0,0 +1,5 @@
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND "")
|
||||
@@ -0,0 +1,42 @@
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
import argparse
|
||||
import time
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
args = None
|
||||
outerthread = None
|
||||
|
||||
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
data = b'D'
|
||||
|
||||
if args.speed_limit:
|
||||
slow_deadline = time.time()+args.limit_duration
|
||||
|
||||
while time.time() < slow_deadline:
|
||||
self.wfile.write(data)
|
||||
if args.speed_limit:
|
||||
time.sleep(1.1)
|
||||
|
||||
data = data * 100
|
||||
self.wfile.write(data)
|
||||
self.close_connection = True
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False)
|
||||
parser.add_argument('--limit_duration', help='duration of the transfer rate limitation',default=1, type=float)
|
||||
parser.add_argument('--file', help='file to write the url to connect to')
|
||||
parser.add_argument('--subprocess', action='store_true')
|
||||
args = parser.parse_args()
|
||||
if not args.subprocess:
|
||||
subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL)
|
||||
else:
|
||||
httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler)
|
||||
with open(args.file,"w") as f:
|
||||
f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1]))
|
||||
httpd.handle_request()
|
||||
os.remove(args.file)
|
||||
@@ -0,0 +1 @@
|
||||
^[^0]
|
||||
@@ -0,0 +1 @@
|
||||
.*
|
||||
@@ -0,0 +1,5 @@
|
||||
include(ExternalProject)
|
||||
set(source_dir "${CMAKE_CURRENT_BINARY_DIR}/DownloadTimeout")
|
||||
file(REMOVE_RECURSE "${source_dir}")
|
||||
file(MAKE_DIRECTORY "${source_dir}")
|
||||
ExternalProject_Add(MyProj URL "http://cmake.org/invalid_file.tar.gz")
|
||||
@@ -1,5 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
include(RunCMake)
|
||||
|
||||
# We do not contact any remote URLs, but may use a local one.
|
||||
# Remove any proxy configuration that may change behavior.
|
||||
unset(ENV{http_proxy})
|
||||
unset(ENV{https_proxy})
|
||||
|
||||
run_cmake(IncludeScope-Add)
|
||||
run_cmake(IncludeScope-Add_Step)
|
||||
run_cmake(NoOptions)
|
||||
@@ -27,6 +33,50 @@ function(__ep_test_with_build testName)
|
||||
run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
|
||||
endfunction()
|
||||
|
||||
find_package(Python3)
|
||||
function(__ep_test_with_build_with_server testName)
|
||||
if(NOT Python3_EXECUTABLE)
|
||||
return()
|
||||
endif()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_TIMEOUT 20)
|
||||
set(RunCMake_TEST_OUTPUT_MERGE TRUE)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
set(URL_FILE ${RunCMake_BINARY_DIR}/${testName}.url)
|
||||
if(EXISTS "${URL_FILE}")
|
||||
file(REMOVE "${URL_FILE}")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN}
|
||||
OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
|
||||
ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
|
||||
RESULT_VARIABLE result
|
||||
TIMEOUT 30
|
||||
)
|
||||
if(NOT result EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to start download server:\n ${result}")
|
||||
endif()
|
||||
|
||||
foreach(i RANGE 1 8)
|
||||
if(EXISTS ${URL_FILE})
|
||||
break()
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${i})
|
||||
endforeach()
|
||||
|
||||
if(NOT EXISTS ${URL_FILE})
|
||||
message(FATAL_ERROR "Failed to load download server URL from:\n ${URL_FILE}")
|
||||
endif()
|
||||
|
||||
file(READ ${URL_FILE} SERVER_URL)
|
||||
message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}")
|
||||
run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DSERVER_URL=${SERVER_URL} )
|
||||
run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean)
|
||||
run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
|
||||
endfunction()
|
||||
|
||||
__ep_test_with_build(MultiCommand)
|
||||
|
||||
set(RunCMake_TEST_OUTPUT_MERGE 1)
|
||||
@@ -38,6 +88,9 @@ set(RunCMake_TEST_OUTPUT_MERGE 0)
|
||||
if(NOT RunCMake_GENERATOR MATCHES "Visual Studio")
|
||||
__ep_test_with_build(LogOutputOnFailure)
|
||||
__ep_test_with_build(LogOutputOnFailureMerged)
|
||||
__ep_test_with_build(DownloadTimeout)
|
||||
__ep_test_with_build_with_server(DownloadInactivityTimeout --speed_limit --limit_duration 40)
|
||||
__ep_test_with_build_with_server(DownloadInactivityResume --speed_limit --limit_duration 1)
|
||||
endif()
|
||||
|
||||
# We can't test the substitution when using the old MSYS due to
|
||||
|
||||
Reference in New Issue
Block a user