mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-07 21:48:30 +00:00
Use all projects executions now running query for api V9
This commit is contained in:
parent
2854fa9df3
commit
4249dd54bb
3 changed files with 45 additions and 4 deletions
|
@ -2668,11 +2668,16 @@ public class RundeckClient implements Serializable {
|
|||
*/
|
||||
public List<RundeckExecution> getRunningExecutions() throws RundeckApiException, RundeckApiLoginException,
|
||||
RundeckApiTokenException {
|
||||
List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
|
||||
for (RundeckProject project : getProjects()) {
|
||||
executions.addAll(getRunningExecutions(project.getName()));
|
||||
if (this.getApiVersion() >= Version.V9.getVersionNumber()) {
|
||||
//simply query using '*'
|
||||
return getRunningExecutions("*");
|
||||
} else {
|
||||
List<RundeckExecution> executions = new ArrayList<RundeckExecution>();
|
||||
for (RundeckProject project : getProjects()) {
|
||||
executions.addAll(getRunningExecutions(project.getName()));
|
||||
}
|
||||
return executions;
|
||||
}
|
||||
return executions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,6 +53,7 @@ public class RundeckClientTest {
|
|||
public static final String TEST_TOKEN_2 = "PP4s4SdCRO6KUoNPd1D303Dc304ORN87";
|
||||
public static final String TEST_TOKEN_3 = "9RdEosesKP3se4oV9EKOd4s3RUeUS3ON";
|
||||
public static final String TEST_TOKEN_4 = "sN5RRSNvu15DnV6EcNDdc2CkdPcv3s32";
|
||||
public static final String TEST_TOKEN_5 = "C3O6d5O98Kr6Dpv71sdE4ERdCuU12P6d";
|
||||
|
||||
@Rule
|
||||
public Recorder recorder = new Recorder();
|
||||
|
@ -911,6 +912,21 @@ public class RundeckClientTest {
|
|||
Assert.assertEquals("importJobsProjectParamV7", rundeckJob.getName());
|
||||
Assert.assertEquals("testXYZ", rundeckJob.getProject());
|
||||
}
|
||||
/**
|
||||
* Running executions for all projects using API v9
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Betamax(tape = "running_executions_v9")
|
||||
public void runningExecutionsV9() throws Exception {
|
||||
final RundeckClient client = createClient(TEST_TOKEN_5, 9);
|
||||
List<RundeckExecution> runningExecutions = client.getRunningExecutions();
|
||||
Assert.assertEquals(2, runningExecutions.size());
|
||||
RundeckExecution exec1 = runningExecutions.get(0);
|
||||
Assert.assertEquals("test", exec1.getProject());
|
||||
RundeckExecution exec2 = runningExecutions.get(1);
|
||||
Assert.assertEquals("test2", exec2.getProject());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
20
src/test/resources/betamax/tapes/running_executions_v9.yaml
Normal file
20
src/test/resources/betamax/tapes/running_executions_v9.yaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
!tape
|
||||
name: running_executions_v9
|
||||
interactions:
|
||||
- recorded: 2013-08-21T17:03:14.308Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/9/executions/running?project=*
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 9
|
||||
X-RunDeck-Auth-Token: C3O6d5O98Kr6Dpv71sdE4ERdCuU12P6d
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml; charset=utf-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(6.1.21)
|
||||
Set-Cookie: JSESSIONID=1voch0o7fzo55;Path=/
|
||||
body: <result success='true' apiversion='9'><executions count='2'><execution id='119' href='http://dignan:4440/execution/follow/119' status='running' project='test'><user>admin</user><date-started unixtime='1377104570966'>2013-08-21T17:02:50Z</date-started><description>echo asdf; sleep 120</description><argstring/></execution><execution id='118' href='http://dignan:4440/execution/follow/118' status='running' project='test2'><user>admin</user><date-started unixtime='1377104560345'>2013-08-21T17:02:40Z</date-started><description>echo asdf; sleep 120</description><argstring/></execution></executions></result>
|
Loading…
Add table
Add a link
Reference in a new issue