Merge pull request #9 from rundeck/apiv10

Support Rundeck API v10 (Rundeck 2.0)
This commit is contained in:
Greg Schueler 2014-02-27 09:45:18 -08:00
commit ee9e4f3c54
50 changed files with 2380 additions and 1730 deletions

View file

@ -27,7 +27,7 @@
<!-- Project informations -->
<groupId>org.rundeck</groupId>
<artifactId>rundeck-api-java-client</artifactId>
<version>9.4-SNAPSHOT</version>
<version>10.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>RunDeck API - Java Client</name>
<description>Java client for the RunDeck REST API</description>

View file

@ -22,6 +22,23 @@
<author>Vincent Behar</author>
</properties>
<body>
<release date='TBD' description='Rundeck API version 10' version='10.0-SNAPSHOT'>
<action type='add' dev='gschueler'>
Execution State - Retrieve workflow step and node state information
</action>
<action type='add' dev='gschueler'>
Execution Output with State - Retrieve log output with state change information
</action>
<action type='add' dev='gschueler'>
Execution Output - Retrieve log output for a particular node or step.
</action>
<action type='add' dev='gschueler'>
Execution Info - added successfulNodes and failedNodes detail.
</action>
<action type='remove' dev='gschueler'>
Remove deprecated RundeckClient methods.
</action>
</release>
<release date='2014-01-24' description='Bugfix' version='9.3'>
<action type='fix' dev='gschueler'>
Issue #7: Fix authentication to Tomcat container (thanks @katanafleet)

View file

