This commit is contained in:
fit2-zhao 2021-03-17 09:13:50 +08:00
commit 7489fcaec3
16 changed files with 220 additions and 21 deletions

View File

@ -102,7 +102,12 @@
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
ORDER BY ORDER BY
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
load_test.${order.name} ${order.type} <if test="order.name == 'user_name'">
user_name ${order.type}
</if>
<if test="order.name != 'user_name'">
load_test.${order.name} ${order.type}
</if>
</foreach> </foreach>
</if> </if>
</select> </select>

View File

@ -12,4 +12,5 @@ public interface ExtTestPlanLoadCaseMapper {
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request); List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status); void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status);
List<String> getStatusByTestPlanId(@Param("planId") String planId); List<String> getStatusByTestPlanId(@Param("planId") String planId);
} }

View File

@ -0,0 +1,5 @@
package io.metersphere.commons.constants;
public enum TestCaseStatus {
performance,api,testcase,automation
}

View File

@ -238,9 +238,11 @@ public class PerformanceTestService {
// 相减 // 相减
List<String> deleteFileIds = ListUtils.subtract(originFileIds, updatedFileIds); List<String> deleteFileIds = ListUtils.subtract(originFileIds, updatedFileIds);
// 删除已经不相关的文件 // 删除已经不相关的文件
LoadTestFileExample example3 = new LoadTestFileExample(); if (!CollectionUtils.isEmpty(deleteFileIds)) {
example3.createCriteria().andFileIdIn(deleteFileIds); LoadTestFileExample example3 = new LoadTestFileExample();
loadTestFileMapper.deleteByExample(example3); example3.createCriteria().andFileIdIn(deleteFileIds);
loadTestFileMapper.deleteByExample(example3);
}
// 导入项目里其他的文件 // 导入项目里其他的文件
List<String> addFileIds = ListUtils.subtract(updatedFileIds, originFileIds); List<String> addFileIds = ListUtils.subtract(updatedFileIds, originFileIds);

View File

@ -23,4 +23,6 @@ public class PlanCaseRelevanceRequest {
* 具体要关联的用例 * 具体要关联的用例
*/ */
private List<String> testCaseIds = new ArrayList<>(); private List<String> testCaseIds = new ArrayList<>();
private Boolean checked;
} }

View File

@ -24,4 +24,6 @@ public class ReviewRelevanceRequest {
* 具体选择要关联的用例 * 具体选择要关联的用例
*/ */
private List<String> testCaseIds = new ArrayList<>(); private List<String> testCaseIds = new ArrayList<>();
private Boolean checked;
} }

View File

