我正在使用jira(Zephyr(REST调用来创建测试周期并将测试案例添加到其中。根据上述信息,此处 1如果我使用此REST调用将测试添加到循环中,则作为响应,我将获得JobProgresstoken。JobProgresstoken无非会说出测试案例增加的进度。
现在我面临的问题是我没有从这个Jobprogresstoken中获得任何输出。我尝试使用提到的格式发射get rest呼叫,但我得到了空的响应。
有人可以解释如何使用此Jobprogresstoken来获得我的任务进展吗?我想验证我添加到周期的测试是否会添加是否可疑?
只是我遇到了同样的问题。Zapi文档确实令人困惑。我找到了以下解决方案:
get 检索工作进度的请求具有以下形式:http://jira/rest/reast/zapi/最终/execution/execution/jobprogress/0001498157843923-5056B64FDB-0001其中 0001498157843923-5056B64FDB-0001 是特定Jobprogresstoken的值
由于某些异步操作而获得了Jobprogresstoken后,我的代码正在等待进度变成1(它正在从零索上,到1(
//get the job progress token as a result of some async operation invocation
String jobProgressToken = new JSONObject(zapiResponse).getString("jobProgressToken");
waitAsyncJobToBeCompleted(jobProgressToken);
void waitAsyncJobToBeCompleted(String jobProgressToken) {
double jobProgress;
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LOG.error("Error while try to make the thread sleeping 500ms. " + e.getLocalizedMessage());
e.printStackTrace();
}
jobProgress = getJobProgress(jobProgressToken);
} while (Double.compare(jobProgress, 1) <0);
private double getJobProgress(String jobProgressToken) {
URI uri = makeUriFromString(String.format(
GET_GetJobProgress, //Get request pattern
connectionParameters.getJiraUrl(),//host
jobProgressToken)); //parameters
HttpResponse response = executeHttpRequestWithResponse(new HttpGet(uri));
String zapiResponse = null;
try {
zapiResponse = EntityUtils.toString(response.getEntity());
LOG.trace("ZAPI RESPONSE: " + zapiResponse);
EntityUtils.consumeQuietly(response.getEntity()); //cleanup the HTTP response
double progress = new JSONObject(zapiResponse).getDouble("progress");
LOG.debug("Job progress: " + progress);
return progress;
} catch (IOException e) {
String err = String.format("Error while getting Zephyr API response: %s",
e.getLocalizedMessage());
LOG.fatal(err);
throw new RestApiException(err, e);
} catch (JSONException e) {
String err = String.format("Error while retrieving the job progress from JSON: %sn%s",
zapiResponse, e.getLocalizedMessage());
LOG.fatal(err);
throw new RestApiException(err, e);
}
}
这都是魔术:(
遵循两个日志:第一个用于克隆测试周期,第二个删除
2ndZephyrClient.invokeHttpPost - URI=http://jira/rest/zapi/latest/cycle JSON payload={"projectId": "13795","clonedCycleId": 2643,"name": "ZAPI client test","description": "Created With ZAPI client unit test","versionId": "-1"}
ZephyrClient.cloneTestCycle - RESPONSE JSON: {"jobProgressToken":"0001498218783350-5056b64fdb-0001"}
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 1 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.56,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.56
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 1 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.98,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.98
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 2 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":0.98,"message":"","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 0.98
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218783350-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 3 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":1.0,"message":"Cycle ZAPI client test created successfully.","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 1.0
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/cycle?projectId=13795&versionId=-1 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.invokeHttpDelete - URI=http://jira/rest/zapi/latest/cycle/2727
ZephyrClient.deleteTestCycle - RESPONSE JSON: {"jobProgressToken":"0001498218815183-5056b64fdb-0001"}
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/execution/jobProgress/0001498218815183-5056b64fdb-0001 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
ZephyrClient.getJobProgress - ZAPI RESPONSE: {"timeTaken":"0 min, 0 sec","stepMessage":"","summaryMessage":"","errorMessage":"","progress":1.0,"message":"{"success":"Cycle ZAPI client test успешно удален"}","stepLabel":"","stepMessages":[]}
ZephyrClient.getJobProgress - Job progress: 1.0
ZephyrClient.executeHttpRequestWithResponse - HTTP REQUEST: GET http://jira/rest/zapi/latest/cycle?projectId=13795&versionId=-1 HTTP/1.1
ZephyrClient.executeHttpRequestWithResponse - HTTP RESPONSE: HTTP/1.1 200 OK
P.S。这与应如何完成无关。这是关于它如何对我有用的;(