mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-06 13:08:38 +00:00
WIP: add client interface to execution state endpoint
This commit is contained in:
parent
cbdb5c818e
commit
ba136cfc44
3 changed files with 56 additions and 0 deletions
|
@ -3281,6 +3281,25 @@ public class RundeckClient implements Serializable {
|
|||
return new ApiCall(this).get(param,
|
||||
new OutputParser("result/output", createOutputEntryParser()));
|
||||
}
|
||||
/**
|
||||
* Get the execution state of the given execution
|
||||
*
|
||||
* @param executionId identifier of the execution - mandatory
|
||||
* @return {@link RundeckExecutionState} the execution state
|
||||
* @throws RundeckApiException in case of error when calling the API (non-existent job with this ID)
|
||||
* @throws RundeckApiLoginException if the login fails (in case of login-based authentication)
|
||||
* @throws RundeckApiTokenException if the token is invalid (in case of token-based authentication)
|
||||
* @throws IllegalArgumentException if the jobId is blank (null, empty or whitespace)
|
||||
*/
|
||||
public RundeckExecutionState getExecutionState(Long executionId)
|
||||
throws RundeckApiException, RundeckApiLoginException, RundeckApiTokenException, IllegalArgumentException {
|
||||
AssertUtil.notNull(executionId, "executionId is mandatory to get the state of an execution!");
|
||||
ApiPathBuilder param = new ApiPathBuilder(
|
||||
"/execution/", executionId.toString(),
|
||||
"/state");
|
||||
|
||||
return new ApiCall(this).get(param, new ExecutionStateParser("result/executionState"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the execution output of the given execution on the specified node
|
||||
|
|
|
@ -1186,6 +1186,22 @@ public class RundeckClientTest {
|
|||
Assert.assertEquals(false, output.isUnmodified());
|
||||
Assert.assertEquals(12, output.getLogEntries().size());
|
||||
}
|
||||
/**
|
||||
* Execution state structure
|
||||
*/
|
||||
@Test
|
||||
@Betamax(tape = "execution_state", mode = TapeMode.READ_ONLY)
|
||||
public void executionState() throws Exception {
|
||||
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
|
||||
RundeckExecutionState output = client.getExecutionState(149L);
|
||||
|
||||
Assert.assertEquals(149,output.getExecutionId());
|
||||
Assert.assertEquals(3,output.getTargetNodes().size());
|
||||
Assert.assertEquals(3,output.getAllNodes().size());
|
||||
Assert.assertEquals(1,output.getStepCount());
|
||||
Assert.assertEquals(1,output.getSteps().size());
|
||||
Assert.assertEquals(RundeckWFExecState.SUCCEEDED,output.getExecutionState());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
21
src/test/resources/betamax/tapes/execution_state.yaml
Normal file
21
src/test/resources/betamax/tapes/execution_state.yaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
!tape
|
||||
name: execution_state
|
||||
interactions:
|
||||
- recorded: 2014-01-18T18:24:49.806Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/10/execution/149/state
|
||||
headers:
|
||||
Accept: text/xml
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 10
|
||||
X-RunDeck-Auth-Token: Do4d3NUD5DKk21DR4sNK755RcPk618vn
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(7.6.0.v20120127)
|
||||
Set-Cookie: JSESSIONID=x0rnzzfb3xi410pethl5ttvjb;Path=/
|
||||
body: <result success='true' apiversion='10'><executionState id='149'><startTime>2014-01-18T17:29:19Z</startTime><stepCount>1</stepCount><allNodes><nodes><node name='node-111.qa.subgroup.mycompany.com'></node><node name='node-14.qa.subgroup.mycompany.com'></node><node name='node-6.qa.subgroup.mycompany.com'></node></nodes></allNodes><targetNodes><nodes><node name='node-111.qa.subgroup.mycompany.com'></node><node name='node-14.qa.subgroup.mycompany.com'></node><node name='node-6.qa.subgroup.mycompany.com'></node></nodes></targetNodes><updateTime>2014-01-18T17:29:20Z</updateTime><executionId>149</executionId><serverNode>dignan</serverNode><endTime>2014-01-18T17:29:20Z</endTime><executionState>SUCCEEDED</executionState><completed>true</completed><steps><step stepctx='1' id='1'><startTime>2014-01-18T17:29:19Z</startTime><nodeStep>true</nodeStep><updateTime>2014-01-18T17:29:20Z</updateTime><endTime>2014-01-18T17:29:20Z</endTime><executionState>SUCCEEDED</executionState><nodeStates><nodeState name='node-111.qa.subgroup.mycompany.com'><startTime>2014-01-18T17:29:19Z</startTime><updateTime>2014-01-18T17:29:20Z</updateTime><endTime>2014-01-18T17:29:20Z</endTime><executionState>SUCCEEDED</executionState></nodeState><nodeState name='node-6.qa.subgroup.mycompany.com'><startTime>2014-01-18T17:29:20Z</startTime><updateTime>2014-01-18T17:29:20Z</updateTime><endTime>2014-01-18T17:29:20Z</endTime><executionState>SUCCEEDED</executionState></nodeState><nodeState name='node-14.qa.subgroup.mycompany.com'><startTime>2014-01-18T17:29:20Z</startTime><updateTime>2014-01-18T17:29:20Z</updateTime><endTime>2014-01-18T17:29:20Z</endTime><executionState>SUCCEEDED</executionState></nodeState></nodeStates></step></steps><nodes><node name='node-111.qa.subgroup.mycompany.com'><steps><step><stepctx>1</stepctx><executionState>SUCCEEDED</executionState></step></steps></node><node name='node-6.qa.subgroup.mycompany.com'><steps><step><stepctx>1</stepctx><executionState>SUCCEEDED</executionState></step></steps></node><node name='node-14.qa.subgroup.mycompany.com'><steps><step><stepctx>1</stepctx><executionState>SUCCEEDED</executionState></step></steps></node></nodes></executionState></result>
|
Loading…
Add table
Add a link
Reference in a new issue