@ -115,7 +115,8 @@ class ApiCall {
/**
* Test the authentication on the RunDeck instance. Will delegate to either {@link #testLoginAuth()} (in case of
* login-based auth) or {@link #testTokenAuth()} (in case of token-based auth).
*
*
* @return the login session ID if using login-based auth, otherwise null
* @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)
* @see #testLoginAuth()
@ -177,7 +178,11 @@ class ApiCall {
*/
public <T> T get(ApiPathBuilder apiPath, XmlNodeParser<T> parser) throws RundeckApiException,
RundeckApiLoginException, RundeckApiTokenException {
return execute(new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath), parser);
HttpGet request = new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath);
if (null != apiPath.getAccept()) {
request.setHeader("Accept", apiPath.getAccept());
}
return execute(request, parser);
}
/**
@ -192,7 +197,11 @@ class ApiCall {
*/
public InputStream get(ApiPathBuilder apiPath) throws RundeckApiException, RundeckApiLoginException,
RundeckApiTokenException {
ByteArrayInputStream response = execute(new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath));
HttpGet request = new HttpGet(client.getUrl() + client.getApiEndpoint() + apiPath);
if (null != apiPath.getAccept()) {
request.setHeader("Accept", apiPath.getAccept());
}
ByteArrayInputStream response = execute(request);
// try to load the document, to throw an exception in case of error
ParserHelper.loadDocument(response);
@ -213,7 +222,11 @@ class ApiCall {
*/
public InputStream getNonApi(ApiPathBuilder apiPath) throws RundeckApiException, RundeckApiLoginException,
RundeckApiTokenException {
ByteArrayInputStream response = execute(new HttpGet(client.getUrl() + apiPath));
HttpGet request = new HttpGet(client.getUrl() + apiPath);
if (null != apiPath.getAccept()) {
request.setHeader("Accept", apiPath.getAccept());
}
ByteArrayInputStream response = execute(request);
response.reset();
return response;
@ -257,7 +270,9 @@ class ApiCall {
public <T> T post(ApiPathBuilder apiPath, XmlNodeParser<T> parser) throws RundeckApiException,
RundeckApiLoginException, RundeckApiTokenException {
HttpPost httpPost = new HttpPost(client.getUrl() + client.getApiEndpoint() + apiPath);
if(null!= apiPath.getAccept()) {
httpPost.setHeader("Accept", apiPath.getAccept());
}
// POST a multi-part request, with all attachments
if(apiPath.getAttachments().size()>0){
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

View file

@ -38,6 +38,8 @@ class ApiPathBuilder {
/** Internally, we store everything in a {@link StringBuilder} */
private final StringBuilder apiPath;
private String accept="text/xml";
/** When POSTing, we can add attachments */
private final Map<String, InputStream> attachments;
private final List<NameValuePair> form = new ArrayList<NameValuePair>();
@ -63,6 +65,13 @@ class ApiPathBuilder {
}
}
/**
* Set the accept header
*/
public ApiPathBuilder accept(String mimeTypes) {
accept=mimeTypes;
return this;
}
/**
* Visit a {@link BuildsParameters} and add the parameters
*/
@ -305,6 +314,13 @@ class ApiPathBuilder {
return getAttachments().size() > 0 || getForm().size() > 0;
}
/**
* Accept header value, default "text/xml"
*/
public String getAccept() {
return accept;
}
/**
* BuildsParameters can add URL or POST parameters to an {@link ApiPathBuilder}
*

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
package org.rundeck.api.domain;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* Base execution status for a step
*/
public class BaseState {
private Date startTime;
private Date endTime;
private Date updateTime;
private RundeckWFExecState executionState;
/**
* Time that the execution of this step started
* @return
*/
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
/**
* Time that the execution of this step finished, or null if it has not completed
* @return
*/
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* Current state of the execution
* @return
*/
public RundeckWFExecState getExecutionState() {
return executionState;
}
public void setExecutionState(RundeckWFExecState executionState) {
this.executionState = executionState;
}
/**
* Time that this state was last updated
* @return
*/
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View file

@ -17,6 +17,7 @@ package org.rundeck.api.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.time.DurationFormatUtils;
@ -52,6 +53,8 @@ public class RundeckExecution implements Serializable {
private String description;
private String argstring;
private String project;
private Set<RundeckNodeIdentity> successfulNodes;
private Set<RundeckNodeIdentity> failedNodes;
/**
* @return the duration of the execution in milliseconds (or null if the duration is still running, or has been
@ -174,7 +177,10 @@ public class RundeckExecution implements Serializable {
return "RundeckExecution [id=" + id + ", description=" + description + ", url=" + url + ", status=" + status
+ ", argstring=" + argstring
+ ", startedBy=" + startedBy + ", startedAt=" + startedAt + ", endedAt=" + endedAt
+ ", durationInSeconds=" + getDurationInSeconds() + ", abortedBy=" + abortedBy + ", job=" + job + "]";
+ ", durationInSeconds=" + getDurationInSeconds() + ", abortedBy=" + abortedBy + ", job=" + job
+ ", successfulNodes=" + getSuccessfulNodes()
+ ", failedNodes=" + getFailedNodes()
+ "]";
}
@Override
@ -281,6 +287,22 @@ public class RundeckExecution implements Serializable {
this.project = project;
}
public Set<RundeckNodeIdentity> getSuccessfulNodes() {
return successfulNodes;
}
public void setSuccessfulNodes(Set<RundeckNodeIdentity> successfulNodes) {
this.successfulNodes = successfulNodes;
}
public Set<RundeckNodeIdentity> getFailedNodes() {
return failedNodes;
}
public void setFailedNodes(Set<RundeckNodeIdentity> failedNodes) {
this.failedNodes = failedNodes;
}
/**
* The status of an execution
*/

View file

@ -0,0 +1,50 @@
package org.rundeck.api.domain;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* The state of an Execution
*/
public class RundeckExecutionState extends WorkflowState{
private long executionId;
private Set<RundeckNodeIdentity> allNodes;
private Map<String, List<WorkflowStepContextState>> nodeStates;
/**
* Return the set of all rundeck nodes targeted in this execution
* @return
*/
public Set<RundeckNodeIdentity> getAllNodes() {
return allNodes;
}
public void setAllNodes(Set<RundeckNodeIdentity> allNodes) {
this.allNodes = allNodes;
}
/**
* Return the map of node name to step state list
* @return
*/
public Map<String, List<WorkflowStepContextState>> getNodeStates() {
return nodeStates;
}
public void setNodeStates(Map<String, List<WorkflowStepContextState>> nodeStates) {
this.nodeStates = nodeStates;
}
/**
* Return this execution's ID
* @return
*/
public long getExecutionId() {
return executionId;
}
public void setExecutionId(long executionId) {
this.executionId = executionId;
}
}

View file

@ -23,7 +23,7 @@ import java.util.List;
*
* @author Vincent Behar
*/
public class RundeckNode implements Serializable {
public class RundeckNode implements Serializable, RundeckNodeIdentity {
private static final long serialVersionUID = 1L;
@ -63,6 +63,7 @@ public class RundeckNode implements Serializable {
/** URL to an external resource model service. (optional) */
private String remoteUrl;
@Override
public String getName() {
return name;
}

View file

@ -0,0 +1,14 @@
package org.rundeck.api.domain;
/**
* Identifies a node by name
*/
public interface RundeckNodeIdentity {
/**
* Return the rundeck Node name
*
* @return
*/
String getName();
}

View file

@ -22,9 +22,9 @@ public class RundeckOutput implements Serializable {
//private String error = null;
private Boolean unmodified;
private Boolean unmodified = false;
private Boolean empty;
private Boolean empty = false;
private int offset;
@ -46,6 +46,9 @@ public class RundeckOutput implements Serializable {
List<RundeckOutputEntry> logEntries = null;
private String filterNode;
private String filterStep;
public Long getExecutionId() {
return executionId;
}
@ -181,6 +184,7 @@ public class RundeckOutput implements Serializable {
", execCompleted=" + execCompleted + ", hasFailedNodes=" + hasFailedNodes +
", status=" + status + ", lastModified=" + lastModified +
", execDuration=" + execDuration + ", percentLoaded=" + percentLoaded +
", filterNode=" + filterNode + ", filterStep=" + filterStep +
", totalSize=" + totalSize + "]";
}
@ -203,6 +207,8 @@ public class RundeckOutput implements Serializable {
result = prime * result + ((percentLoaded == null) ? 0 : percentLoaded.hashCode());
result = prime * result + totalSize;
result = prime * result + ((logEntries == null) ? 0 : logEntries.hashCode());
result = prime * result + ((filterNode == null) ? 0 : filterNode.hashCode());
result = prime * result + ((filterStep == null) ? 0 : filterStep.hashCode());
return result;
}
@ -286,7 +292,40 @@ public class RundeckOutput implements Serializable {
return false;
} else if (!logEntries.equals(other.logEntries))
return false;
if (filterNode == null) {
if (other.filterNode != null)
return false;
} else if (!filterNode.equals(other.filterNode))
return false;
if (filterStep == null) {
if (other.filterStep != null)
return false;
} else if (!filterStep.equals(other.filterStep))
return false;
return true;
}
}
public String getFilterNode() {
return filterNode;
}
/**
* return the node name used to filter this output
* @param filterNode
*/
public void setFilterNode(String filterNode) {
this.filterNode = filterNode;
}
/**
* Return the step context used to filter this output
* @return
*/
public String getFilterStep() {
return filterStep;
}
public void setFilterStep(String filterStep) {
this.filterStep = filterStep;
}
}

View file

@ -1,6 +1,8 @@
package org.rundeck.api.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* Represents a RunDeck output entry
@ -11,7 +13,8 @@ public class RundeckOutputEntry implements Serializable {
private static final long serialVersionUID = 1L;
private String time = null;
private Date absoluteTime = null;
private RundeckLogLevel level = null;
private String message = null;
@ -21,7 +24,9 @@ public class RundeckOutputEntry implements Serializable {
private String command = null;
private String node = null;
private String type = null;
private Map<String,String> metadata;
public String getTime() {
@ -77,8 +82,11 @@ public class RundeckOutputEntry implements Serializable {
@Override
public String toString() {
return "RundeckOutputEntry [time=" + time + ", level=" + level +
", message=" + message + ", user=" + user + ", command=" +
command + ", node=" + node + "]";
", message=" + message + ", user=" + user
+ ", command=" + command
+ ", type=" + type
+ ", metadata=" + metadata
+ ", node=" + node + "]";
}
@Override
@ -91,6 +99,8 @@ public class RundeckOutputEntry implements Serializable {
result = prime * result + ((user == null) ? 0 : user.hashCode());
result = prime * result + ((command == null) ? 0 : command.hashCode());
result = prime * result + ((node == null) ? 0 : node.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
return result;
}
@ -134,13 +144,49 @@ public class RundeckOutputEntry implements Serializable {
return false;
} else if (!node.equals(other.node))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
if (metadata == null) {
if (other.metadata != null)
return false;
} else if (!metadata.equals(other.metadata))
return false;
return true;
}
/**
* type of entry
*/
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, String> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}
public Date getAbsoluteTime() {
return absoluteTime;
}
public void setAbsoluteTime(Date absoluteTime) {
this.absoluteTime = absoluteTime;
}
public static enum RundeckLogLevel {
SEVERE, WARNING, INFO, CONFIG, FINEST;
SEVERE, ERROR, WARNING, INFO, NORMAL, DEBUG, CONFIG, VERBOSE, FINEST,;
}
}
}

View file

@ -0,0 +1,43 @@
package org.rundeck.api.domain;
/**
* An execution state for a workflow or node step
*/
public enum RundeckWFExecState {
/**
* Waiting to start running
*/
WAITING,
/**
* Currently running
*/
RUNNING,
/**
* Running error handler
*/
RUNNING_HANDLER,
/**
* Finished running successfully
*/
SUCCEEDED,
/**
* Finished with a failure
*/
FAILED,
/**
* Execution was aborted
*/
ABORTED,
/**
* Partial success for some nodes
*/
NODE_PARTIAL_SUCCEEDED,
/**
* Mixed states among nodes
*/
NODE_MIXED,
/**
* After waiting the execution did not start
*/
NOT_STARTED,;
}

View file

@ -0,0 +1,52 @@
package org.rundeck.api.domain;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Represents the state of a workflow of steps
*/
public class WorkflowState extends BaseState {
private int stepCount;
private Set<RundeckNodeIdentity> targetNodes;
private List<WorkflowStepState> steps;
/**
* Return the number of steps in this workflow
* @return
*/
public int getStepCount() {
return stepCount;
}
public void setStepCount(int stepCount) {
this.stepCount = stepCount;
}
/**
* Identify the target nodes of this workflow
* @return
*/
public Set<RundeckNodeIdentity> getTargetNodes() {
return targetNodes;
}
public void setTargetNodes(Set<RundeckNodeIdentity> targetNodes) {
this.targetNodes = targetNodes;
}
/**
* Return the list of steps for this workflow
* @return
*/
public List<WorkflowStepState> getSteps() {
return steps;
}
public void setSteps(List<WorkflowStepState> steps) {
this.steps = steps;
}
}

View file

@ -0,0 +1,33 @@
package org.rundeck.api.domain;
/**
* A state for a particular step
*/
public class WorkflowStepContextState extends BaseState {
private String stepContextId;
private int stepNum;
/**
* The context id for the step in the form "#[/#[/#[...]]]" where "#" is a number
* @return
*/
public String getStepContextId() {
return stepContextId;
}
public void setStepContextId(String stepContextId) {
this.stepContextId = stepContextId;
}
/**
* The step number of this step in the current workflow, 1 indexed.
* @return
*/
public int getStepNum() {
return stepNum;
}
public void setStepNum(int stepNum) {
this.stepNum = stepNum;
}
}

View file

@ -0,0 +1,49 @@
package org.rundeck.api.domain;
import java.util.List;
import java.util.Map;
/**
* Represents the state of a step in a workflow
*/
public class WorkflowStepState extends WorkflowStepContextState {
private boolean nodeStep;
private WorkflowState subWorkflow;
private Map<String, WorkflowStepContextState> nodeStates;
/**
* Return true if this step runs on each target node
* @return
*/
public boolean isNodeStep() {
return nodeStep;
}
public void setNodeStep(boolean nodeStep) {
this.nodeStep = nodeStep;
}
/**
* Return sub workflow if this step has one
* @return
*/
public WorkflowState getSubWorkflow() {
return subWorkflow;
}
public void setSubWorkflow(WorkflowState subWorkflow) {
this.subWorkflow = subWorkflow;
}
/**
* Return the state of each target node if this step runs on each target node
* @return
*/
public Map<String, WorkflowStepContextState> getNodeStates() {
return nodeStates;
}
public void setNodeStates(Map<String, WorkflowStepContextState> nodeStates) {
this.nodeStates = nodeStates;
}
}

View file

@ -0,0 +1,42 @@
package org.rundeck.api.parser;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.BaseState;
import org.rundeck.api.domain.RundeckWFExecState;
/**
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:19 PM
*/
public class BaseStateParser implements XmlNodeParser<BaseState> {
public static void parseBaseState(Node targetNode, BaseState state) {
state.setEndTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("endTime"))));
state.setStartTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("startTime"))));
state.setUpdateTime(WorkflowStateParser.parseDate(StringUtils.trimToNull(targetNode.valueOf("updateTime"))));
try {
state.setExecutionState(RundeckWFExecState.valueOf(StringUtils.upperCase(targetNode.valueOf
("executionState"))));
} catch (IllegalArgumentException e) {
state.setExecutionState(null);
}
}
private String xpath;
public BaseStateParser() {
}
public BaseStateParser(String xpath) {
this.xpath = xpath;
}
@Override
public BaseState parseXmlNode(Node node) {
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
BaseState baseState = new BaseState();
parseBaseState(targetNode, baseState);
return baseState;
}
}

View file

@ -15,12 +15,18 @@
*/
package org.rundeck.api.parser;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.RundeckExecution;
import org.rundeck.api.domain.RundeckJob;
import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
import org.rundeck.api.domain.RundeckNode;
import org.rundeck.api.domain.RundeckNodeIdentity;
/**
* Parser for a single {@link RundeckExecution}
@ -76,6 +82,26 @@ public class ExecutionParser implements XmlNodeParser<RundeckExecution> {
execution.setJob(job);
}
final Node successfulNodes = execNode.selectSingleNode("successfulNodes");
if (successfulNodes != null) {
final List<RundeckNode> rundeckNodes =
new ListParser<RundeckNode>(new NodeParser(), "successfulNodes/node")
.parseXmlNode(execNode);
execution.setSuccessfulNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
}else{
execution.setSuccessfulNodes(Collections.<RundeckNodeIdentity>emptySet());
}
final Node failedNodes = execNode.selectSingleNode("failedNodes");
if (failedNodes != null) {
final List<RundeckNode> rundeckNodes =
new ListParser<RundeckNode>(new NodeParser(), "failedNodes/node")
.parseXmlNode(execNode);
execution.setFailedNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
} else {
execution.setFailedNodes(Collections.<RundeckNodeIdentity>emptySet());
}
return execution;
}

View file

@ -0,0 +1,60 @@
package org.rundeck.api.parser;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:42 PM
*/
public class ExecutionStateParser implements XmlNodeParser<RundeckExecutionState> {
private String xpath;
public ExecutionStateParser() {
super();
}
/**
* @param xpath of the execution element if it is not the root node
*/
public ExecutionStateParser(String xpath) {
this();
this.xpath = xpath;
}
@Override
public RundeckExecutionState parseXmlNode(Node node) {
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
RundeckExecutionState rundeckExecutionState = new RundeckExecutionState();
rundeckExecutionState.setExecutionId(Long.valueOf(targetNode.valueOf("@id")));
WorkflowStateParser.parseWorkflowState(targetNode, rundeckExecutionState);
final List<RundeckNode> rundeckNodes =
new ListParser<RundeckNode>(new NodeParser(), "allNodes/nodes/node").parseXmlNode(targetNode);
rundeckExecutionState.setAllNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
//node states
HashMap<String, List<WorkflowStepContextState>> nodeStates = new HashMap<String, List<WorkflowStepContextState>>();
for (Object o : targetNode.selectNodes("nodes/node")) {
final Node nodeStateNode = (Node) o;
final String nodeName = StringUtils.trimToNull(nodeStateNode.valueOf("@name"));
if (null != nodeName) {
ListParser<WorkflowStepContextState> workflowStepStateListParser
= new ListParser<WorkflowStepContextState>(new IndexedWorkflowStepStateParser(rundeckExecutionState, nodeName)
, "steps/step");
nodeStates.put(nodeName, workflowStepStateListParser.parseXmlNode(nodeStateNode));
}
}
rundeckExecutionState.setNodeStates(nodeStates);
return rundeckExecutionState;
}
}

View file

@ -0,0 +1,61 @@
package org.rundeck.api.parser;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.WorkflowState;
import org.rundeck.api.domain.WorkflowStepContextState;
import org.rundeck.api.domain.WorkflowStepState;
/**
* Returns a WorkflowStepContextState by looking up the given Rundeck node's state in the workflow, using the step
* context path of the "stepctx" element of the selected DOM node.
*/
public class IndexedWorkflowStepStateParser implements XmlNodeParser<WorkflowStepContextState> {
private final WorkflowState workflowState;
private String rundeckNodeName;
@Override
public WorkflowStepContextState parseXmlNode(final Node node) {
//look for workflow step state based on node name and stepctx found on the node
final String stepctx = StringUtils.trimToNull(node.valueOf("stepctx"));
final WorkflowStepState foundStep = lookupContext(stepctx, workflowState);
//look up node state for this node
if (null != foundStep
&& null != foundStep.getNodeStates()
&& null != foundStep.getNodeStates().get(rundeckNodeName)) {
return foundStep.getNodeStates().get(rundeckNodeName);
}
return null;
}
/**
* look up the workflow step state for the step context, from the root workflow
*
* @param stepctx
* @param initial
*
* @return
*/
public static WorkflowStepState lookupContext(final String stepctx, final WorkflowState initial) {
final String[] parts = stepctx.split("/");
//descend workflow steps to find correct step
WorkflowState current = initial;
WorkflowStepState currentStep = null;
for (int i = 0; i < parts.length; i++) {
final String part = parts[i];
final WorkflowStepState workflowStepState = current.getSteps().get(Integer.parseInt(part) - 1);
currentStep = workflowStepState;
if (i < parts.length - 1) {
current = currentStep.getSubWorkflow();
}
}
return currentStep;
}
public IndexedWorkflowStepStateParser(final WorkflowState workflowState, final String rundeckNodeName) {
this.workflowState = workflowState;
this.rundeckNodeName = rundeckNodeName;
}
}

View file

@ -6,6 +6,10 @@ import org.dom4j.Node;
import org.rundeck.api.domain.RundeckOutputEntry;
import org.rundeck.api.domain.RundeckOutputEntry.RundeckLogLevel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Parses output message content for API v6
*/
@ -16,15 +20,28 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
public OutputEntryParser() {
super();
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
}
private SimpleDateFormat dateFormat;
/**
* @param xpath of the event element if it is not the root node
*/
public OutputEntryParser(String xpath) {
super();
this();
this.xpath = xpath;
}
static HashSet<String> nonMetaAttributes = new HashSet<String>();
static {
nonMetaAttributes.add("time");
nonMetaAttributes.add("level");
nonMetaAttributes.add("user");
nonMetaAttributes.add("node");
nonMetaAttributes.add("type");
nonMetaAttributes.add("log");
nonMetaAttributes.add("absolute_type");
}
@Override
public RundeckOutputEntry parseXmlNode(Node node) {
@ -38,15 +55,44 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
} catch (IllegalArgumentException e) {
outputEntry.setLevel(null);
}
if(null!=entryNode.valueOf("@absolute_time")) {
outputEntry.setAbsoluteTime(parseDate(StringUtils.trimToNull(entryNode.valueOf("@absolute_time"))));
}
outputEntry.setUser(StringUtils.trimToNull(entryNode.valueOf("@user")));
outputEntry.setCommand(StringUtils.trimToNull(entryNode.valueOf("@command")));
outputEntry.setNode(StringUtils.trimToNull(entryNode.valueOf("@node")));
outputEntry.setType(StringUtils.trimToNull(entryNode.valueOf("@type")));
HashMap<String, String> meta = new HashMap<String, String>();
List list = entryNode.selectNodes("@*");
for (Object node1 : list) {
if(node1 instanceof Node) {
Node child = (Node) node1;
if (!nonMetaAttributes.contains(child.getName())) {
meta.put(child.getName(), child.getText());
}
}
}
if(meta.size()>0){
outputEntry.setMetadata(meta);
}
outputEntry.setMessage(parseMessage(entryNode));
return outputEntry;
}
private Date parseDate(String s) {
if(null==s){
return null;
}
try {
Date parse = dateFormat.parse(s);
return parse;
} catch (ParseException e) {
return null;
}
}
/**
* Parse the message content
*/
@ -54,4 +100,4 @@ public class OutputEntryParser implements XmlNodeParser<RundeckOutputEntry> {
return StringUtils.trimToNull(entryNode.valueOf("@log"));
}
}
}

View file

@ -47,6 +47,7 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
output.setCompleted(Boolean.valueOf(entryNode.valueOf("completed")));
output.setExecCompleted(Boolean.valueOf(entryNode.valueOf("execCompleted")));
output.setHasFailedNodes(Boolean.valueOf(entryNode.valueOf("hasFailedNodes")));
output.setUnmodified(Boolean.valueOf(entryNode.valueOf("unmodified")));
try {
output.setStatus(RundeckExecution.ExecutionStatus
@ -78,6 +79,10 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
} catch (NumberFormatException e) {
output.setTotalSize(-1);
}
if(entryNode.selectSingleNode("filter")!=null){
output.setFilterNode(StringUtils.trimToNull(entryNode.valueOf("filter/@nodename")));
output.setFilterStep(StringUtils.trimToNull(entryNode.valueOf("filter/@stepctx")));
}
Node entriesListNode = entryNode.selectSingleNode("entries");
@ -93,4 +98,4 @@ public class OutputParser implements XmlNodeParser<RundeckOutput> {
return output;
}
}
}

