-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8998 from rundeck/RSE-873-scheduled-forecast-gui-…
…errors
- Loading branch information
Showing
10 changed files
with
375 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
functional-test/src/test/groovy/org/rundeck/util/common/projects/ProjectUtils.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.rundeck.util.common.projects | ||
|
||
import org.rundeck.util.common.jobs.JobUtils | ||
import org.rundeck.util.container.RdClient | ||
|
||
class ProjectUtils { | ||
|
||
/** | ||
* Creates projects with scheduled jobs. | ||
* | ||
* @param suffixProjectName The suffix to be added to project names. | ||
* @param projectsCount The number of projects to create. | ||
* @param jobsCountsPerProject The number of jobs to schedule per project. | ||
* @param client The RdClient object used to interact with the Rundeck API. | ||
* @throws RuntimeException If failed to create a project. | ||
*/ | ||
static void createProjectsWithJobsScheduled(String suffixProjectName, int projectsCount, int jobsCountsPerProject, RdClient client) { | ||
(1..projectsCount).each {it -> | ||
def projectName = "${suffixProjectName}-${it}".toString() | ||
def getProject = client.doGet("/project/${projectName}") | ||
if (getProject.code() == 404) { | ||
def post = client.doPost("/projects", [name: projectName]) | ||
if (!post.successful) { | ||
throw new RuntimeException("Failed to create project: ${post.body().string()}") | ||
} | ||
} | ||
(1..jobsCountsPerProject).each {it2 -> | ||
def pathFile = JobUtils.updateJobFileToImport("api-test-executions-running-scheduled.xml", projectName) | ||
def imported = JobUtils.jobImportFile(projectName, pathFile, client) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves the count of running executions for a given project, waiting until the count exceeds a specified value or a timeout occurs. | ||
* | ||
* @param projectName The name of the project to query. Must not be null. | ||
* @param valueMoreThan The threshold value for the count of running executions. Must be greater than zero. | ||
* @param client The RdClient instance used to make HTTP requests. Must not be null. | ||
* @return True if the count of running executions exceeds the specified value within the timeout period, false otherwise. | ||
* @throws RuntimeException if fetching running executions fails or if a timeout occurs. | ||
*/ | ||
static def projectCountExecutions = (String projectName, int valueMoreThan, RdClient client) -> { | ||
def startTime = System.currentTimeMillis() | ||
def timeout = 10000 | ||
def pollingInterval = 1000 | ||
while (true) { | ||
def response = client.doGet("/project/${projectName}/executions/running?includePostponed=true") | ||
if (!response.successful) { | ||
throw new RuntimeException("Failed to get running executions: ${response.body().string()}") | ||
} | ||
def valueCount = client.jsonValue(response.body(), Map).paging.count | ||
if (valueCount > valueMoreThan) { | ||
return Boolean.TRUE | ||
} | ||
if (System.currentTimeMillis() - startTime > timeout) { | ||
throw new RuntimeException("Timeout: No running executions found within ${timeout} milliseconds.") | ||
} | ||
sleep pollingInterval | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
functional-test/src/test/resources/test-files/api-test-executions-running-scheduled.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<joblist> | ||
<job> | ||
<defaultTab>nodes</defaultTab> | ||
<description></description> | ||
<executionEnabled>true</executionEnabled> | ||
<id>d9500676-1cba-4e67-adec-1c28ad935048</id> | ||
<loglevel>INFO</loglevel> | ||
<name>Simple Scheduled job</name> | ||
<nodeFilterEditable>false</nodeFilterEditable> | ||
<plugins /> | ||
<schedule crontab="*/4 * * ? * * *"/> | ||
<scheduleEnabled>true</scheduleEnabled> | ||
<multipleExecutions>true</multipleExecutions> | ||
<sequence keepgoing='false'> | ||
<command> | ||
<exec>echo '1'; sleep 5</exec> | ||
</command> | ||
</sequence> | ||
<uuid>xml-uuid</uuid> | ||
</job> | ||
</joblist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.