Merge branch 'dev' of bin.github.com:fit2cloudrd/metersphere-server into dev
This commit is contained in:
commit
d5470c33c9
|
@ -53,6 +53,11 @@ public class LoadTestController {
|
|||
loadTestService.delete(request);
|
||||
}
|
||||
|
||||
@PostMapping("/run")
|
||||
public void delete(@RequestBody RunTestPlanRequest request) {
|
||||
loadTestService.run(request);
|
||||
}
|
||||
|
||||
@GetMapping("/file/metadata/{testId}")
|
||||
public FileMetadata getFileMetadata(@PathVariable String testId) {
|
||||
return fileService.getFileMetadataByTestId(testId);
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package io.metersphere.controller.request.testplan;
|
||||
|
||||
public class RunTestPlanRequest extends TestPlanRequest {
|
||||
}
|
|
@ -6,10 +6,7 @@ import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
|
|||
import io.metersphere.commons.constants.LoadTestFileType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.IOUtils;
|
||||
import io.metersphere.controller.request.testplan.DeleteTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.EditTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.QueryTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.SaveTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.*;
|
||||
import io.metersphere.dto.LoadTestDTO;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -147,4 +144,13 @@ public class LoadTestService {
|
|||
loadTestMapper.updateByPrimaryKeySelective(loadTest);
|
||||
}
|
||||
}
|
||||
|
||||
public void run(RunTestPlanRequest request) {
|
||||
final LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
|
||||
if (loadTest == null) {
|
||||
MSException.throwException("无法运行测试,未找到测试:" + request.getId());
|
||||
}
|
||||
|
||||
System.out.println("开始运行:" + loadTest.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,36 @@ const options = function (value, array) {
|
|||
return value;
|
||||
};
|
||||
|
||||
const timestampFormatDate = function (timestamp) {
|
||||
if (!timestamp) {
|
||||
return timestamp
|
||||
}
|
||||
|
||||
let date = new Date(timestamp);
|
||||
|
||||
let y = date.getFullYear();
|
||||
|
||||
let MM = date.getMonth() + 1;
|
||||
MM = MM < 10 ? ('0' + MM) : MM;
|
||||
|
||||
let d = date.getDate();
|
||||
d = d < 10 ? ('0' + d) : d;
|
||||
|
||||
let h = date.getHours();
|
||||
h = h < 10 ? ('0' + h) : h;
|
||||
|
||||
let m = date.getMinutes();
|
||||
m = m < 10 ? ('0' + m) : m;
|
||||
|
||||
let s = date.getSeconds();
|
||||
s = s < 10 ? ('0' + s) : s;
|
||||
|
||||
return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
|
||||
};
|
||||
|
||||
const filters = {
|
||||
"options": options,
|
||||
"timestampFormatDate": timestampFormatDate,
|
||||
};
|
||||
|
||||
export default {
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
let timestampFormatDate = function (timestamp) {
|
||||
if (!timestamp) {
|
||||
return timestamp
|
||||
}
|
||||
|
||||
let date = new Date(timestamp);
|
||||
|
||||
let y = date.getFullYear();
|
||||
|
||||
let MM = date.getMonth() + 1;
|
||||
MM = MM < 10 ? ('0' + MM) : MM;
|
||||
|
||||
let d = date.getDate();
|
||||
d = d < 10 ? ('0' + d) : d;
|
||||
|
||||
let h = date.getHours();
|
||||
h = h < 10 ? ('0' + h) : h;
|
||||
|
||||
let m = date.getMinutes();
|
||||
m = m < 10 ? ('0' + m) : m;
|
||||
|
||||
let s = date.getSeconds();
|
||||
s = s < 10 ? ('0' + s) : s;
|
||||
|
||||
return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
|
||||
};
|
||||
export default timestampFormatDate
|
|
@ -51,6 +51,7 @@
|
|||
listProjectPath: "/project/listAll",
|
||||
savePath: "/testplan/save",
|
||||
editPath: "/testplan/edit",
|
||||
runPath: "/testplan/run",
|
||||
projects: [],
|
||||
active: '0',
|
||||
tabs: [{
|
||||
|
@ -85,28 +86,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
let formData = new FormData();
|
||||
let url = this.testPlan.id ? this.editPath : this.savePath;
|
||||
|
||||
if (!this.testPlan.file.id) {
|
||||
formData.append("file", this.testPlan.file);
|
||||
}
|
||||
// file属性不需要json化
|
||||
let requestJson = JSON.stringify(this.testPlan, function (key, value) {
|
||||
return key === "file" ? undefined : value
|
||||
});
|
||||
formData.append('request', new Blob([requestJson], {
|
||||
type: "application/json"
|
||||
}));
|
||||
|
||||
let options = {
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': undefined
|
||||
}
|
||||
};
|
||||
let options = this.getSaveOption();
|
||||
|
||||
this.$request(options).then(response => {
|
||||
if (response) {
|
||||
|
@ -122,12 +102,48 @@
|
|||
return;
|
||||
}
|
||||
|
||||
/// todo: saveAndRun
|
||||
this.$message({
|
||||
message: '保存成功,开始运行!',
|
||||
type: 'success'
|
||||
let options = this.getSaveOption();
|
||||
|
||||
this.$request(options).then(response => {
|
||||
if (response) {
|
||||
this.$message({
|
||||
message: '保存成功!',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
this.$post(this.runPath, {id: this.testPlan.id}).then(() => {
|
||||
this.$message({
|
||||
message: '正在运行!',
|
||||
type: 'success'
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
getSaveOption() {
|
||||
let formData = new FormData();
|
||||
let url = this.testPlan.id ? this.editPath : this.savePath;
|
||||
|
||||
if (!this.testPlan.file.id) {
|
||||
formData.append("file", this.testPlan.file);
|
||||
}
|
||||
// file属性不需要json化
|
||||
let requestJson = JSON.stringify(this.testPlan, function (key, value) {
|
||||
return key === "file" ? undefined : value
|
||||
});
|
||||
formData.append('request', new Blob([requestJson], {
|
||||
type: "application/json"
|
||||
}));
|
||||
|
||||
return {
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
cancel() {
|
||||
this.$router.push({path: '/'})
|
||||
},
|
||||
|
|
|
@ -8,7 +8,6 @@ import App from './App.vue';
|
|||
import router from "./components/router/router";
|
||||
import './permission' // permission control
|
||||
import i18n from "../i18n/i18n";
|
||||
import timestampFormatDate from "./components/common/filter/TimestampFormatDateFilter";
|
||||
import store from "./store";
|
||||
import {permission} from './permission'
|
||||
|
||||
|
@ -20,9 +19,6 @@ Vue.use(ElementUI, {
|
|||
Vue.use(filters);
|
||||
Vue.use(ajax);
|
||||
|
||||
// filter
|
||||
Vue.filter('timestampFormatDate', timestampFormatDate);
|
||||
|
||||
// v-permission
|
||||
Vue.directive('permission', permission)
|
||||
|
||||
|
|
Loading…
Reference in New Issue