This commit is contained in:
fit2-zhao 2021-01-20 16:50:23 +08:00
commit f2fd694000
16 changed files with 64 additions and 65 deletions

View File

@ -238,6 +238,7 @@
<select id="findIdByPerformanceReportId" resultType="java.lang.String">
SELECT report.id FROM test_plan_report report INNER JOIN test_plan_report_data reportData ON report.id = reportData.test_plan_report_id
WHERE reportData.performance_info like CONCAT('%', #{0},'%')
AND report.is_performance_executing = true;
</select>
</mapper>

View File

@ -7,5 +7,6 @@ public enum ReportTriggerMode {
/**
* 性能测试用例执行触发报告
*/
CASE
CASE,
TEST_PLAN_SCHEDULE
}

View File

@ -141,7 +141,7 @@ public class TestPlanTestJob extends MsScheduleJob {
RunTestPlanRequest performanceRequest = new RunTestPlanRequest();
performanceRequest.setId(caseID);
performanceRequest.setTestPlanLoadId(caseID);
performanceRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name());
String reportId = null;
try {

View File

@ -0,0 +1,17 @@
package io.metersphere.track.dto;
import lombok.Getter;
import lombok.Setter;
/**
* @author song.tianyang
* @Date 2021/1/20 4:07 下午
* @Description 测试计划性能测试执行完毕后的回调参数
*/
@Getter
@Setter
public class TestPlanLoadCaseEventDTO {
private String reportId;
private String triggerMode;
private String status;
}

View File

@ -7,6 +7,7 @@ import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.track.dto.TestPlanLoadCaseEventDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -25,11 +26,12 @@ public class TestPlanLoadCaseEvent implements LoadTestFinishEvent {
@Override
public void execute(LoadTestReport loadTestReport) {
LogUtil.info("PerformanceNoticeEvent OVER:" + loadTestReport.getTriggerMode()+";"+loadTestReport.getStatus());
if (StringUtils.equals(NoticeConstants.Mode.SCHEDULE, loadTestReport.getTriggerMode()) ) {
if (StringUtils.equalsAny(loadTestReport.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
testPlanReportService.updatePerformanceTestStatus(loadTestReport.getId(), ReportTriggerMode.SCHEDULE.name());
}
if (StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(), loadTestReport.getTriggerMode()) ) {
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO();
eventDTO.setReportId(loadTestReport.getId());
eventDTO.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
eventDTO.setStatus(loadTestReport.getStatus());
testPlanReportService.updatePerformanceTestStatus(eventDTO);
}
}
}

View File

@ -199,6 +199,7 @@ public class TestPlanReportService {
QueryTestPlanRequest queryTestPlanRequest = new QueryTestPlanRequest();
queryTestPlanRequest.setId(testPlanReport.getTestPlanId());
TestPlanDTO testPlan = extTestPlanMapper.list(queryTestPlanRequest).get(0);
String issuesInfo = null;
//因为接口案例的定时任务是单个案例开线程运行 所以要检查是否都执行完成全部执行完成时才会进行统一整理
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(),triggerMode)
@ -209,6 +210,8 @@ public class TestPlanReportService {
return;
}
}
}else if(StringUtils.equals(ReportTriggerMode.TEST_PLAN_SCHEDULE.name(),triggerMode)){
issuesInfo = ReportTriggerMode.TEST_PLAN_SCHEDULE.name();
}
testPlanReport.setEndTime(System.currentTimeMillis());
@ -251,6 +254,9 @@ public class TestPlanReportService {
testPlanReportData.setExecuteResult(JSONObject.toJSONString(testCaseReportMetricDTO.getExecuteResult()));
testPlanReportData.setFailurTestCases(JSONObject.toJSONString(testCaseReportMetricDTO.getFailureTestCases()));
testPlanReportData.setModuleExecuteResult(JSONArray.toJSONString(testCaseReportMetricDTO.getModuleExecuteResult()));
if(issuesInfo!=null){
testPlanReportData.setIssuesInfo(issuesInfo);
}
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(testPlanReportData);
}
@ -336,54 +342,11 @@ public class TestPlanReportService {
models.setPerformanceInfo(JSONArray.toJSONString(performaneReportIDList));
testPlanReportDataMapper.updateByPrimaryKeyWithBLOBs(models);
}
/**
* 虽然kafka已经设置了topic推送但是在1.18日测试时发现无法收到消息
* 由于Tapd为完成任务较多无法抽时间查看问题暂时先保留以下逻辑解决完Tpad任务之后查看原因再删除以下代码
*/
executorService.submit(() -> {
//错误数据检查集合 如果错误数据出现超过20次则取消该条数据的检查
Map<String,Integer> errorDataCheckMap = new HashMap<>();
while (performaneReportIDList.size()>0) {
List<String> selectList = new ArrayList<>(performaneReportIDList);
for (String loadTestReportId:selectList) {
LoadTestReportWithBLOBs loadTestReportFromDatabase = loadTestReportMapper.selectByPrimaryKey(loadTestReportId);
if(loadTestReportFromDatabase == null){
//检查错误数据
if(errorDataCheckMap.containsKey(loadTestReportId)){
if(errorDataCheckMap.get(loadTestReportId)>20){
performaneReportIDList.remove(loadTestReportId);
}else {
errorDataCheckMap.put(loadTestReportId,errorDataCheckMap.get(loadTestReportId)+1);
}
}else {
errorDataCheckMap.put(loadTestReportId,1);
}
}else if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
performaneReportIDList.remove(loadTestReportId);
System.out.println("over");
}
}
if(performaneReportIDList.isEmpty()){
List<String> testPlanReportList = new ArrayList<>();
testPlanReportList.add(testPlanReport.getId());
this.updateReport(testPlanReportList, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
}else {
try {
//查询定时任务是否关闭
Thread.sleep(1000 * 10);// 检查 loadtest 的状态
} catch (InterruptedException e) {
}
}
}
return true;
});
}
public void updatePerformanceTestStatus(String reportId,String triggerMode) {
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(reportId);
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),triggerMode);
public void updatePerformanceTestStatus(TestPlanLoadCaseEventDTO eventDTO) {
List<String> testPlanReportId = extTestPlanMapper.findIdByPerformanceReportId(eventDTO.getReportId());
this.updateReport(testPlanReportId, ApiRunMode.SCHEDULE_PERFORMANCE_TEST.name(),eventDTO.getTriggerMode());
}
public void delete(List<String> testPlanReportIdList) {

View File

@ -41,7 +41,7 @@
<el-dropdown @command="handleCommand" v-tester>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
<el-dropdown-item command="ADD">{{ $t('api_test.automation.add_scenario') }}</el-dropdown-item>
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
</el-dropdown-item>
</el-dropdown-menu>

View File

@ -374,6 +374,7 @@
},
copy(row) {
row.copy = true;
row.name = 'copy_'+row.name;
this.$emit('edit', row);
},
showReport(row) {

View File

@ -692,9 +692,19 @@
if (!hasEnvironment) {
this.currentEnvironmentId = '';
}
//
this.checkDataIsCopy();
});
}
},
checkDataIsCopy(){
//
if(this.currentScenario.copy){
this.editScenario(false);
}
},
openEnvironmentConfig() {
if (!this.projectId) {
this.$error(this.$t('api_test.select_project'));
@ -937,7 +947,7 @@
}
.ms-scenario-button {
margin-left: 30%;
margin-left: 20px;
padding: 7px;
}

View File

@ -81,12 +81,13 @@
],
isCodeEditAlive: true,
languages: [
'beanshell', "python", "groovy"
'beanshell', "python", "groovy", "javascript"
],
codeEditModeMap: {
beanshell: 'java',
python: 'python',
groovy: 'java'
groovy: 'java',
javascript: 'javascript',
}
}
},