@ -6,10 +6,7 @@ import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper; import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.*;
import io.metersphere.commons.constants.TestCaseReviewStatus;
import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.commons.constants.TestReviewCaseStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
@ -77,6 +74,19 @@ public class TestCaseReviewService {
private NoticeSendService noticeSendService; private NoticeSendService noticeSendService;
@Resource @Resource
private SystemParameterService systemParameterService; private SystemParameterService systemParameterService;
@Resource
private TestCaseReviewLoadMapper testCaseReviewLoadMapper;
@Resource
private TestCaseReviewApiCaseMapper testCaseReviewApiCaseMapper;
@Resource
private TestCaseReviewScenarioMapper testCaseReviewScenarioMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
@Resource
private ApiDefinitionMapper apiDefinitionMapper;
public String saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) { public String saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest); checkCaseReviewExist(reviewRequest);
@ -366,7 +376,65 @@ public class TestCaseReviewService {
} }
sqlSession.flushStatements(); sqlSession.flushStatements();
//同步添加关联的接口和测试用例
if(request.getChecked()){
if (!testCaseIds.isEmpty()) {
testCaseIds.forEach(caseId -> {
TestCaseWithBLOBs testDtail=testCaseMapper.selectByPrimaryKey(caseId);
if(StringUtils.equals(testDtail.getType(), TestCaseStatus.performance.name())){
TestCaseReviewLoad t=new TestCaseReviewLoad();
t.setId(UUID.randomUUID().toString());
t.setTestCaseReviewId(request.getReviewId());
t.setLoadCaseId(testDtail.getTestId());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestCaseReviewLoadExample example=new TestCaseReviewLoadExample();
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andLoadCaseIdEqualTo(t.getLoadCaseId());
if (testCaseReviewLoadMapper.countByExample(example) <=0) {
testCaseReviewLoadMapper.insert(t);
}
}
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.testcase.name())){
TestCaseReviewApiCase t=new TestCaseReviewApiCase();
ApiTestCaseWithBLOBs apitest=apiTestCaseMapper.selectByPrimaryKey(testDtail.getTestId());
ApiDefinitionWithBLOBs apidefinition=apiDefinitionMapper.selectByPrimaryKey(apitest.getApiDefinitionId());
t.setId(UUID.randomUUID().toString());
t.setTestCaseReviewId(request.getReviewId());
t.setApiCaseId(testDtail.getTestId());
t.setEnvironmentId(apidefinition.getEnvironmentId());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestCaseReviewApiCaseExample example=new TestCaseReviewApiCaseExample();
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andApiCaseIdEqualTo(t.getApiCaseId());
if(testCaseReviewApiCaseMapper.countByExample(example)<=0){
testCaseReviewApiCaseMapper.insert(t);
}
}
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.automation.name())){
TestCaseReviewScenario t=new TestCaseReviewScenario();
ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(testDtail.getTestId());
t.setId(UUID.randomUUID().toString());
t.setTestCaseReviewId(request.getReviewId());
t.setApiScenarioId(testDtail.getTestId());
t.setLastResult(testPlanApiScenario.getLastResult());
t.setPassRate(testPlanApiScenario.getPassRate());
t.setReportId(testPlanApiScenario.getReportId());
t.setStatus(testPlanApiScenario.getStatus());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestCaseReviewScenarioExample example=new TestCaseReviewScenarioExample();
example.createCriteria().andTestCaseReviewIdEqualTo(request.getReviewId()).andApiScenarioIdEqualTo(t.getApiScenarioId());
if(testCaseReviewScenarioMapper.countByExample(example)<=0){
testCaseReviewScenarioMapper.insert(t);
}
}
});
}
}
TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
if (StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Prepare.name()) if (StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Prepare.name())
|| StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Completed.name())) { || StringUtils.equals(testCaseReview.getStatus(), TestCaseReviewStatus.Completed.name())) {

View File

@ -114,8 +114,20 @@ public class TestPlanService {
private ApiTestCaseService apiTestCaseService; private ApiTestCaseService apiTestCaseService;
@Resource @Resource
private PerformanceTestService performanceTestService; private PerformanceTestService performanceTestService;
@Resource
private TestPlanLoadCaseMapper testPlanLoadCaseMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiDefinitionMapper apiDefinitionMapper;
@Resource
private TestPlanApiCaseMapper testPlanApiCaseMapper;
@Resource
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
public synchronized void addTestPlan(AddTestPlanRequest testPlan) { public synchronized String addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) { if (getTestPlanByName(testPlan.getName()).size() > 0) {
MSException.throwException(Translator.get("plan_name_already_exists")); MSException.throwException(Translator.get("plan_name_already_exists"));
} }
@ -144,6 +156,7 @@ public class TestPlanService {
.event(NoticeConstants.Event.CREATE) .event(NoticeConstants.Event.CREATE)
.build(); .build();
noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel); noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
return testPlan.getId();
} }
public List<TestPlan> getTestPlanByName(String name) { public List<TestPlan> getTestPlanByName(String name) {
@ -416,7 +429,65 @@ public class TestPlanService {
} }
sqlSession.flushStatements(); sqlSession.flushStatements();
//同步添加关联的接口和测试用例
if(request.getChecked()){
if (!testCaseIds.isEmpty()) {
testCaseIds.forEach(caseId -> {
TestCaseWithBLOBs testDtail=testCaseMapper.selectByPrimaryKey(caseId);
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.performance.name())){
TestPlanLoadCase t = new TestPlanLoadCase();
t.setId(UUID.randomUUID().toString());
t.setTestPlanId(request.getPlanId());
t.setLoadCaseId(testDtail.getTestId());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestPlanLoadCaseExample testPlanLoadCaseExample=new TestPlanLoadCaseExample();
testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andLoadCaseIdEqualTo(t.getLoadCaseId());
if (testPlanLoadCaseMapper.countByExample(testPlanLoadCaseExample) <=0) {
testPlanLoadCaseMapper.insert(t);
}
}
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.testcase.name())){
TestPlanApiCase t=new TestPlanApiCase();
ApiTestCaseWithBLOBs apitest=apiTestCaseMapper.selectByPrimaryKey(testDtail.getTestId());
ApiDefinitionWithBLOBs apidefinition=apiDefinitionMapper.selectByPrimaryKey(apitest.getApiDefinitionId());
t.setId(UUID.randomUUID().toString());
t.setTestPlanId(request.getPlanId());
t.setApiCaseId(testDtail.getTestId());
t.setEnvironmentId(apidefinition.getEnvironmentId());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestPlanApiCaseExample example=new TestPlanApiCaseExample();
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiCaseIdEqualTo(t.getApiCaseId());
if(testPlanApiCaseMapper.countByExample(example)<=0){
testPlanApiCaseMapper.insert(t);
}
}
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.automation.name())){
TestPlanApiScenario t=new TestPlanApiScenario();
ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(testDtail.getTestId());
t.setId(UUID.randomUUID().toString());
t.setTestPlanId(request.getPlanId());
t.setApiScenarioId(testDtail.getTestId());
t.setLastResult(testPlanApiScenario.getLastResult());
t.setPassRate(testPlanApiScenario.getPassRate());
t.setReportId(testPlanApiScenario.getReportId());
t.setStatus(testPlanApiScenario.getStatus());
t.setCreateTime(System.currentTimeMillis());
t.setUpdateTime(System.currentTimeMillis());
TestPlanApiScenarioExample example=new TestPlanApiScenarioExample();
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId());
if(testPlanApiScenarioMapper.countByExample(example)<=0){
testPlanApiScenarioMapper.insert(t);
}
}
});
}
}
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name()) if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|| StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {

View File

@ -147,6 +147,9 @@ alter table schedule drop column custom_data;
-- add sort column -- add sort column
alter table load_test_file add sort int default 0; alter table load_test_file add sort int default 0;
alter table file_metadata
add project_id VARCHAR(50) null;
UPDATE file_metadata JOIN (SELECT file_id, project_id UPDATE file_metadata JOIN (SELECT file_id, project_id
FROM load_test_file FROM load_test_file
JOIN load_test ON test_id = load_test.id) temp ON file_id = file_metadata.id JOIN load_test ON test_id = load_test.id) temp ON file_id = file_metadata.id

View File

@ -199,7 +199,7 @@ export default {
}); });
}, },
beforeUploadFile(file) { async beforeUploadFile(file) {
if (!this.fileValidator(file)) { if (!this.fileValidator(file)) {
/// todo: /// todo:
return false; return false;
@ -215,7 +215,8 @@ export default {
async function f() { async function f() {
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {filename: file.name}) return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {filename: file.name})
} }
f().then(res => {
await f().then(res => {
let response = res.data; let response = res.data;
if (response.data.length === 0) { if (response.data.length === 0) {
let type = file.name.substring(file.name.lastIndexOf(".") + 1); let type = file.name.substring(file.name.lastIndexOf(".") + 1);

View File

@ -60,7 +60,7 @@
<script> <script>
import MsDialogFooter from "../../common/components/MsDialogFooter"; import MsDialogFooter from "../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../common/js/utils"; import {listenGoBack, publicKeyEncrypt, removeGoBackListener} from "../../../../common/js/utils";
export default { export default {
name: "LdapSetting", name: "LdapSetting",
@ -204,9 +204,15 @@ export default {
}) })
}, },
login(form) { login(form) {
let publicKey = localStorage.getItem("publicKey");
this.$refs[form].validate(valid => { this.$refs[form].validate(valid => {
if (valid) { if (valid) {
this.result = this.$post("/ldap/test/login", this.loginForm, () => { let form = {
username: publicKeyEncrypt(this.loginForm.username, publicKey),
password: publicKeyEncrypt(this.loginForm.password, publicKey),
};
this.result = this.$post("/ldap/test/login", form, () => {
this.$success(this.$t('ldap.login_success')); this.$success(this.$t('ldap.login_success'));
}); });
} else { } else {

View File

@ -109,6 +109,9 @@
@click="savePlan"> @click="savePlan">
{{ $t('test_track.confirm') }} {{ $t('test_track.confirm') }}
</el-button> </el-button>
<el-button type="primary" @click="testPlanInfo">
{{ $t('test_track.planning_execution') }}
</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@ -170,6 +173,33 @@ export default {
listenGoBack(this.close); listenGoBack(this.close);
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
testPlanInfo() {
this.$refs['planFrom'].validate((valid) => {
if (valid) {
let param = {};
Object.assign(param, this.form);
param.name = param.name.trim();
if (param.name === '') {
this.$warning(this.$t('test_track.plan.input_plan_name'));
return;
}
param.workspaceId = localStorage.getItem(WORKSPACE_ID);
if (this.form.tags instanceof Array) {
this.form.tags = JSON.stringify(this.form.tags);
}
param.tags = this.form.tags;
this.$post('/test/plan/' + this.operationType, param, response => {
this.$success(this.$t('commons.save_success'));
this.dialogFormVisible = false;
this.$router.push('/track/plan/view/' + response.data);
// 广 head
TrackEvent.$emit(LIST_CHANGE);
});
} else {
return false;
}
});
},
savePlan() { savePlan() {
this.$refs['planFrom'].validate((valid) => { this.$refs['planFrom'].validate((valid) => {
if (valid) { if (valid) {

View File

@ -3,9 +3,9 @@
<template v-slot:header> <template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" <ms-table-header :is-tester-permission="true" :condition.sync="condition"
@search="initTableData" @create="testPlanCreate" @search="initTableData" @create="testPlanCreate"
:create-tip="$t('test_track.plan.create_plan')"
:title="$t('test_track.plan.test_plan')" :title="$t('test_track.plan.test_plan')"
:show-create="false"/> />
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester @click="testPlanCreate"/>
</template> </template>

View File

@ -19,6 +19,9 @@
<slot name="footer"></slot> <slot name="footer"></slot>
</div> </div>
<div v-else> <div v-else>
<div style="margin-bottom: 15px;margin-right: 0">
<el-checkbox v-model="checked">同步添加关联的接口和性能测试</el-checkbox>
</div>
<ms-dialog-footer @cancel="close" @confirm="save"/> <ms-dialog-footer @cancel="close" @confirm="save"/>
</div> </div>
</template> </template>
@ -41,6 +44,7 @@
}, },
data() { data() {
return { return {
checked: true,
result: {}, result: {},
currentProject: {}, currentProject: {},
projectId: '', projectId: '',
@ -70,7 +74,7 @@
}, },
save() { save() {
this.$emit('save'); this.$emit('save', this.checked);
}, },
close() { close() {

View File

@ -63,10 +63,6 @@
<div v-if="!lineStatus" style="text-align: center">{{ $t('test_track.review_view.last_page') }}</div> <div v-if="!lineStatus" style="text-align: center">{{ $t('test_track.review_view.last_page') }}</div>
<div style="text-align: center"> {{ total }} </div> <div style="text-align: center"> {{ total }} </div>
<div style="margin-bottom: 15px;margin-right: 0">
<el-checkbox v-model="checked">同步添加关联的接口和性能测试</el-checkbox>
</div>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
@ -162,11 +158,12 @@ export default {
this.projectId = projectId; this.projectId = projectId;
}, },
saveCaseRelevance() { saveCaseRelevance(item) {
let param = {}; let param = {};
param.planId = this.planId; param.planId = this.planId;
param.testCaseIds = [...this.selectIds]; param.testCaseIds = [...this.selectIds];
param.request = this.condition; param.request = this.condition;
param.checked = item
// //
if (this.testCases.length === param.testCaseIds.length) { if (this.testCases.length === param.testCaseIds.length) {
param.testCaseIds = ['all']; param.testCaseIds = ['all'];

View File

@ -133,6 +133,7 @@ export default {
}, },
data() { data() {
return { return {
checked: true,
result: {}, result: {},
currentProject: {}, currentProject: {},
dialogFormVisible: false, dialogFormVisible: false,
@ -202,6 +203,7 @@ export default {
param.reviewId = this.reviewId; param.reviewId = this.reviewId;
param.testCaseIds = [...this.selectIds]; param.testCaseIds = [...this.selectIds];
param.request = this.condition; param.request = this.condition;
param.checked = this.checked;
// //
if (this.testReviews.length === param.testCaseIds.length) { if (this.testReviews.length === param.testCaseIds.length) {
param.testCaseIds = ['all']; param.testCaseIds = ['all'];