Use all projects executions now running query for api V9

This commit is contained in:
Greg Schueler 2013-08-21 10:16:32 -07:00
parent 2854fa9df3
commit 4249dd54bb
3 changed files with 45 additions and 4 deletions

View file

@ -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;
}
/**

View file

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

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