CTest: Add CTEST_SUBMIT_INACTIVITY_TIMEOUT variable

Fixes: #22617
This commit is contained in:
Nikhil Reddy Ramolla
2021-10-02 00:40:55 +05:30
committed by Brad King
parent 1c12694124
commit 5d178fcc53
9 changed files with 54 additions and 3 deletions
+1
View File
@@ -1608,6 +1608,7 @@ syn keyword cmakeVariable contained
\ CTEST_SCP_COMMAND \ CTEST_SCP_COMMAND
\ CTEST_SITE \ CTEST_SITE
\ CTEST_SOURCE_DIRECTORY \ CTEST_SOURCE_DIRECTORY
\ CTEST_SUBMIT_INACTIVITY_TIMEOUT
\ CTEST_SUBMIT_URL \ CTEST_SUBMIT_URL
\ CTEST_SVN_COMMAND \ CTEST_SVN_COMMAND
\ CTEST_SVN_OPTIONS \ CTEST_SVN_OPTIONS
+1
View File
@@ -665,6 +665,7 @@ Variables for CTest
/variable/CTEST_SCP_COMMAND /variable/CTEST_SCP_COMMAND
/variable/CTEST_SCRIPT_DIRECTORY /variable/CTEST_SCRIPT_DIRECTORY
/variable/CTEST_SITE /variable/CTEST_SITE
/variable/CTEST_SUBMIT_INACTIVITY_TIMEOUT
/variable/CTEST_SUBMIT_URL /variable/CTEST_SUBMIT_URL
/variable/CTEST_SOURCE_DIRECTORY /variable/CTEST_SOURCE_DIRECTORY
/variable/CTEST_SVN_COMMAND /variable/CTEST_SVN_COMMAND
+7
View File
@@ -1349,6 +1349,13 @@ Configuration settings include:
* :module:`CTest` module variable: ``SUBMIT_URL`` if set, * :module:`CTest` module variable: ``SUBMIT_URL`` if set,
else ``CTEST_SUBMIT_URL`` 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`` ``TriggerSite``
Legacy option. Not used. Legacy option. Not used.
@@ -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.
@@ -0,0 +1,5 @@
CTEST_SUBMIT_INACTIVITY_TIMEOUT
-------------------------------
Specify the CTest ``SubmitInactivityTimeout`` setting
in a :manual:`ctest(1)` dashboard client script.
+1
View File
@@ -21,6 +21,7 @@ LabelsForSubprojects: @CTEST_LABELS_FOR_SUBPROJECTS@
# Submission information # Submission information
SubmitURL: @SUBMIT_URL@ SubmitURL: @SUBMIT_URL@
SubmitInactivityTimeout: @CTEST_SUBMIT_INACTIVITY_TIMEOUT@
# Dashboard start time # Dashboard start time
NightlyStartTime: @NIGHTLY_START_TIME@ NightlyStartTime: @NIGHTLY_START_TIME@
+3
View File
@@ -58,6 +58,9 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet); this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "SubmitInactivityTimeout",
"CTEST_SUBMIT_INACTIVITY_TIMEOUT", this->Quiet);
cmValue notesFilesVariable = cmValue notesFilesVariable =
this->Makefile->GetDefinition("CTEST_NOTES_FILES"); this->Makefile->GetDefinition("CTEST_NOTES_FILES");
+30 -3
View File
@@ -7,6 +7,7 @@
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>
#include <cm/iomanip>
#include <cmext/algorithm> #include <cmext/algorithm>
#include <cm3p/curl/curl.h> #include <cm3p/curl/curl.h>
@@ -216,8 +217,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
// if there is little to no activity for too long stop submitting // 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_LIMIT, 1);
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, auto submitInactivityTimeout = this->GetSubmitInactivityTimeout();
SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); if (submitInactivityTimeout != 0) {
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
submitInactivityTimeout);
}
/* HTTP PUT please */ /* HTTP PUT please */
::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::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::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
std::vector<std::string> args = cmExpandedList(curlopt); std::vector<std::string> args = cmExpandedList(curlopt);
curl.SetCurlOptions(args); curl.SetCurlOptions(args);
curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); auto submitInactivityTimeout = this->GetSubmitInactivityTimeout();
if (submitInactivityTimeout != 0) {
curl.SetTimeOutSeconds(submitInactivityTimeout);
}
curl.SetHttpHeaders(this->HttpHeaders); curl.SetHttpHeaders(this->HttpHeaders);
std::string url = this->CTest->GetSubmitURL(); std::string url = this->CTest->GetSubmitURL();
if (!cmHasLiteralPrefix(url, "http://") && if (!cmHasLiteralPrefix(url, "http://") &&
@@ -893,6 +900,26 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> 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<int>(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<std::string> const& files) void cmCTestSubmitHandler::SelectFiles(std::set<std::string> const& files)
{ {
this->Files.insert(files.begin(), files.end()); this->Files.insert(files.begin(), files.end());
+1
View File
@@ -63,6 +63,7 @@ private:
void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk); void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk);
std::string GetSubmitResultsPrefix(); std::string GetSubmitResultsPrefix();
int GetSubmitInactivityTimeout();
class ResponseParser; class ResponseParser;