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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -0,0 +1,5 @@
CTEST_SUBMIT_INACTIVITY_TIMEOUT
-------------------------------
Specify the CTest ``SubmitInactivityTimeout`` setting
in a :manual:`ctest(1)` dashboard client script.

View File

@@ -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@

View File

@@ -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");

View File

@@ -7,6 +7,7 @@
#include <cstdlib>
#include <sstream>
#include <cm/iomanip>
#include <cmext/algorithm>
#include <cm3p/curl/curl.h>
@@ -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<std::string> 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<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)
{
this->Files.insert(files.begin(), files.end());

View File

@@ -63,6 +63,7 @@ private:
void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk);
std::string GetSubmitResultsPrefix();
int GetSubmitInactivityTimeout();
class ResponseParser;