View file

@ -0,0 +1,83 @@
package org.rundeck.api.parser;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:44 PM
*/
public class WorkflowStateParser implements XmlNodeParser<WorkflowState> {
private String xpath;
public WorkflowStateParser() {
}
public WorkflowStateParser(String xpath) {
this();
this.xpath = xpath;
}
private static final ThreadLocal<DateFormat> w3cDateFormat = new ThreadLocal<DateFormat>() {
protected DateFormat initialValue() {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
return fmt;
}
};
public static Date parseDate(String s) {
if (null == s) {
return null;
}
try {
Date parse = w3cDateFormat.get().parse(s);
return parse;
} catch (ParseException e) {
return null;
}
}
private static int integerValue(final String value, final int defValue) {
int parseMax = defValue;
try {
parseMax = null != value ? Integer.parseInt(value) : defValue;
} catch (NumberFormatException e) {
}
return parseMax;
}
@Override
public WorkflowState parseXmlNode(Node node) {
Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
WorkflowState state = new WorkflowState();
parseWorkflowState(targetNode, state);
return state;
}
/**
* Parse the workflow state components from the given dom node
* @param targetNode
* @param state
*/
public static void parseWorkflowState(Node targetNode, WorkflowState state) {
BaseStateParser.parseBaseState(targetNode, state);
state.setStepCount(integerValue(StringUtils.trimToNull(targetNode.valueOf("stepCount")), 0));
final List<RundeckNode> rundeckNodes =
new ListParser<RundeckNode>(new NodeParser(), "targetNodes/nodes/node").parseXmlNode(targetNode);
state.setTargetNodes(new HashSet<RundeckNodeIdentity>(rundeckNodes));
//steps
state.setSteps(new ListParser<WorkflowStepState>(new WorkflowStepStateParser(),
"steps/step").parseXmlNode(targetNode));
}
}

View file

@ -0,0 +1,27 @@
package org.rundeck.api.parser;
import org.dom4j.Node;
import org.rundeck.api.domain.WorkflowStepContextState;
import org.rundeck.api.domain.WorkflowStepState;
/**
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:39 PM
*/
public class WorkflowStepContextStateParser implements XmlNodeParser<WorkflowStepContextState> {
WorkflowStepContextState inherit;
public WorkflowStepContextStateParser(WorkflowStepContextState inherit) {
this.inherit = inherit;
}
@Override
public WorkflowStepContextState parseXmlNode(Node node) {
WorkflowStepContextState workflowStepState = new WorkflowStepContextState();
if(null!=inherit) {
workflowStepState.setStepNum(inherit.getStepNum());
workflowStepState.setStepContextId(inherit.getStepContextId());
}
BaseStateParser.parseBaseState(node, workflowStepState);
return workflowStepState;
}
}

View file