View File

@ -122,7 +122,7 @@
@keydown.enter.native.prevent
type="primary"
circle
style="padding: 7px 0.5px;font-size: 0.5px;color:white"
style="color:white;padding: 0px 0.1px;font-size: 11px;width: 28px;height: 28px;"
size="mini" >case
</el-button>
</el-tooltip>

View File

@ -50,6 +50,8 @@
.active {
border: solid 1px #6d317c;
background-color: #7C3985;
color: #FFFFFF;
}
.case-button {

View File

@ -15,7 +15,7 @@
</span>
</el-tooltip>
<el-row>
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
@ -30,7 +30,7 @@
</div></span>
</el-tooltip>
<el-row>
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.arguments"/>
</el-tab-pane>
@ -46,7 +46,7 @@
</span>
</el-tooltip>
<el-row>
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-variable :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :parameters="request.rest"/>
</el-tab-pane>

View File

@ -27,7 +27,7 @@
<span>
<el-button size="mini" p="$t('commons.remove')" icon="el-icon-close" circle @click="remove(scope.row)"
class="ht-btn-remove"/>
<el-button size="mini" p="$t('commons.save')" icon="el-icon-check" circle @click="confirm(scope.row)"
<el-button size="mini" p="$t('commons.save')" icon="el-icon-check" type="primary" circle @click="confirm(scope.row)"
class="ht-btn-confirm"/>
</span>
</template>
@ -143,13 +143,13 @@
.ht-btn-confirm {
color: white;
background-color: #1483F6;
/*background-color: #1483F6;*/
}
.ht-btn-add {
border: 0px;
margin-top: 10px;
color: #1483F6;
color: #783887;
background-color: white;
}

View File

@ -2,6 +2,7 @@
<span>
<span v-if="triggerMode === 'MANUAL'">{{$t('commons.trigger_mode.manual')}}</span>
<span v-if="triggerMode === 'SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
<span v-if="triggerMode === 'TEST_PLAN_SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
<span v-if="triggerMode === 'API'">{{$t('commons.trigger_mode.api')}}</span>
<span v-if="triggerMode === 'CASE'">用例触发</span>
</span>

@ -1 +1 @@
Subproject commit cea763d974b213104f6d6fc30ab48434b72e10f4
Subproject commit 8a6a9ae708306eaf436f35394b71927cec075b0e