Authored by xuhui

集成测试

... ... @@ -22,4 +22,5 @@ public class AutoTestReq {
private String mailto;
}
private String id;
}
\ No newline at end of file
... ...
... ... @@ -14,9 +14,11 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
... ... @@ -402,4 +404,20 @@ public class ProjectBuildCtrl {
return new ModelAndView("project/autotestresult");
}
@RequestMapping("/testexecute")
@ResponseBody
public BaseResponse testexecute(String env) {
AutoTestReq autoTestReq = new AutoTestReq();
autoTestReq.setEnv(env);
BaseResponse baseResponse = httpRestClient.post("http://qmc.yohops.com:9999/autoTask/executeApiAutoTask", autoTestReq, BaseResponse.class);
return baseResponse;
}
@RequestMapping("/testget")
public BaseResponse testget(String id) {
AutoTestReq autoTestReq = new AutoTestReq();
autoTestReq.setId(id);
BaseResponse baseResponse = httpRestClient.post("http://qmc.yohops.com:9999/autoTask/getAutoTestExecuteResult", autoTestReq, BaseResponse.class);
return baseResponse;
}
}
... ...
... ... @@ -105,6 +105,19 @@
</div>
</div>
</div>
<button id="btnNew" class="btn btn-primary" style="margin-left: 10px;margin-top:10px" onclick="testexecute()">
集成测试
</button>
</div>
<div class="widget-title" style="height: 40px;display:none;" id="testingdiv">
<div>
<div class="form-inline" role="form">
<div class="input-group" style="float: left;margin-left: 25px;margin-top:3px">
<span class="input-group-addon">集成测试结果:</span>
<input type="text" readonly="readonly" id="testingresult" name="testingresult" style="width: 500px" class="form-control" placeholder="" />
</div>
</div>
</div>
</div>
<c:forEach items="${messageList }" var="message">
<div style="float: left;height: 600px;">
... ... @@ -209,6 +222,70 @@
});
}
//做停止用
var setIntervalIndex;
/**
* 集成测试
*/
function testexecute(){
var value;
var envi = $("#environment_name").val();
if(envi == "aws"){
value = 6;
}else if(envi == "qcloud"){
value = 7;
}else{
value = 5;
}
if(setIntervalIndex != null && setIntervalIndex != undefined){
clearInterval(setIntervalIndex);
setIntervalIndex = null;
}
$.ajax({
url: contextPath + 'project/testexecute?env=' + value,
type: 'POST',
dataType: 'json',
success: function (returnVal) {
if(returnVal == null || returnVal.data == null){
alert("http://qmc.yohops.com:9999/autoTask/executeApiAutoTask,参数env="+value+",post请求失败!");
}
var json = returnVal.data;
//获取到id
var id = json.id;
setIntervalIndex = setInterval(function(){testget(id);}, 1000 * 60);
},
error: function (e) {
}
});
}
/**
* 集成测试
*/
function testget(id){
if(id == null || id == undefined){
return;
}
$.ajax({
url: contextPath + 'project/testget?id=' + id,
type: 'POST',
dataType: 'json',
success: function (returnVal) {
if(returnVal == null || returnVal.data == null){
return;
}
var message = returnVal.message;
var code = returnVal.code;
$("#testingdiv").show();
$("#testingresult").val("id:" + id + ";message:" + message + ";code:"+code);
clearInterval(setIntervalIndex);
},
error: function (e) {
}
});
}
</script>
<script>
... ...