@ -0,0 +1,51 @@
package org.rundeck.api.parser;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Node;
import org.rundeck.api.domain.BaseState;
import org.rundeck.api.domain.WorkflowStepContextState;
import org.rundeck.api.domain.WorkflowStepState;
import java.util.HashMap;
/**
* $INTERFACE is ... User: greg Date: 1/17/14 Time: 12:09 PM
*/
public class WorkflowStepStateParser implements XmlNodeParser<WorkflowStepState> {
private String xpath;
public WorkflowStepStateParser(final String xpath) {
this.xpath = xpath;
}
public WorkflowStepStateParser() {
}
@Override
public WorkflowStepState parseXmlNode(final Node node) {
final Node targetNode = xpath != null ? node.selectSingleNode(xpath) : node;
final WorkflowStepState state = new WorkflowStepState();
BaseStateParser.parseBaseState(targetNode, state);
state.setStepContextId(StringUtils.trimToNull(targetNode.valueOf("@stepctx")));
state.setStepNum(Integer.valueOf(targetNode.valueOf("@id")));
state.setNodeStep(Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("nodeStep"))));
if (Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("hasSubworkflow")))) {
//parse sub workflow
state.setSubWorkflow(new WorkflowStateParser("workflow").parseXmlNode(targetNode));
}
if (Boolean.valueOf(StringUtils.trimToNull(targetNode.valueOf("nodeStep")))) {
//node states
final HashMap<String, WorkflowStepContextState> nodeStates = new HashMap<String, WorkflowStepContextState>();
for (final Object o : targetNode.selectNodes("nodeStates/nodeState")) {
final Node nodeStateNode = (Node) o;
final String nodeName = StringUtils.trimToNull(nodeStateNode.valueOf("@name"));
if (null != nodeName) {
nodeStates.put(nodeName, new WorkflowStepContextStateParser(state).parseXmlNode(nodeStateNode));
}
}
state.setNodeStates(nodeStates);
}
return state;
}
}

View file

