From 5d178fcc53d0075bb6f6d93a862b67c66a0d1add Mon Sep 17 00:00:00 2001 From: Nikhil Reddy Ramolla Date: Sat, 2 Oct 2021 00:40:55 +0530 Subject: CTest: Add CTEST_SUBMIT_INACTIVITY_TIMEOUT variable Fixes: #22617 --- Auxiliary/vim/syntax/cmake.vim | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/manual/ctest.1.rst | 7 +++++ .../dev/ctest_submit-inactivity-timeout.rst | 5 ++++ Help/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT.rst | 5 ++++ Modules/DartConfiguration.tcl.in | 1 + Source/CTest/cmCTestSubmitCommand.cxx | 3 ++ Source/CTest/cmCTestSubmitHandler.cxx | 33 ++++++++++++++++++++-- Source/CTest/cmCTestSubmitHandler.h | 1 + 9 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 Help/release/dev/ctest_submit-inactivity-timeout.rst create mode 100644 Help/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT.rst diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 7a3e4ed..e09ecf3 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -1608,6 +1608,7 @@ syn keyword cmakeVariable contained \ CTEST_SCP_COMMAND \ CTEST_SITE \ CTEST_SOURCE_DIRECTORY + \ CTEST_SUBMIT_INACTIVITY_TIMEOUT \ CTEST_SUBMIT_URL \ CTEST_SVN_COMMAND \ CTEST_SVN_OPTIONS diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index a2103f7..ad96c09 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -665,6 +665,7 @@ Variables for CTest /variable/CTEST_SCP_COMMAND /variable/CTEST_SCRIPT_DIRECTORY /variable/CTEST_SITE + /variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT /variable/CTEST_SUBMIT_URL /variable/CTEST_SOURCE_DIRECTORY /variable/CTEST_SVN_COMMAND diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 03d8bf6..52e8009 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -1349,6 +1349,13 @@ Configuration settings include: * :module:`CTest` module variable: ``SUBMIT_URL`` if set, else ``CTEST_SUBMIT_URL`` +``SubmitInactivityTimeout`` + The time to wait for the submission after which it is canceled + if not completed. Specify a zero value to disable timeout. + + * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_INACTIVITY_TIMEOUT` + * :module:`CTest` module variable: ``CTEST_SUBMIT_INACTIVITY_TIMEOUT`` + ``TriggerSite`` Legacy option. Not used. diff --git a/Help/release/dev/ctest_submit-inactivity-timeout.rst b/Help/release/dev/ctest_submit-inactivity-timeout.rst new file mode 100644 index 0000000..3d4c408 --- /dev/null +++ b/Help/release/dev/ctest_submit-inactivity-timeout.rst @@ -0,0 +1,5 @@ +ctest_submit-inactivity-timeout +------------------------------- + +* :manual:`ctest(1)` gained a new :variable:`CTEST_SUBMIT_INACTIVITY_TIMEOUT` + variable, which can be used to specify a timeout for submission inactivity. diff --git a/Help/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT.rst b/Help/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT.rst new file mode 100644 index 0000000..65976fa --- /dev/null +++ b/Help/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT.rst @@ -0,0 +1,5 @@ +CTEST_SUBMIT_INACTIVITY_TIMEOUT +------------------------------- + +Specify the CTest ``SubmitInactivityTimeout`` setting +in a :manual:`ctest(1)` dashboard client script. diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index e5b1e5d..afa36f7 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -21,6 +21,7 @@ LabelsForSubprojects: @CTEST_LABELS_FOR_SUBPROJECTS@ # Submission information SubmitURL: @SUBMIT_URL@ +SubmitInactivityTimeout: @CTEST_SUBMIT_INACTIVITY_TIMEOUT@ # Dashboard start time NightlyStartTime: @NIGHTLY_START_TIME@ diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index c4f87e9..a2dc615 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -58,6 +58,9 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable( + this->Makefile, "SubmitInactivityTimeout", + "CTEST_SUBMIT_INACTIVITY_TIMEOUT", this->Quiet); cmValue notesFilesVariable = this->Makefile->GetDefinition("CTEST_NOTES_FILES"); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index b99bb79..fae5e30 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -216,8 +217,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( // if there is little to no activity for too long stop submitting ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1); - ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, - SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); + auto submitInactivityTimeout = this->GetSubmitInactivityTimeout(); + if (submitInactivityTimeout != 0) { + ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, + submitInactivityTimeout); + } /* HTTP PUT please */ ::curl_easy_setopt(curl, CURLOPT_PUT, 1); @@ -499,7 +503,10 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector args = cmExpandedList(curlopt); curl.SetCurlOptions(args); - curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); + auto submitInactivityTimeout = this->GetSubmitInactivityTimeout(); + if (submitInactivityTimeout != 0) { + curl.SetTimeOutSeconds(submitInactivityTimeout); + } curl.SetHttpHeaders(this->HttpHeaders); std::string url = this->CTest->GetSubmitURL(); if (!cmHasLiteralPrefix(url, "http://") && @@ -893,6 +900,26 @@ void cmCTestSubmitHandler::SelectParts(std::set const& parts) } } +int cmCTestSubmitHandler::GetSubmitInactivityTimeout() +{ + int submitInactivityTimeout = SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT; + std::string const& timeoutStr = + this->CTest->GetCTestConfiguration("SubmitInactivityTimeout"); + if (!timeoutStr.empty()) { + unsigned long timeout; + if (cmStrToULong(timeoutStr, &timeout)) { + submitInactivityTimeout = static_cast(timeout); + } else { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "SubmitInactivityTimeout is invalid: " + << cm::quoted(timeoutStr) << "." + << " Using a default value of " + << SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT << "." << std::endl); + } + } + return submitInactivityTimeout; +} + void cmCTestSubmitHandler::SelectFiles(std::set const& files) { this->Files.insert(files.begin(), files.end()); diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 809c615..0c7253c 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -63,6 +63,7 @@ private: void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk); std::string GetSubmitResultsPrefix(); + int GetSubmitInactivityTimeout(); class ResponseParser; -- cgit v0.12