Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions regression-test/plugins/plugin_curl_requester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,37 @@ Suite.metaClass.curl = { String method, String url /* param */->
}

Integer timeout = 10; // 10 seconds;
Integer maxRetries = 10; // Maximum number of retries
Integer retryCount = 0; // Current retry count
Integer sleepTime = 5000; // Sleep time in milliseconds

String cmd = String.format("curl --max-time %d -X %s %s", timeout, method, url).toString()
logger.info("curl cmd: " + cmd)
def process = cmd.execute()
int code = process.waitFor()
String err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream())))
String out = process.getText()
def process
int code
String err
String out

while (retryCount < maxRetries) {
process = cmd.execute()
code = process.waitFor()
err = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(process.getErrorStream())))
out = process.getText()

// If the command was successful, break the loop
if (code == 0) {
break
}

// If the command was not successful, increment the retry count, sleep for a while and try again
retryCount++
sleep(sleepTime)
}

// If the command was not successful after maxRetries attempts, log the failure and return the result
if (code != 0) {
logger.error("Command curl failed after " + maxRetries + " attempts. code: " + code + ", err: " + err)
}

return [code, out, err]
}
Expand Down