@ -83,3 +83,13 @@ h2. RunDeck API version 9
* list running executions across all projects - OK
* include project name in execution results - OK
* Add uuidOption parameter to allow removing imported UUIDs to avoid creation conflicts - OK
h2. RunDeck API version 10
[Documentation of the RunDeck API version 10|http://rundeck.org/2.0.0/api/index.html]
* Execution State - Retrieve workflow step and node state information - OK
* Execution Output with State - Retrieve log output with state change information - OK
* Execution Output - Retrieve log output for a particular node or step - OK
* Execution Info - added successfulNodes and failedNodes detail. - OK
* Deprecation: Remove methods deprecated until version 10. - OK

View file

@ -364,22 +364,7 @@ public class RundeckClientTest {
Assert.assertNull(delete.getMessage());
Assert.assertEquals("3a6d16be-4268-4d26-86a9-cebc1781f768", delete.getId());
}
@Test
@Betamax(tape = "trigger_job_basic")
public void triggerJobDeprecatedBasic() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test
= client.triggerJob("3170ba0e-6093-4b58-94d2-52988aefbfc9", null, null, null);
Assert.assertEquals((Long) 19L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("echo hi there ${job.username} ; sleep 90", test.getDescription());
Assert.assertEquals("admin", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_job_basic")
public void triggerJobBasic() throws Exception {
@ -396,22 +381,7 @@ public class RundeckClientTest {
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_job_as_user")
public void triggerJobDeprecatedAsUser() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test
= client.triggerJob("3170ba0e-6093-4b58-94d2-52988aefbfc9", null, null, "api-java-client-user-test1");
Assert.assertEquals((Long) 20L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("echo hi there ${job.username} ; sleep 90", test.getDescription());
Assert.assertEquals("api-java-client-user-test1", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_job_as_user")
public void triggerJobAsUser() throws Exception {
@ -431,19 +401,7 @@ public class RundeckClientTest {
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_job_as_user_unauthorized")
public void triggerJobDeprecatedAsUserUnauthorized() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test;
try {
test = client.triggerJob("3170ba0e-6093-4b58-94d2-52988aefbfc9",null,null,"api-java-client-user-test2");
Assert.fail("should not succeed");
} catch (RundeckApiException e) {
Assert.assertEquals("Not authorized for action \"Run as User\" for Job ID 3170ba0e-6093-4b58-94d2-52988aefbfc9", e.getMessage());
}
}
@Test
@Betamax(tape = "trigger_job_as_user_unauthorized")
public void triggerJobAsUserUnauthorized() throws Exception {
@ -461,21 +419,7 @@ public class RundeckClientTest {
}
}
@Test
@Betamax(tape = "trigger_adhoc_command")
public void triggerAdhocCommandDeprecated() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test
= client.triggerAdhocCommand("test", "echo test trigger_adhoc_command");
Assert.assertEquals((Long) 23L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("echo test trigger_adhoc_command", test.getDescription());
Assert.assertEquals("admin", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_command")
@ -496,21 +440,7 @@ public class RundeckClientTest {
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_command_as_user")
public void triggerAdhocCommandDeprecatedAsUser() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test
= client.triggerAdhocCommand("test", "echo test trigger_adhoc_command_as_user",null,null,null,"api-java-client-test-run-command-as-user1");
Assert.assertEquals((Long) 24L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("echo test trigger_adhoc_command_as_user", test.getDescription());
Assert.assertEquals("api-java-client-test-run-command-as-user1", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_command_as_user")
public void triggerAdhocCommandAsUser() throws Exception {
@ -532,19 +462,7 @@ public class RundeckClientTest {
Assert.assertEquals("api-java-client-test-run-command-as-user1", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_command_as_user_unauthorized")
public void triggerAdhocCommandDeprecatedAsUserUnauthorized() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
final RundeckExecution test;
try {
test = client.triggerAdhocCommand("test", "echo test trigger_adhoc_command_as_user",null,null,null,"api-java-client-test-run-command-as-user1");
Assert.fail("should not succeed");
} catch (RundeckApiException e) {
Assert.assertEquals("Not authorized for action \"Run as User\" for Run Adhoc", e.getMessage());
}
}
@Test
@Betamax(tape = "trigger_adhoc_command_as_user_unauthorized")
public void triggerAdhocCommandAsUserUnauthorized() throws Exception {
@ -565,24 +483,7 @@ public class RundeckClientTest {
}
}
@Test
@Betamax(tape = "trigger_adhoc_script")
public void triggerAdhocScriptDeprecated() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
String script = "#!/bin/bash\n" +
"echo test trigger_adhoc_script\n";
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(script.getBytes());
final RundeckExecution test
= client.triggerAdhocScript("test", byteArrayInputStream,(Properties) null, null, null, null, null);
Assert.assertEquals((Long) 25L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("#!/bin/bash\necho test trigger_adhoc_script", test.getDescription());
Assert.assertEquals("admin", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_script")
public void triggerAdhocScript() throws Exception {
@ -602,24 +503,7 @@ public class RundeckClientTest {
Assert.assertEquals("admin", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_script_as_user")
public void triggerAdhocScriptDeprecatedAsUser() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
String script = "#!/bin/bash\n" +
"echo test trigger_adhoc_script\n";
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(script.getBytes());
final RundeckExecution test
= client.triggerAdhocScript("test", byteArrayInputStream, (Properties) null, null, null, null, "api-java-client-test-adhoc-script-as-user1");
Assert.assertEquals((Long) 26L, test.getId());
Assert.assertEquals(null, test.getArgstring());
Assert.assertEquals(null, test.getAbortedBy());
Assert.assertEquals("#!/bin/bash\necho test trigger_adhoc_script", test.getDescription());
Assert.assertEquals("api-java-client-test-adhoc-script-as-user1", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_script_as_user")
public void triggerAdhocScriptAsUser() throws Exception {
@ -639,23 +523,7 @@ public class RundeckClientTest {
Assert.assertEquals("api-java-client-test-adhoc-script-as-user1", test.getStartedBy());
Assert.assertEquals(RundeckExecution.ExecutionStatus.RUNNING, test.getStatus());
}
@Test
@Betamax(tape = "trigger_adhoc_script_as_user_unauthorized")
public void triggerAdhocScriptDeprecatedAsUserUnauthorized() throws Exception {
RundeckClient client = createClient(TEST_TOKEN_3, 5);
String script = "#!/bin/bash\n" +
"echo test trigger_adhoc_script\n";
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(script.getBytes());
try{
final RundeckExecution test
= client.triggerAdhocScript("test", byteArrayInputStream, (Properties) null, null, null, null, "api-java-client-test-adhoc-script-as-user1");
Assert.fail("should not succeed");
} catch (RundeckApiException e) {
Assert.assertEquals("Not authorized for action \"Run as User\" for Run Adhoc", e.getMessage());
}
}
@Test
@Betamax(tape = "trigger_adhoc_script_as_user_unauthorized")
public void triggerAdhocScriptAsUserUnauthorized() throws Exception {
@ -1034,6 +902,175 @@ public class RundeckClientTest {
RundeckExecution exec2 = runningExecutions.get(1);
Assert.assertEquals("test2", exec2.getProject());
}
/**
* Execution output
*/
@Test
@Betamax(tape = "execution_output_basic", mode = TapeMode.READ_ONLY)
public void executionOutputBasic() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getJobExecutionOutput(146L,0,0L,-1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(3, output.getLogEntries().size());
}
/**
* Execution output for a node
*/
@Test
@Betamax(tape = "execution_output_fornode", mode = TapeMode.READ_ONLY)
public void executionOutputForNode() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getExecutionOutputForNode(146L, "node-14.qa.subgroup.mycompany.com", 0, -1, 0L, -1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals("node-14.qa.subgroup.mycompany.com", output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(1, output.getLogEntries().size());
}
/**
* Execution output for a step
*/
@Test
@Betamax(tape = "execution_output_forstep", mode = TapeMode.READ_ONLY)
public void executionOutputForStep() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getExecutionOutputForStep(146L, "1", 0, -1, 0L, -1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals("1", output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(3, output.getLogEntries().size());
}
/**
* Execution output for a node and step
*/
@Test
@Betamax(tape = "execution_output_fornodeandstep", mode = TapeMode.READ_ONLY)
public void executionOutputForNodeAndStep() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getExecutionOutputForNodeAndStep(146L, "node-14.qa.subgroup.mycompany.com",
"1", 0, -1, 0L, -1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals("node-14.qa.subgroup.mycompany.com", output.getFilterNode());
Assert.assertEquals("1", output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(1, output.getLogEntries().size());
}
/**
* Execution output state sequence
*/
@Test
@Betamax(tape = "execution_output_state", mode = TapeMode.READ_ONLY)
public void executionOutputState() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getExecutionOutputState(146L, false, 0, 0L, -1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(15, output.getLogEntries().size());
}
/**
* Execution output state sequence
*/
@Test
@Betamax(tape = "execution_output_state_only", mode = TapeMode.READ_ONLY)
public void executionOutputStateOnly() throws Exception {
final RundeckClient client = createClient(TEST_TOKEN_6, 10);
RundeckOutput output = client.getExecutionOutputState(146L, true, 0, 0L, -1);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.57597), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
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 {

View file

@ -0,0 +1,40 @@
package org.rundeck.api.parser;
import junit.framework.Assert;
import org.dom4j.Document;
import org.junit.Test;
import org.rundeck.api.domain.BaseState;
import org.rundeck.api.domain.RundeckWFExecState;
import java.io.InputStream;
import java.util.Date;
/**
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 8:33 AM
*/
public class BaseStateParserTest {
@Test
public void testBase1(){
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
Document document = ParserHelper.loadDocument(input);
BaseState baseState = new BaseState();
BaseStateParser.parseBaseState(document.selectSingleNode("/result/executionState"), baseState);
Assert.assertEquals(1390066160000L, baseState.getEndTime().getTime());
Assert.assertEquals(1390066159000L, baseState.getStartTime().getTime());
Assert.assertEquals(1390066160000L, baseState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, baseState.getExecutionState());
}
@Test
public void testBase2(){
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
Document document = ParserHelper.loadDocument(input);
BaseState baseState = new BaseState();
BaseStateParser.parseBaseState(document.selectSingleNode("/result/executionState/steps/step[1]"), baseState);
Assert.assertEquals(1390066159000L, baseState.getStartTime().getTime());
Assert.assertEquals(1390066160000L, baseState.getEndTime().getTime());
Assert.assertEquals(1390066160000L, baseState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, baseState.getExecutionState());
}
}

View file

@ -16,13 +16,17 @@
package org.rundeck.api.parser;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import org.dom4j.Document;
import org.junit.Assert;
import org.junit.Test;
import org.rundeck.api.domain.RundeckExecution;
import org.rundeck.api.domain.RundeckJob;
import org.rundeck.api.domain.RundeckExecution.ExecutionStatus;
import org.rundeck.api.domain.RundeckNodeIdentity;
/**
* Test the {@link ExecutionParser}
@ -156,4 +160,47 @@ public class ExecutionParserTest {
}
@Test
public void parseV10Execution() throws Exception {
InputStream input = getClass().getResourceAsStream("execution-result-v10.xml");
Document document = ParserHelper.loadDocument(input);
RundeckExecution execution = new ExecutionParser("result/executions/execution").parseXmlNode(document);
RundeckJob job = execution.getJob();
Assert.assertNotNull(job);
Assert.assertEquals(new Long(146), execution.getId());
Assert.assertEquals("http://dignan.local:4440/execution/follow/146", execution.getUrl());
Assert.assertEquals(ExecutionStatus.SUCCEEDED, execution.getStatus());
Assert.assertEquals("admin", execution.getStartedBy());
Assert.assertEquals(new Date(1389894502959L), execution.getStartedAt());
Assert.assertEquals(new Date(1389894504561L), execution.getEndedAt());
Assert.assertEquals((Long)(1389894504561L- 1389894502959L), execution.getDurationInMillis());
Assert.assertEquals(null, execution.getAbortedBy());
Assert.assertEquals("fdfd", execution.getProject());
Assert.assertNotNull(execution.getSuccessfulNodes());
Assert.assertEquals(3, execution.getSuccessfulNodes().size());
HashSet<String> expectedSuccess = new HashSet<String>();
expectedSuccess.addAll(Arrays.asList(
"node-111.qa.subgroup.mycompany.com",
"node-6.qa.subgroup.mycompany.com",
"node-14.qa.subgroup.mycompany.com"));
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getSuccessfulNodes()) {
Assert.assertTrue(expectedSuccess.contains(rundeckNodeIdentity.getName()));
}
Assert.assertNotNull(execution.getFailedNodes());
Assert.assertEquals(3, execution.getFailedNodes().size());
HashSet<String> expectedFailure = new HashSet<String>();
expectedFailure.addAll(Arrays.asList(
"node-112.qa.subgroup.mycompany.com",
"node-62.qa.subgroup.mycompany.com",
"node-12.qa.subgroup.mycompany.com"));
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getFailedNodes()) {
Assert.assertTrue(expectedFailure.contains(rundeckNodeIdentity.getName()));
}
}
}

View file

@ -0,0 +1,43 @@
package org.rundeck.api.parser;
import junit.framework.Assert;
import org.dom4j.Document;
import org.junit.Test;
import org.rundeck.api.domain.RundeckExecutionState;
import org.rundeck.api.domain.RundeckNodeIdentity;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:42 PM
*/
public class ExecutionStateParserTest {
@Test
public void testBasic(){
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
Document document = ParserHelper.loadDocument(input);
RundeckExecutionState execution = new ExecutionStateParser("/result/executionState").parseXmlNode
(document);
Assert.assertEquals(149L, execution.getExecutionId());
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
"node-111.qa.subgroup.mycompany.com",
"node-14.qa.subgroup.mycompany.com",
"node-6.qa.subgroup.mycompany.com"
));
Assert.assertEquals(3, execution.getAllNodes().size());
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getAllNodes()) {
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
}
Assert.assertEquals(3,execution.getNodeStates().size());
for (String s : execution.getNodeStates().keySet()) {
Assert.assertTrue(expectedTargetNodes.contains(s));
}
}
}

View file

@ -0,0 +1,73 @@
package org.rundeck.api.parser;
import junit.framework.Assert;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.junit.Test;
import org.rundeck.api.domain.WorkflowState;
import org.rundeck.api.domain.WorkflowStepContextState;
import org.rundeck.api.domain.WorkflowStepState;
import java.util.Arrays;
import java.util.HashMap;
/**
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 9:57 AM
*/
public class IndexedWorkflowStepStateParserTest {
@Test
public void testLookupContextSimple1(){
WorkflowState workflowState = new WorkflowState();
WorkflowStepState step1 = new WorkflowStepState();
workflowState.setSteps(Arrays.asList(step1));
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("1", workflowState);
Assert.assertEquals(step1,stepState);
}
@Test
public void testLookupContextSimple2(){
WorkflowState workflowState = new WorkflowState();
WorkflowStepState step1 = new WorkflowStepState();
WorkflowStepState step2 = new WorkflowStepState();
workflowState.setSteps(Arrays.asList(step1,step2));
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("2", workflowState);
Assert.assertEquals(step2,stepState);
}
@Test
public void testLookupContextDescend1(){
WorkflowState workflowState = new WorkflowState();
WorkflowStepState step1 = new WorkflowStepState();
WorkflowStepState step2 = new WorkflowStepState();
WorkflowState sub1 = new WorkflowState();
step2.setSubWorkflow(sub1);
workflowState.setSteps(Arrays.asList(step1,step2));
WorkflowStepState step21 = new WorkflowStepState();
sub1.setSteps(Arrays.asList(step21));
WorkflowStepState stepState = IndexedWorkflowStepStateParser.lookupContext("2/1", workflowState);
Assert.assertEquals(step21,stepState);
}
@Test
public void testParse1() throws DocumentException {
WorkflowState workflowState = new WorkflowState();
WorkflowStepState step1 = new WorkflowStepState();
WorkflowStepState step2 = new WorkflowStepState();
WorkflowState sub1 = new WorkflowState();
step2.setSubWorkflow(sub1);
workflowState.setSteps(Arrays.asList(step1,step2));
WorkflowStepState step21 = new WorkflowStepState();
sub1.setSteps(Arrays.asList(step21));
HashMap<String, WorkflowStepContextState> nodeStates = new HashMap<String, WorkflowStepContextState>();
WorkflowStepContextState nodeState1 = new WorkflowStepContextState();
nodeStates.put("dignan", nodeState1);
step21.setNodeStates(nodeStates);
Document document = DocumentHelper.parseText("<stepctx>2/1</stepctx>");
WorkflowStepContextState result = new IndexedWorkflowStepStateParser(workflowState,"dignan").parseXmlNode(document);
Assert.assertEquals(nodeState1,result);
}
}

View file

@ -0,0 +1,55 @@
package org.rundeck.api.parser;
import org.dom4j.Document;
import org.junit.Assert;
import org.junit.Test;
import org.rundeck.api.domain.RundeckOutputEntry;
import java.io.InputStream;
import java.util.Date;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 4:35 PM
*/
public class OutputEntryParserTest {
@Test
public void testEntryBasic() {
InputStream input = getClass().getResourceAsStream("output1.xml");
Document document = ParserHelper.loadDocument(input);
OutputEntryParser outputEntryParser = new OutputEntryParser("//entry[1]");
RundeckOutputEntry rundeckOutputEntry = outputEntryParser.parseXmlNode(document);
Assert.assertEquals("hi there", rundeckOutputEntry.getMessage());
Assert.assertEquals(null, rundeckOutputEntry.getCommand());
Assert.assertEquals(RundeckOutputEntry.RundeckLogLevel.NORMAL, rundeckOutputEntry.getLevel());
Assert.assertEquals("node-111.qa.subgroup.mycompany.com", rundeckOutputEntry.getNode());
Assert.assertEquals("09:48:23", rundeckOutputEntry.getTime());
Assert.assertEquals(new Date(1389894503000L), rundeckOutputEntry.getAbsoluteTime());
Assert.assertEquals(null, rundeckOutputEntry.getType());
Assert.assertEquals("Raif", rundeckOutputEntry.getUser());
Assert.assertNotNull(rundeckOutputEntry.getMetadata());
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("stepctx"));
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("stepctx"));
}
@Test
public void testEntryState() {
InputStream input = getClass().getResourceAsStream("output-state.xml");
Document document = ParserHelper.loadDocument(input);
OutputEntryParser outputEntryParser = new OutputEntryParser("//entry[1]");
RundeckOutputEntry rundeckOutputEntry = outputEntryParser.parseXmlNode(document);
Assert.assertEquals(null, rundeckOutputEntry.getMessage());
Assert.assertEquals(null, rundeckOutputEntry.getCommand());
Assert.assertEquals(RundeckOutputEntry.RundeckLogLevel.NORMAL, rundeckOutputEntry.getLevel());
Assert.assertEquals("dignan", rundeckOutputEntry.getNode());
Assert.assertEquals("09:48:23", rundeckOutputEntry.getTime());
Assert.assertEquals(new Date(1389894503000L), rundeckOutputEntry.getAbsoluteTime());
Assert.assertEquals("stepbegin", rundeckOutputEntry.getType());
Assert.assertEquals("admin", rundeckOutputEntry.getUser());
Assert.assertNotNull(rundeckOutputEntry.getMetadata());
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("stepctx"));
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("stepctx"));
Assert.assertNotNull(rundeckOutputEntry.getMetadata().get("step"));
Assert.assertEquals("1",rundeckOutputEntry.getMetadata().get("step"));
}
}

View file

@ -0,0 +1,85 @@
package org.rundeck.api.parser;
import org.dom4j.Document;
import org.junit.Assert;
import org.junit.Test;
import org.rundeck.api.domain.RundeckExecution;
import org.rundeck.api.domain.RundeckOutput;
import org.rundeck.api.domain.RundeckProject;
import java.io.InputStream;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 4:24 PM
*/
public class OutputParserTest {
@Test
public void parseOutputBasic() throws Exception {
InputStream input = getClass().getResourceAsStream("output1.xml");
Document document = ParserHelper.loadDocument(input);
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.9), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(3, output.getLogEntries().size());
}
@Test
public void parseOutputFiltered() throws Exception {
InputStream input = getClass().getResourceAsStream("output-filtered.xml");
Document document = ParserHelper.loadDocument(input);
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals("node-111.qa.subgroup.mycompany.com", output.getFilterNode());
Assert.assertEquals("1", output.getFilterStep());
Assert.assertEquals(1409, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(new Float(99.9), output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(false, output.isUnmodified());
Assert.assertEquals(1, output.getLogEntries().size());
}
@Test
public void parseOutputUnmodified() throws Exception {
InputStream input = getClass().getResourceAsStream("output-unmodified.xml");
Document document = ParserHelper.loadDocument(input);
RundeckOutput output = new OutputParser("result/output", new OutputEntryParser()).parseXmlNode(document);
Assert.assertEquals(new Long(1602), output.getExecDuration());
Assert.assertEquals(new Long(146), output.getExecutionId());
Assert.assertEquals(new Long(1389894504000L), output.getLastModified());
Assert.assertEquals(null, output.getFilterNode());
Assert.assertEquals(null, output.getFilterStep());
Assert.assertEquals(0, output.getOffset());
Assert.assertEquals(RundeckExecution.ExecutionStatus.SUCCEEDED, output.getStatus());
Assert.assertEquals(null, output.getPercentLoaded());
Assert.assertEquals(1415, output.getTotalSize());
Assert.assertEquals(true, output.isCompleted());
Assert.assertEquals(true, output.isExecCompleted());
Assert.assertEquals(false, output.isEmpty());
Assert.assertEquals(false, output.isHasFailedNodes());
Assert.assertEquals(true, output.isUnmodified());
Assert.assertEquals(null, output.getLogEntries());
}
}

View file

@ -0,0 +1,65 @@
package org.rundeck.api.parser;
import junit.framework.Assert;
import org.dom4j.Document;
import org.junit.Test;
import org.rundeck.api.domain.*;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
/**
* $INTERFACE is ... User: greg Date: 1/16/14 Time: 5:47 PM
*/
public class WorkflowStateParserTest {
@Test
public void parseBasic(){
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
Document document = ParserHelper.loadDocument(input);
WorkflowState execution = new WorkflowStateParser("result/executionState").parseXmlNode(document);
Assert.assertEquals(1390066159000L, execution.getStartTime().getTime());
Assert.assertEquals(1390066160000L, execution.getEndTime().getTime());
Assert.assertEquals(1390066160000L, execution.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, execution.getExecutionState());
Assert.assertEquals(1, execution.getStepCount());
Assert.assertEquals(3, execution.getTargetNodes().size());
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
"node-111.qa.subgroup.mycompany.com",
"node-14.qa.subgroup.mycompany.com",
"node-6.qa.subgroup.mycompany.com"
));
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getTargetNodes()) {
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
}
//
Assert.assertEquals(1,execution.getSteps().size());
WorkflowStepState step1 = execution.getSteps().get(0);
}
@Test
public void parse(){
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
Document document = ParserHelper.loadDocument(input);
WorkflowState execution = new WorkflowStateParser("result/executionState").parseXmlNode(document);
Assert.assertEquals(1390066061000L, execution.getStartTime().getTime());
Assert.assertEquals(null, execution.getEndTime());
Assert.assertEquals(1390066067000L, execution.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.RUNNING, execution.getExecutionState());
Assert.assertEquals(2, execution.getStepCount());
Assert.assertEquals(1, execution.getTargetNodes().size());
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
"dignan"
));
for (RundeckNodeIdentity rundeckNodeIdentity : execution.getTargetNodes()) {
Assert.assertTrue(expectedTargetNodes.contains(rundeckNodeIdentity.getName()));
}
//
Assert.assertEquals(2,execution.getSteps().size());
WorkflowStepState step1 = execution.getSteps().get(0);
}
}

View file

@ -0,0 +1,122 @@
package org.rundeck.api.parser;
import junit.framework.Assert;
import org.dom4j.Document;
import org.junit.Test;
import org.rundeck.api.domain.*;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
/**
* $INTERFACE is ... User: greg Date: 1/18/14 Time: 9:00 AM
*/
public class WorkflowStepStateParserTest {
@Test
public void testParse1() {
InputStream input = getClass().getResourceAsStream("execution-state1.xml");
Document document = ParserHelper.loadDocument(input);
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
("/result/executionState/steps/step[1]"));
Assert.assertNotNull(stepState);
Assert.assertEquals(true, stepState.isNodeStep());
Assert.assertEquals(null, stepState.getSubWorkflow());
Assert.assertNotNull(stepState.getNodeStates());
Assert.assertEquals("1", stepState.getStepContextId());
Assert.assertEquals(1, stepState.getStepNum());
Assert.assertEquals(1390066159000L, stepState.getStartTime().getTime());
Assert.assertEquals(1390066160000L, stepState.getEndTime().getTime());
Assert.assertEquals(1390066160000L, stepState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, stepState.getExecutionState());
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
"node-111.qa.subgroup.mycompany.com",
"node-14.qa.subgroup.mycompany.com",
"node-6.qa.subgroup.mycompany.com"
));
int i = 0;
for (String s : stepState.getNodeStates().keySet()) {
Assert.assertTrue(expectedTargetNodes.contains(s));
WorkflowStepContextState workflowStepContextState = stepState.getNodeStates().get(s);
Assert.assertEquals("1", workflowStepContextState.getStepContextId());
Assert.assertEquals(1, workflowStepContextState.getStepNum());
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getStartTime().getTime());
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getEndTime().getTime());
Assert.assertEquals(1390066159000L + (i * 1000), workflowStepContextState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, workflowStepContextState.getExecutionState());
i++;
}
}
@Test
public void testParseRunning1() {
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
Document document = ParserHelper.loadDocument(input);
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
("/result/executionState/steps/step[1]"));
Assert.assertNotNull(stepState);
Assert.assertEquals(true, stepState.isNodeStep());
Assert.assertEquals(null, stepState.getSubWorkflow());
Assert.assertEquals("1", stepState.getStepContextId());
Assert.assertEquals(1, stepState.getStepNum());
Assert.assertNotNull(stepState.getNodeStates());
Assert.assertEquals(1390066061000L, stepState.getStartTime().getTime());
Assert.assertEquals(1390066066000L, stepState.getEndTime().getTime());
Assert.assertEquals(1390066061000L, stepState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, stepState.getExecutionState());
HashSet<String> expectedTargetNodes = new HashSet<String>(Arrays.asList(
"dignan"
));
WorkflowStepContextState workflowStepContextState = stepState.getNodeStates().get("dignan");
Assert.assertEquals("1", workflowStepContextState.getStepContextId());
Assert.assertEquals(1, workflowStepContextState.getStepNum());
Assert.assertEquals(1390066061000L, workflowStepContextState.getStartTime().getTime());
Assert.assertEquals(1390066066000L, workflowStepContextState.getEndTime().getTime());
Assert.assertEquals(1390066066000L, workflowStepContextState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.SUCCEEDED, workflowStepContextState.getExecutionState());
}
@Test
public void testParseRunning2() {
InputStream input = getClass().getResourceAsStream("execution-state2.xml");
Document document = ParserHelper.loadDocument(input);
WorkflowStepState stepState = new WorkflowStepStateParser().parseXmlNode(document.selectSingleNode
("/result/executionState/steps/step[2]"));
Assert.assertNotNull(stepState);
Assert.assertEquals(false, stepState.isNodeStep());
Assert.assertNotNull(stepState.getSubWorkflow());
Assert.assertNull(stepState.getNodeStates());
Assert.assertEquals("2", stepState.getStepContextId());
Assert.assertEquals(2, stepState.getStepNum());
Assert.assertEquals(1390066066000L, stepState.getStartTime().getTime());
Assert.assertNull(stepState.getEndTime());
Assert.assertEquals(1390066066000L, stepState.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.RUNNING, stepState.getExecutionState());
//sub workflow
WorkflowState subWorkflow = stepState.getSubWorkflow();
Assert.assertEquals(1,subWorkflow.getSteps().size());
Assert.assertEquals(1,subWorkflow.getTargetNodes().size());
WorkflowStepState stepState1 = subWorkflow.getSteps().get(0);
Assert.assertEquals(true, stepState1.isNodeStep());
Assert.assertNull(stepState1.getSubWorkflow());
Assert.assertNotNull(stepState1.getNodeStates());
Assert.assertEquals("2/1", stepState1.getStepContextId());
Assert.assertEquals(1, stepState1.getStepNum());
Assert.assertEquals(1390066067000L, stepState1.getStartTime().getTime());
Assert.assertNull(stepState1.getEndTime());
Assert.assertEquals(1390066067000L, stepState1.getUpdateTime().getTime());
Assert.assertEquals(RundeckWFExecState.RUNNING, stepState1.getExecutionState());
}
}

View file

@ -0,0 +1,24 @@
!tape
name: execution_output_basic
interactions:
- recorded: 2014-01-17T01:12:05.218Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output?offset=0&lastmod=0
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=1lnnniwx8tih2ehakkgipuyra;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <entries>\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z'\
\ log='hi there' level='NORMAL' user='Raif' command='' stepctx='1' node='node-111.qa.subgroup.mycompany.com' />\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com'\
\ />\n <entry time='09:48:24' absolute_time='2014-01-16T17:48:24Z' log='hi there' level='NORMAL' user='Carolyn' command='' stepctx='1' node='node-6.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"

View file

@ -0,0 +1,23 @@
!tape
name: execution_output_fornode
interactions:
- recorded: 2014-01-17T01:07:39.379Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output/node/node-14.qa.subgroup.mycompany.com?offset=0&lastmod=0
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=17y6a48eoxo7w4eqjrnba9xzz;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <filter nodename='node-14.qa.subgroup.mycompany.com' />\n <entries>\n\
\ <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"

View file

@ -0,0 +1,23 @@
!tape
name: execution_output_fornodeandstep
interactions:
- recorded: 2014-01-17T01:21:20.524Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output/node/node-14.qa.subgroup.mycompany.com/step/1?offset=0&lastmod=0
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=1tik7xow5yg5t1avvahzumv6u1;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <filter nodename='node-14.qa.subgroup.mycompany.com' stepctx='1' />\n \
\ <entries>\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"

View file

@ -0,0 +1,24 @@
!tape
name: execution_output_forstep
interactions:
- recorded: 2014-01-17T01:10:44.001Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output/step/1?offset=0&lastmod=0
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=37vkq48ddskqv2f3etipviu8;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <filter stepctx='1' />\n <entries>\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z'\
\ log='hi there' level='NORMAL' user='Raif' command='' stepctx='1' node='node-111.qa.subgroup.mycompany.com' />\n <entry time='09:48:23' absolute_time='2014-01-16T17:48:23Z' log='hi there' level='NORMAL' user='Dale' command='' stepctx='1' node='node-14.qa.subgroup.mycompany.com'\
\ />\n <entry time='09:48:24' absolute_time='2014-01-16T17:48:24Z' log='hi there' level='NORMAL' user='Carolyn' command='' stepctx='1' node='node-6.qa.subgroup.mycompany.com' />\n </entries>\n </output>\n</result>"

View file

@ -0,0 +1,32 @@
!tape
name: execution_output_state
interactions:
- recorded: 2014-01-17T01:32:08.245Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output/state?offset=0&lastmod=0
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=wanbmac3kkhgo3jghy3twd7g;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <entries>\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:23'\
\ level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='node-111.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Raif' time='09:48:23' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:23Z'\
\ log='' />\n <entry node='node-111.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Raif' time='09:48:23' level='NORMAL' type='log' absolute_time='2014-01-16T17:48:23Z' log='hi there' />\n <entry node='node-111.qa.subgroup.mycompany.com'\
\ step='1' stepctx='1' user='Raif' time='09:48:23' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:23' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:23Z'\
\ log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:23' level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='node-14.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Dale'\
\ time='09:48:23' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='node-14.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Dale' time='09:48:23' level='NORMAL' type='log' absolute_time='2014-01-16T17:48:23Z'\
\ log='hi there' />\n <entry node='node-14.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Dale' time='09:48:24' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin'\
\ time='09:48:24' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:24' level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:24Z' log='' />\n\
\ <entry node='node-6.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Carolyn' time='09:48:24' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='node-6.qa.subgroup.mycompany.com' step='1' stepctx='1'\
\ user='Carolyn' time='09:48:24' level='NORMAL' type='log' absolute_time='2014-01-16T17:48:24Z' log='hi there' />\n <entry node='node-6.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Carolyn' time='09:48:24' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:24Z'\
\ log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:24' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:24Z' log='' />\n </entries>\n </output>\n</result>"

View file

@ -0,0 +1,30 @@
!tape
name: execution_output_state_only
interactions:
- recorded: 2014-01-17T01:34:08.528Z
request:
method: GET
uri: http://rundeck.local:4440/api/10/execution/146/output/state?offset=0&lastmod=0&stateOnly=true
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=19nlvjuo85wqz1lwl7biksu77h;Path=/
body: "<result success='true' apiversion='10'>\n <output>\n <id>146</id>\n <offset>1409</offset>\n <completed>true</completed>\n <execCompleted>true</execCompleted>\n <hasFailedNodes>false</hasFailedNodes>\n <execState>succeeded</execState>\n\
\ <lastModified>1389894504000</lastModified>\n <execDuration>1602</execDuration>\n <percentLoaded>99.57597173144876</percentLoaded>\n <totalSize>1415</totalSize>\n <entries>\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:23'\
\ level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='node-111.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Raif' time='09:48:23' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:23Z'\
\ log='' />\n <entry node='node-111.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Raif' time='09:48:23' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin'\
\ time='09:48:23' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:23' level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n\
\ <entry node='node-14.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Dale' time='09:48:23' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:23Z' log='' />\n <entry node='node-14.qa.subgroup.mycompany.com' step='1' stepctx='1'\
\ user='Dale' time='09:48:24' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:24' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:24Z'\
\ log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:24' level='NORMAL' type='stepbegin' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='node-6.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Carolyn'\
\ time='09:48:24' level='NORMAL' type='nodebegin' absolute_time='2014-01-16T17:48:24Z' log='' />\n <entry node='node-6.qa.subgroup.mycompany.com' step='1' stepctx='1' user='Carolyn' time='09:48:24' level='NORMAL' type='nodeend' absolute_time='2014-01-16T17:48:24Z'\
\ log='' />\n <entry node='dignan' step='1' stepctx='1' user='admin' time='09:48:24' level='NORMAL' type='stepend' absolute_time='2014-01-16T17:48:24Z' log='' />\n </entries>\n </output>\n</result>"

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

View file

@ -6,6 +6,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?jobFilter=test+job&project=blah&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -23,6 +24,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&descFilter=a+description&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -38,6 +40,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&begin=2012-09-13T17%3A06%3A18Z&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -53,6 +56,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&end=2012-09-13T17%3A06%3A18Z&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -68,6 +72,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&excludeJobIdListFilter=123&excludeJobIdListFilter=456&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -83,6 +88,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&jobListFilter=fruit%2Fmango&jobListFilter=fruit%2Flemon&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -98,6 +104,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&excludeJobListFilter=a%2Fpath%2Fjob1&excludeJobListFilter=path%2Fto%2Fjob2&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -113,6 +120,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&jobIdListFilter=1f4415d7-3b52-4fc8-ba42-b6ac97508bff&jobIdListFilter=d9fc5ee6-f1db-4d24-8808-feda18345bab&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -128,6 +136,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&groupPath=fruit&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -143,6 +152,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&groupPathExact=fruit&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -158,6 +168,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?jobExactFilter=test+job&project=blah&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -173,6 +184,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&loglevelFilter=INFO&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -188,6 +200,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&recentFilter=1h&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -203,6 +216,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&statusFilter=succeeded&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -218,6 +232,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&adhoc=true&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -235,6 +250,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&abortedbyFilter=admin&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -252,6 +268,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?excludeJobFilter=test+job&project=blah&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -269,6 +286,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?excludeJobExactFilter=test+job&project=blah&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -284,6 +302,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&excludeGroupPath=fruit&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5
@ -301,6 +320,7 @@ interactions:
method: GET
uri: http://rundeck.local:4440/api/5/executions?project=blah&excludeGroupPathExact=fruit&max=2&offset=0
headers:
Accept: text/xml
Host: rundeck.local:4440
Proxy-Connection: Keep-Alive
User-Agent: RunDeck API Java Client 5

View file

@ -0,0 +1,27 @@
<result success="true" apiversion="10">
<executions count="1">
<execution id="146" href="http://dignan.local:4440/execution/follow/146" status="succeeded" project="fdfd">
<user>admin</user>
<date-started unixtime="1389894502959">2014-01-16T17:48:22Z</date-started>
<date-ended unixtime="1389894504561">2014-01-16T17:48:24Z</date-ended>
<job id="4ae33efb-5d37-4237-a33b-ac08eaaadf79" averageDuration="1528">
<name>test 1</name>
<group/>
<project>fdfd</project>
<description/>
</job>
<description>echo hi there</description>
<argstring/>
<successfulNodes>
<node name="node-111.qa.subgroup.mycompany.com"/>
<node name="node-6.qa.subgroup.mycompany.com"/>
<node name="node-14.qa.subgroup.mycompany.com"/>
</successfulNodes>
<failedNodes>
<node name="node-112.qa.subgroup.mycompany.com"/>
<node name="node-62.qa.subgroup.mycompany.com"/>
<node name="node-12.qa.subgroup.mycompany.com"/>
</failedNodes>
</execution>
</executions>
</result>

View file

@ -0,0 +1,81 @@
<result success="true" apiversion="10">
<executionState id="149">
<executionId>149</executionId>
<serverNode>dignan</serverNode>
<executionState>SUCCEEDED</executionState>
<completed>true</completed>
<targetNodes>
<nodes>
<node name="node-111.qa.subgroup.mycompany.com"/>
<node name="node-14.qa.subgroup.mycompany.com"/>
<node name="node-6.qa.subgroup.mycompany.com"/>
</nodes>
</targetNodes>
<allNodes>
<nodes>
<node name="node-111.qa.subgroup.mycompany.com"/>
<node name="node-14.qa.subgroup.mycompany.com"/>
<node name="node-6.qa.subgroup.mycompany.com"/>
</nodes>
</allNodes>
<stepCount>1</stepCount>
<updateTime>2014-01-18T17:29:20Z</updateTime>
<startTime>2014-01-18T17:29:19Z</startTime>
<endTime>2014-01-18T17:29:20Z</endTime>
<steps>
<step stepctx="1" id="1">
<nodeStep>true</nodeStep>
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:29:19Z</startTime>
<updateTime>2014-01-18T17:29:20Z</updateTime>
<endTime>2014-01-18T17:29:20Z</endTime>
<nodeStates>
<nodeState name="node-111.qa.subgroup.mycompany.com">
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:29:19Z</startTime>
<updateTime>2014-01-18T17:29:19Z</updateTime>
<endTime>2014-01-18T17:29:19Z</endTime>
</nodeState>
<nodeState name="node-6.qa.subgroup.mycompany.com">
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:29:20Z</startTime>
<updateTime>2014-01-18T17:29:20Z</updateTime>
<endTime>2014-01-18T17:29:20Z</endTime>
</nodeState>
<nodeState name="node-14.qa.subgroup.mycompany.com">
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:29:21Z</startTime>
<updateTime>2014-01-18T17:29:21Z</updateTime>
<endTime>2014-01-18T17:29:21Z</endTime>
</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>

View file

@ -0,0 +1,96 @@
<result success="true" apiversion="10">
<executionState id="148">
<executionId>148</executionId>
<serverNode>dignan</serverNode>
<executionState>RUNNING</executionState>
<completed>false</completed>
<targetNodes>
<nodes>
<node name="dignan"/>
</nodes>
</targetNodes>
<allNodes>
<nodes>
<node name="dignan"/>
</nodes>
</allNodes>
<stepCount>2</stepCount>
<updateTime>2014-01-18T17:27:47Z</updateTime>
<startTime>2014-01-18T17:27:41Z</startTime>
<endTime/>
<steps>
<step stepctx="1" id="1">
<nodeStep>true</nodeStep>
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:27:41Z</startTime>
<updateTime>2014-01-18T17:27:41Z</updateTime>
<endTime>2014-01-18T17:27:46Z</endTime>
<nodeStates>
<nodeState name="dignan">
<executionState>SUCCEEDED</executionState>
<startTime>2014-01-18T17:27:41Z</startTime>
<updateTime>2014-01-18T17:27:46Z</updateTime>
<endTime>2014-01-18T17:27:46Z</endTime>
</nodeState>
</nodeStates>
</step>
<step stepctx="2" id="2">
<hasSubworkflow>true</hasSubworkflow>
<workflow>
<executionState>RUNNING</executionState>
<completed>false</completed>
<targetNodes>
<nodes>
<node name="dignan"/>
</nodes>
</targetNodes>
<allNodes>
<nodes>
<node name="dignan"/>
</nodes>
</allNodes>
<stepCount>1</stepCount>
<updateTime>2014-01-18T17:27:47Z</updateTime>
<startTime>2014-01-18T17:27:47Z</startTime>
<endTime/>
<steps>
<step stepctx="2/1" id="1">
<nodeStep>true</nodeStep>
<executionState>RUNNING</executionState>
<startTime>2014-01-18T17:27:47Z</startTime>
<updateTime>2014-01-18T17:27:47Z</updateTime>
<endTime/>
<nodeStates>
<nodeState name="dignan">
<executionState>RUNNING</executionState>
<startTime>2014-01-18T17:27:47Z</startTime>
<updateTime>2014-01-18T17:27:47Z</updateTime>
<endTime/>
</nodeState>
</nodeStates>
</step>
</steps>
</workflow>
<nodeStep>false</nodeStep>
<executionState>RUNNING</executionState>
<startTime>2014-01-18T17:27:46Z</startTime>
<updateTime>2014-01-18T17:27:46Z</updateTime>
<endTime/>
</step>
</steps>
<nodes>
<node name="dignan">
<steps>
<step>
<stepctx>1</stepctx>
<executionState>SUCCEEDED</executionState>
</step>
<step>
<stepctx>2/1</stepctx>
<executionState>RUNNING</executionState>
</step>
</steps>
</node>
</nodes>
</executionState>
</result>

View file

@ -0,0 +1,19 @@
<result success="true" apiversion="10">
<output>
<id>146</id>
<offset>1409</offset>
<completed>true</completed>
<execCompleted>true</execCompleted>
<hasFailedNodes>false</hasFailedNodes>
<execState>succeeded</execState>
<lastModified>1389894504000</lastModified>
<execDuration>1602</execDuration>
<percentLoaded>99.9</percentLoaded>
<totalSize>1415</totalSize>
<filter nodename="node-111.qa.subgroup.mycompany.com" stepctx="1"/>
<entries>
<entry time="09:48:23" absolute_time="2014-01-16T17:48:23Z" log="hi there" level="NORMAL" user="Raif"
command="" stepctx="1" node="node-111.qa.subgroup.mycompany.com"/>
</entries>
</output>
</result>

View file

@ -0,0 +1,46 @@
<result success="true" apiversion="10">
<output>
<id>146</id>
<offset>1409</offset>
<completed>true</completed>
<execCompleted>true</execCompleted>
<hasFailedNodes>false</hasFailedNodes>
<execState>succeeded</execState>
<lastModified>1389894504000</lastModified>
<execDuration>1602</execDuration>
<percentLoaded>99.57597173144876</percentLoaded>
<totalSize>1415</totalSize>
<entries>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:23" level="NORMAL" type="stepbegin"
absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="node-111.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Raif" time="09:48:23"
level="NORMAL" type="nodebegin" absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="node-111.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Raif" time="09:48:23"
level="NORMAL" type="log" absolute_time="2014-01-16T17:48:23Z" log="hi there"/>
<entry node="node-111.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Raif" time="09:48:23"
level="NORMAL" type="nodeend" absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:23" level="NORMAL" type="stepend"
absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:23" level="NORMAL" type="stepbegin"
absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="node-14.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Dale" time="09:48:23"
level="NORMAL" type="nodebegin" absolute_time="2014-01-16T17:48:23Z" log=""/>
<entry node="node-14.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Dale" time="09:48:23"
level="NORMAL" type="log" absolute_time="2014-01-16T17:48:23Z" log="hi there"/>
<entry node="node-14.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Dale" time="09:48:24"
level="NORMAL" type="nodeend" absolute_time="2014-01-16T17:48:24Z" log=""/>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:24" level="NORMAL" type="stepend"
absolute_time="2014-01-16T17:48:24Z" log=""/>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:24" level="NORMAL" type="stepbegin"
absolute_time="2014-01-16T17:48:24Z" log=""/>
<entry node="node-6.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Carolyn" time="09:48:24"
level="NORMAL" type="nodebegin" absolute_time="2014-01-16T17:48:24Z" log=""/>
<entry node="node-6.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Carolyn" time="09:48:24"
level="NORMAL" type="log" absolute_time="2014-01-16T17:48:24Z" log="hi there"/>
<entry node="node-6.qa.subgroup.mycompany.com" step="1" stepctx="1" user="Carolyn" time="09:48:24"
level="NORMAL" type="nodeend" absolute_time="2014-01-16T17:48:24Z" log=""/>
<entry node="dignan" step="1" stepctx="1" user="admin" time="09:48:24" level="NORMAL" type="stepend"
absolute_time="2014-01-16T17:48:24Z" log=""/>
</entries>
</output>
</result>

View file

@ -0,0 +1,16 @@
<result success="true" apiversion="10">
<output>
<id>146</id>
<offset>0</offset>
<completed>true</completed>
<unmodified>true</unmodified>
<message>Unmodified</message>
<execCompleted>true</execCompleted>
<hasFailedNodes>false</hasFailedNodes>
<execState>succeeded</execState>
<lastModified>1389894504000</lastModified>
<execDuration>1602</execDuration>
<totalSize>1415</totalSize>
<entries/>
</output>
</result>

View file

@ -0,0 +1,22 @@
<result success="true" apiversion="10">
<output>
<id>146</id>
<offset>1409</offset>
<completed>true</completed>
<execCompleted>true</execCompleted>
<hasFailedNodes>false</hasFailedNodes>
<execState>succeeded</execState>
<lastModified>1389894504000</lastModified>
<execDuration>1602</execDuration>
<percentLoaded>99.9</percentLoaded>
<totalSize>1415</totalSize>
<entries>
<entry time="09:48:23" absolute_time="2014-01-16T17:48:23Z" log="hi there" level="NORMAL" user="Raif"
command="" stepctx="1" node="node-111.qa.subgroup.mycompany.com"/>
<entry time="09:48:23" absolute_time="2014-01-16T17:48:23Z" log="hi there" level="NORMAL" user="Dale"
command="" stepctx="1" node="node-14.qa.subgroup.mycompany.com"/>
<entry time="09:48:24" absolute_time="2014-01-16T17:48:24Z" log="hi there" level="NORMAL" user="Carolyn"
command="" stepctx="1" node="node-6.qa.subgroup.mycompany.com"/>
</entries>
</output>
</result>