feat(测试计划): 测试计划增加性能测试用例

This commit is contained in:
shiziyuan9527 2021-01-07 11:10:19 +08:00
parent 87a074310f
commit 657d800536
7 changed files with 45 additions and 19 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.track.dto.TestPlanLoadCaseDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -7,4 +8,5 @@ import java.util.List;
public interface ExtTestPlanLoadCaseMapper {
List<String> selectIdsNotInPlan(@Param("projectId") String projectId, @Param("planId") String planId);
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("planId") String planId);
}

View File

@ -10,4 +10,12 @@
select tplc.load_case_id from test_plan_load_case tplc where tplc.test_plan_id = #{planId}
)
</select>
<select id="selectTestPlanLoadCaseList" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, u.name as userName, tplc.create_time, tplc.update_time, tplc.test_plan_id, tplc.load_case_id,
lt.status, lt.name as caseName
from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
inner join user u on lt.user_id = u.id
where tplc.test_plan_id = #{planId}
</select>
</mapper>

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.track.dto.TestPlanLoadCaseDTO;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.service.TestPlanLoadCaseService;
import org.springframework.web.bind.annotation.*;
@ -30,7 +31,7 @@ public class TestPlanLoadCaseController {
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<LoadTest>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
public Pager<List<TestPlanLoadCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanLoadCaseService.list(request));
}

View File

@ -0,0 +1,12 @@
package io.metersphere.track.dto;
import io.metersphere.base.domain.TestPlanLoadCase;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestPlanLoadCaseDTO extends TestPlanLoadCase {
private String userName;
private String caseName;
}

View File

@ -1,28 +1,24 @@
package io.metersphere.track.service;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.domain.TestPlanLoadCase;
import io.metersphere.base.domain.TestPlanLoadCaseExample;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.track.dto.TestPlanLoadCaseDTO;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.python.antlr.op.Load;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
@ -45,12 +41,8 @@ public class TestPlanLoadCaseService {
return performanceTestService.getLoadTestListByIds(ids);
}
public List<LoadTest> list(LoadCaseRequest request) {
TestPlanLoadCaseExample testPlanLoadCaseExample = new TestPlanLoadCaseExample();
testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(request.getTestPlanId());
List<TestPlanLoadCase> testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(testPlanLoadCaseExample);
List<String> ids = testPlanLoadCases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList());
return performanceTestService.getLoadTestListByIds(ids);
public List<TestPlanLoadCaseDTO> list(LoadCaseRequest request) {
return extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request.getTestPlanId());
}
public void relevanceCase(LoadCaseRequest request) {

View File

@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS `test_plan_load_case`
(
`id` varchar(50) NOT NULL COMMENT 'ID',
`test_plan_id` varchar(50) NOT NULL COMMENT 'Test plan ID',
`load_case_id` varchar(50) NOT NULL COMMENT 'Load test case ID',
`status` varchar(50) DEFAULT NULL COMMENT 'Load case status',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`),
UNIQUE KEY `plan_load_case_id` (`test_plan_id`, `load_case_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;

View File

@ -26,7 +26,7 @@
<!-- <el-table-column prop="num" label="ID" show-overflow-tooltip/>-->
<el-table-column
prop="name"
prop="caseName"
:label="$t('commons.name')"
show-overflow-tooltip>
</el-table-column>
@ -190,12 +190,11 @@ export default {
},
handleDelete(loadCase) {
console.log(loadCase)
// this.$get('/test/plan/load/case/delete/' + loadCase.id, () => {
// this.$success(this.$t('test_track.cancel_relevance_success'));
// this.$emit('refresh');
// this.initTable();
// });
this.$get('/test/plan/load/case/delete/' + loadCase.id, () => {
this.$success(this.$t('test_track.cancel_relevance_success'));
this.$emit('refresh');
this.initTable();
});
},
sort(column) {
//