This commit is contained in:
fit2-zhao 2021-01-08 17:54:16 +08:00
commit f22a917f12
10 changed files with 101 additions and 45 deletions

View File

@ -136,6 +136,10 @@ public class UserController {
@PostMapping("/update/current")
public UserDTO updateCurrentUser(@RequestBody User user) {
String currentUserId = SessionUtils.getUserId();
if (!StringUtils.equals(currentUserId, user.getId())) {
MSException.throwException(Translator.get("not_authorized"));
}
userService.updateUser(user);
UserDTO userDTO = userService.getUserDTO(user.getId());
SessionUtils.putUser(SessionUser.fromUser(userDTO));

View File

@ -76,6 +76,8 @@ public class PerformanceTestService {
private TestCaseService testCaseService;
@Resource
private PerformanceNoticeTask performanceNoticeTask;
@Resource
private TestResourcePoolMapper testResourcePoolMapper;
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -217,6 +219,14 @@ public class PerformanceTestService {
if (StringUtils.equalsAny(loadTest.getStatus(), PerformanceTestStatus.Running.name(), PerformanceTestStatus.Starting.name())) {
MSException.throwException(Translator.get("load_test_is_running"));
}
String testResourcePoolId = loadTest.getTestResourcePoolId();
TestResourcePool testResourcePool = testResourcePoolMapper.selectByPrimaryKey(testResourcePoolId);
if (testResourcePool == null) {
MSException.throwException("Test resource pool not exists.");
}
if (ResourceStatusEnum.INVALID.name().equals(testResourcePool.getStatus())) {
MSException.throwException("Test resource pool invalid.");
}
// check kafka
checkKafka();
@ -479,9 +489,9 @@ public class PerformanceTestService {
quotaService.checkLoadTestQuota(request, create);
}
}
public List<LoadTest> getLoadTestListByIds(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
LoadTestExample loadTestExample = new LoadTestExample();

View File

@ -332,7 +332,7 @@ public class UserService {
MSException.throwException(Translator.get("user_email_already_exists"));
}
}
user.setPassword(null);
user.setUpdateTime(System.currentTimeMillis());
userMapper.updateByPrimaryKeySelective(user);
// 禁用用户之后剔除在线用户

View File

@ -164,9 +164,9 @@
<ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')"
style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/>
<!--断言规则-->
<ms-api-assertions v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/>
<ms-api-assertions @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/>
<!--提取规则-->
<ms-api-extract @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
<ms-api-extract @suggestClick="suggestClick(node)" :response="response" @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
<!--API 导入 -->
<ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow"
v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
@ -319,7 +319,8 @@
enableCookieShare: false,
globalOptions: {
spacing: 30
}
},
response: {}
}
}
,
@ -534,6 +535,12 @@
this.selectedTreeNode = e;
}
,
suggestClick(node) {
this.response = {};
if (node.parent && node.parent.data.requestResult) {
this.response = node.parent.data.requestResult;
}
},
showAll() {
this.operatingElements = ELEMENTS.get("ALL");
this.selectedTreeNode = undefined;

View File

@ -185,7 +185,6 @@ export default {
this.condition.projectId = this.projectId;
} else {
this.condition.projectId = getCurrentProjectID();
}
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;

View File

@ -57,7 +57,7 @@
</el-collapse-transition>
</el-card>
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" :data="suggestData" ref="jsonpathSuggest"/>
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" ref="jsonpathSuggest"/>
</div>
</template>
@ -111,7 +111,6 @@
type: "",
loading: false,
reloadData: "",
suggestData: {}
}
},
@ -125,17 +124,14 @@
this.$emit('copyRow', this.assertions, this.node);
},
suggestJsonOpen() {
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
this.$message(this.$t('api_test.request.assertions.debug_first'));
return;
}
try {
this.suggestData = JSON.parse(this.response.responseResult.body);
} catch (e) {
this.$error(this.$t('api_test.request.assertions.json_path_err'));
return;
}
this.$refs.jsonpathSuggest.open();
this.$emit('suggestClick');
this.$nextTick(() => {
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
this.$message(this.$t('api_test.request.assertions.debug_first'));
return;
}
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
})
},
reload() {
this.loading = true

View File

@ -19,22 +19,34 @@
return {
visible: false,
isCheckAll: false,
data: {},
};
},
props: {
data: {},
tip: {
type: String,
default() {
return ""
}
}
},
},
methods: {
close() {
this.visible = false;
},
open() {
open(objStr) {
this.data = {};
try {
let param = JSON.parse(objStr);
if (param instanceof Array) {
this.$warning(this.$t('api_test.request.assertions.json_path_err'));
return;
}
this.data = param;
} catch (e) {
this.$warning(this.$t('api_test.request.assertions.json_path_err'));
return;
}
this.visible = true;
},
pathChangeHandler(data) {
@ -64,8 +76,8 @@
if (index === params.length - 1) {
if (childObj instanceof Object) {
childObj = JSON.stringify(childObj);
} else if (childObj == null) {
childObj = "null";
} else {
childObj = childObj + "";
}
return {
key: param,

View File

@ -46,7 +46,7 @@
</div>
</el-collapse-transition>
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" :data="suggestData" ref="jsonpathSuggest"/>
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" ref="jsonpathSuggest"/>
</el-card>
</div>
@ -91,7 +91,6 @@
type: "",
reloadData: "",
loading: false,
suggestData: {}
}
},
@ -117,17 +116,14 @@
this.reload();
},
suggestJsonOpen() {
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
this.$message(this.$t('api_test.request.assertions.debug_first'));
return;
}
try {
this.suggestData = JSON.parse(this.response.responseResult.body);
} catch (e) {
this.$error(this.$t('api_test.request.assertions.json_path_err'));
return;
}
this.$refs.jsonpathSuggest.open();
this.$emit('suggestClick');
this.$nextTick(() => {
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
this.$message(this.$t('api_test.request.assertions.debug_first'));
return;
}
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
})
},
addJsonPathSuggest(data) {
let option = {};

View File

@ -63,9 +63,9 @@ export default {
},
methods: {
refresh() {
this.selectNodeIds = [];
this.selectProjectId = '';
this.selectParentNodes = [];
this.$refs.testCaseLoadRelevance.search();
this.$refs.testPlanLoadCaseList.initTable();
this.getNodeTreeByPlanId();
},
initData() {

View File

@ -143,7 +143,8 @@ export default {
{text: 'Error', value: 'Error'}
],
reportId: '',
loading: false
loading: false,
statusScheduler: null
}
},
props: {
@ -156,6 +157,7 @@ export default {
},
created() {
this.initTable();
this.refreshStatus();
},
watch: {
selectProjectId() {
@ -179,6 +181,16 @@ export default {
this.tableData = data.listObject;
})
},
refreshStatus() {
this.refreshScheduler = setInterval(() => {
let arr = this.tableData.filter(data => data.status !== 'Completed' && data.status !== 'Error');
if (arr.length > 0) {
this.initTable();
} else {
clearInterval(this.refreshScheduler);
}
}, 4000);
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.tableData.forEach(item => {
@ -220,17 +232,29 @@ export default {
})
},
handleRunBatch() {
this.selectRows.forEach(loadCase => {
this.run(loadCase);
})
},
run(loadCase) {
this.$post('/test/plan/load/case/run', {
id: loadCase.loadCaseId,
testPlanLoadId: loadCase.id,
triggerMode: 'MANUAL'
}, response => {
let reportId = response.data;
}).then(() => {
this.$notify({
title: loadCase.caseName,
message: '正在执行....',
type: 'success'
});
this.initTable();
}).catch(() => {
this.$notify.error({
title: loadCase.caseName,
message: '用例执行错误,请单独调试该用例!'
});
})
this.refreshStatus();
},
handleDelete(loadCase) {
this.result = this.$get('/test/plan/load/case/delete/' + loadCase.id, () => {
@ -268,8 +292,16 @@ export default {
// this.initTable();
}
})
},
cancelRefresh() {
if (this.refreshScheduler) {
clearInterval(this.refreshScheduler);
}
}
}
},
beforeDestroy() {
this.cancelRefresh();
},
}
</script>