fix(接口自动化): 批量执行,不同模式切换问题

This commit is contained in:
fit2-zhao 2021-04-16 14:47:21 +08:00 committed by fit2-zhao
parent b610e11b4e
commit 91c7f25067
15 changed files with 751 additions and 711 deletions

View File

@ -118,6 +118,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
MsHTTPSamplerProxy proxy = mapper.readValue(bloBs.getRequest(), new TypeReference<MsHTTPSamplerProxy>() {
});
this.setHashTree(proxy.getHashTree());
this.setName(bloBs.getName());
this.setMethod(proxy.getMethod());
this.setBody(proxy.getBody());
this.setRest(proxy.getRest());
this.setArguments(proxy.getArguments());
this.setHeaders(proxy.getHeaders());
}
} else {
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
@ -126,6 +132,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
MsHTTPSamplerProxy proxy = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsHTTPSamplerProxy>() {
});
this.setHashTree(proxy.getHashTree());
this.setName(apiDefinition.getName());
this.setMethod(proxy.getMethod());
this.setBody(proxy.getBody());
this.setRest(proxy.getRest());
this.setArguments(proxy.getArguments());
this.setHeaders(proxy.getHeaders());
}
}
} catch (Exception ex) {

View File

@ -567,7 +567,7 @@ public class ApiAutomationService {
return null;
}
public APIScenarioReportResult createScenarioReport(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID) {
public APIScenarioReportResult createScenarioReport(String id, String scenarioId, String scenarioName, String triggerMode, String execType, String projectId, String userID, RunModeConfig config) {
APIScenarioReportResult report = new APIScenarioReportResult();
if (triggerMode.equals(ApiRunMode.SCENARIO.name()) || triggerMode.equals(ApiRunMode.DEFINITION.name())) {
triggerMode = ReportTriggerMode.MANUAL.name();
@ -579,8 +579,12 @@ public class ApiAutomationService {
} else {
report.setName("场景调试");
}
report.setCreateTime(System.currentTimeMillis());
report.setUpdateTime(System.currentTimeMillis());
report.setCreateTime(System.currentTimeMillis());
if (config != null && config.getMode().equals("serial")) {
report.setCreateTime(System.currentTimeMillis() + 2000);
report.setUpdateTime(System.currentTimeMillis() + 2000);
}
report.setStatus(APITestStatus.Running.name());
if (StringUtils.isNotEmpty(userID)) {
report.setUserId(userID);
@ -733,10 +737,10 @@ public class ApiAutomationService {
}
}
report = createScenarioReport(reportId, testPlanScenarioId, item.getName(), request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
} else {
report = createScenarioReport(reportId, item.getId(), item.getName(), request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
}
// 生成报告和HashTree
@ -769,8 +773,13 @@ public class ApiAutomationService {
private HashTree generateHashTree(List<ApiScenarioWithBLOBs> apiScenarios, RunScenarioRequest request, List<String> reportIds) {
HashTree jmeterHashTree = new ListedHashTree();
MsTestPlan testPlan = new MsTestPlan();
testPlan.setSerializeThreadgroups(request.getConfig() != null && request.getConfig().getMode().equals("serial"));
testPlan.setHashTree(new LinkedList<>());
if (request.getConfig() != null && request.getConfig().getMode().equals("serial")) {
testPlan.setSerializeThreadgroups(true);
if (StringUtils.isNotEmpty(request.getConfig().getReportName())) {
request.setExecuteType(ExecuteType.Completed.name());
}
}
try {
boolean isFirst = true;
for (ApiScenarioWithBLOBs item : apiScenarios) {
@ -791,7 +800,6 @@ public class ApiAutomationService {
// 批量执行的结果直接存储为报告
if (isFirst) {
group.setName(request.getId());
isFirst = false;
}
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@ -829,15 +837,16 @@ public class ApiAutomationService {
}
}
createScenarioReport(group.getName(), testPlanScenarioId, item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig());
} else {
createScenarioReport(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig());
}
reportIds.add(group.getName());
}
group.setHashTree(scenarios);
testPlan.getHashTree().add(group);
isFirst = false;
}
} catch (Exception ex) {
MSException.throwException(ex.getMessage());
@ -859,7 +868,11 @@ public class ApiAutomationService {
List<String> ids = request.getIds();
//检查是否有正在执行中的情景
this.checkScenarioIsRunning(ids);
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(ids);
StringBuilder idStr = new StringBuilder();
ids.forEach(item -> {
idStr.append("\"").append(item).append("\"").append(",");
});
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectByIds(idStr.toString().substring(0, idStr.toString().length() - 1), "\"" + StringUtils.join(ids, ",") + "\"");
String runMode = ApiRunMode.SCENARIO.name();
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
@ -936,7 +949,7 @@ public class ApiAutomationService {
}
// 调用执行方法
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
SessionUtils.getUserId());
SessionUtils.getUserId(), null);
// 调用执行方法
// jMeterService.runTest(request.getId(), hashTree, ApiRunMode.SCENARIO.name(), null);
// 调用执行方法

View File

@ -49,10 +49,12 @@ public class ApiDefinitionExecResultService {
if (CollectionUtils.isNotEmpty(result.getScenarios())) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiDefinitionExecResultMapper definitionExecResultMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
result.getScenarios().get(0).getRequestResults().forEach(item -> {
result.getScenarios().forEach(scenarioResult -> {
if (scenarioResult != null && CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
scenarioResult.getRequestResults().forEach(item -> {
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
saveResult.setId(UUID.randomUUID().toString());
saveResult.setCreateTime(System.currentTimeMillis());
saveResult.setCreateTime(item.getStartTime());
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
saveResult.setName(item.getName());
if (item.getName().indexOf("<->") != -1) {
@ -66,9 +68,8 @@ public class ApiDefinitionExecResultService {
saveResult.setType(type);
saveResult.setStatus(status);
if (StringUtils.equals(type, ApiRunMode.API_PLAN.name())) {
testPlanApiCaseService.setExecResult(item.getName(), status);
testCaseReviewApiCaseService.setExecResult(item.getName(), status);
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
}
// 清空上次执行结果的内容只保留当前最新一条内容
@ -85,6 +86,8 @@ public class ApiDefinitionExecResultService {
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCaseWithBLOBs);
definitionExecResultMapper.insert(saveResult);
});
}
});
sqlSession.flushStatements();
}
}
@ -126,8 +129,8 @@ public class ApiDefinitionExecResultService {
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
} else {
userID = Objects.requireNonNull(SessionUtils.getUser()).getId();
testPlanApiCaseService.setExecResult(item.getName(), status);
testCaseReviewApiCaseService.setExecResult(item.getName(), status);
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
}
saveResult.setUserId(userID);

View File

@ -15,12 +15,13 @@ import io.metersphere.base.mapper.ApiScenarioReportDetailMapper;
import io.metersphere.base.mapper.ApiScenarioReportMapper;
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import io.metersphere.track.service.TestPlanReportService;
import org.apache.commons.collections4.CollectionUtils;
@ -57,9 +58,9 @@ public class ApiScenarioReportService {
// 更新场景
if (result != null) {
if (StringUtils.equals(runMode, ApiRunMode.SCENARIO_PLAN.name())) {
return updatePlanCase(result,runMode);
return updatePlanCase(result, runMode);
} else if (StringUtils.equals(runMode, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
return updateSchedulePlanCase(result,runMode);
return updateSchedulePlanCase(result, runMode);
} else {
updateScenarioStatus(result.getTestId());
return updateScenario(result, runMode);
@ -114,11 +115,12 @@ public class ApiScenarioReportService {
return report;
}
public ApiScenarioReport editReport(ScenarioResult test) {
public ApiScenarioReport editReport(ScenarioResult test, long startTime) {
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(test.getName());
report.setId(report.getId());
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
report.setUpdateTime(System.currentTimeMillis());
report.setCreateTime(startTime);
report.setUpdateTime(startTime);
String status = test.getError() == 0 ? "Success" : "Error";
report.setStatus(status);
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
@ -166,7 +168,7 @@ public class ApiScenarioReportService {
return testResult;
}
public ApiScenarioReport updatePlanCase(TestResult result,String runMode) {
public ApiScenarioReport updatePlanCase(TestResult result, String runMode) {
// TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(result.getTestId());
List<ScenarioResult> scenarioResultList = result.getScenarios();
ApiScenarioReport returnReport = null;
@ -175,9 +177,13 @@ public class ApiScenarioReportService {
String projectId = null;
String userId = null;
TestResult fullResult = createTestResult(result);
for (ScenarioResult scenarioResult :
scenarioResultList) {
ApiScenarioReport report = editReport(scenarioResult);
List<String> reportIds = new LinkedList<>();
for (ScenarioResult scenarioResult : scenarioResultList) {
long startTime = System.currentTimeMillis();
if (CollectionUtils.isNotEmpty(scenarioResult.getRequestResults()) && scenarioResult.getRequestResults().get(0).getStartTime() > 0) {
startTime = scenarioResult.getRequestResults().get(0).getStartTime();
}
ApiScenarioReport report = editReport(scenarioResult, startTime);
// 报告详情内容
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
@ -207,16 +213,17 @@ public class ApiScenarioReportService {
String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError()));
testPlanApiScenario.setPassRate(passRate);
testPlanApiScenario.setReportId(report.getId());
testPlanApiScenario.setUpdateTime(System.currentTimeMillis());
testPlanApiScenario.setUpdateTime(report.getCreateTime());
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
}
returnReport = report;
reportIds.add(report.getId());
}
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
return returnReport;
}
public ApiScenarioReport updateSchedulePlanCase(TestResult result,String runMode) {
public ApiScenarioReport updateSchedulePlanCase(TestResult result, String runMode) {
ApiScenarioReport lastReport = null;
List<ScenarioResult> scenarioResultList = result.getScenarios();
@ -226,9 +233,14 @@ public class ApiScenarioReportService {
String projectId = null;
String userId = null;
TestResult fullResult = createTestResult(result);
List<String> reportIds = new ArrayList<>();
for (ScenarioResult scenarioResult : scenarioResultList) {
// 存储场景报告
ApiScenarioReport report = editReport(scenarioResult);
long startTime = System.currentTimeMillis();
if (CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
startTime = scenarioResult.getRequestResults().get(0).getStartTime();
}
ApiScenarioReport report = editReport(scenarioResult, startTime);
/**
* 测试计划的定时任务场景执行时主键是提前生成的测试报告ID也就是TestResult.id是测试报告ID
@ -280,9 +292,10 @@ public class ApiScenarioReportService {
scenarioNames.append(report.getName()).append(",");
lastReport = report;
reportIds.add(report.getId());
}
// 合并报告
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class);
testPlanReportService.updateReport(testPlanReportIdList, ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ReportTriggerMode.SCHEDULE.name());
@ -323,9 +336,12 @@ public class ApiScenarioReportService {
}
}
private void margeReport(TestResult result, StringBuilder scenarioIds, StringBuilder scenarioNames, String runMode, String projectId, String userId) {
private void margeReport(TestResult result, StringBuilder scenarioIds, StringBuilder scenarioNames, String runMode, String projectId, String userId, List<String> reportIds) {
// 合并生成一份报告
if (StringUtils.isNotEmpty(result.getReportName())) {
// 清理其他报告保留一份合并后的报告
this.deleteByIds(reportIds);
ApiScenarioReport report = createScenarioReport(scenarioIds.toString(), result.getReportName(), result.getError() > 0 ? "Error" : "Success", scenarioNames.toString().substring(0, scenarioNames.toString().length() - 1), runMode, projectId, userId);
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
detail.setContent(JSON.toJSONString(result).getBytes(StandardCharsets.UTF_8));
@ -342,9 +358,14 @@ public class ApiScenarioReportService {
String projectId = null;
String userId = null;
TestResult fullResult = createTestResult(result);
List<String> reportIds = new LinkedList<>();
for (ScenarioResult item : result.getScenarios()) {
// 更新报告状态
ApiScenarioReport report = editReport(item);
long startTime = System.currentTimeMillis();
if (CollectionUtils.isNotEmpty(item.getRequestResults())) {
startTime = item.getRequestResults().get(0).getStartTime();
}
ApiScenarioReport report = editReport(item, startTime);
TestResult newResult = createTestResult(result.getTestId(), item);
item.setName(report.getScenarioName());
newResult.addScenario(item);
@ -373,9 +394,10 @@ public class ApiScenarioReportService {
apiScenarioMapper.updateByPrimaryKey(scenario);
}
lastReport = report;
reportIds.add(report.getId());
}
// 合并生成一份报告
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId);
margeReport(result, scenarioIds, scenarioNames, runMode, projectId, userId, reportIds);
return lastReport;
}

View File

@ -17,10 +17,13 @@ public interface ExtApiScenarioMapper {
List<ApiScenarioWithBLOBs> selectIds(@Param("ids") List<String> ids);
List<ApiScenarioWithBLOBs> selectByIds(@Param("ids") String ids,@Param("oderId") String oderId);
List<ApiScenario> selectReference(@Param("request") ApiScenarioRequest request);
int removeToGc(@Param("ids") List<String> ids);
int removeToGcByExample(ApiScenarioExample example);
int reduction(@Param("ids") List<String> ids);

View File

@ -256,6 +256,10 @@
</foreach>
</select>
<select id="selectByIds" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
select * from api_scenario where id in (${ids}) ORDER BY FIND_IN_SET(id,${oderId})
</select>
<select id="selectReference" resultType="io.metersphere.base.domain.ApiScenario">
select * from api_scenario
<where>

View File

@ -19,4 +19,7 @@ public interface ExtTestPlanScenarioCaseMapper {
List<String> getNotRelevanceCaseIds(String planId, List<String> relevanceProjectIds);
List<String> selectIds(@Param("request")TestPlanScenarioRequest request);
List<TestPlanApiScenario> selectByIds(@Param("ids")String ids ,@Param("oderId")String oderId );
}

View File

@ -88,6 +88,9 @@
</if>
</select>
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
select t.* from test_plan_api_scenario t where t.id in (${ids}) ORDER BY FIND_IN_SET(t.id,${oderId})
</select>
<select id="selectIds" resultType="java.lang.String">
select
t.id

View File

@ -7,8 +7,6 @@ import io.metersphere.api.service.ApiDefinitionExecResultService;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.TestCaseReviewApiCase;
import io.metersphere.base.domain.TestCaseReviewApiCaseExample;
import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.domain.TestPlanApiCaseExample;
import io.metersphere.base.mapper.TestCaseReviewApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewApiCaseMapper;
import io.metersphere.commons.utils.ServiceUtils;
@ -91,11 +89,11 @@ public class TestCaseReviewApiCaseService {
});
}
}
public void setExecResult(String id, String status) {
public void setExecResult(String id, String status,Long time) {
TestCaseReviewApiCase apiCase = new TestCaseReviewApiCase();
apiCase.setId(id);
apiCase.setStatus(status);
apiCase.setUpdateTime(System.currentTimeMillis());
apiCase.setUpdateTime(time);
testCaseReviewApiCaseMapper.updateByPrimaryKeySelective(apiCase);
}
public void updateByPrimaryKeySelective(TestCaseReviewApiCase apiCase) {

View File

@ -122,11 +122,11 @@ public class TestPlanApiCaseService {
return testPlanApiCaseMapper.selectByPrimaryKey(id);
}
public void setExecResult(String id, String status) {
public void setExecResult(String id, String status,Long time) {
TestPlanApiCase apiCase = new TestPlanApiCase();
apiCase.setId(id);
apiCase.setStatus(status);
apiCase.setUpdateTime(System.currentTimeMillis());
apiCase.setUpdateTime(time);
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
}

View File

@ -92,14 +92,14 @@ public class TestPlanScenarioCaseService {
}
public String run(RunScenarioRequest request) {
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andIdIn(request.getPlanCaseIds());
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
StringBuilder idStr = new StringBuilder();
request.getPlanCaseIds().forEach(item -> {
idStr.append("\"").append(item).append("\"").append(",");
});
List<TestPlanApiScenario> testPlanApiScenarioList =extTestPlanScenarioCaseMapper.selectByIds(idStr.toString().substring(0, idStr.toString().length() - 1), "\"" + org.apache.commons.lang3.StringUtils.join(request.getPlanCaseIds(), ",") + "\"");
List<String> scenarioIds = new ArrayList<>();
Map<String,String> scenarioIdApiScarionMap = new HashMap<>();
for (TestPlanApiScenario apiScenario:
testPlanApiScenarioList) {
for (TestPlanApiScenario apiScenario: testPlanApiScenarioList) {
scenarioIds.add(apiScenario.getApiScenarioId());
scenarioIdApiScarionMap.put(apiScenario.getApiScenarioId(),apiScenario.getId());
}

View File

@ -932,7 +932,7 @@ public class TestPlanService {
APIScenarioReportResult report = apiAutomationService.createScenarioReport(group.getName(),
planScenarioID + ":" + request.getTestPlanReportId(),
item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID());
request.getExecuteType(), item.getProjectId(), request.getReportUserID(),null);
group.setHashTree(scenarios);
testPlan.getHashTree().add(group);
apiScenarioReportMapper.insert(report);

View File

@ -162,27 +162,27 @@
</template>
<script>
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
import MsTag from "../../../common/components/MsTag";
import {downloadFile, getUUID, strMapToObj} from "@/common/js/utils";
import MsApiReportDetail from "../report/ApiReportDetail";
import MsTableMoreBtn from "./TableMoreBtn";
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
import MsTestPlanList from "./testplan/TestPlanList";
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
import BatchEdit from "../../../track/case/components/BatchEdit";
import {API_SCENARIO_LIST, PROJECT_NAME, WORKSPACE_ID} from "../../../../../common/js/constants";
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
import BatchMove from "../../../track/case/components/BatchMove";
import MsRunMode from "./common/RunMode";
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
import MsTag from "../../../common/components/MsTag";
import {downloadFile, getUUID, strMapToObj} from "@/common/js/utils";
import MsApiReportDetail from "../report/ApiReportDetail";
import MsTableMoreBtn from "./TableMoreBtn";
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
import MsTestPlanList from "./testplan/TestPlanList";
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import PriorityTableItem from "../../../track/common/tableItems/planview/PriorityTableItem";
import PlanStatusTableItem from "../../../track/common/tableItems/plan/PlanStatusTableItem";
import BatchEdit from "../../../track/case/components/BatchEdit";
import {API_SCENARIO_LIST, PROJECT_NAME, WORKSPACE_ID} from "../../../../../common/js/constants";
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
import BatchMove from "../../../track/case/components/BatchMove";
import MsRunMode from "./common/RunMode";
import {
import {
_filter,
_handleSelect,
_handleSelectAll,
@ -191,12 +191,12 @@ import {
getSelectDataCounts,
setUnSelectIds,
toggleAllSelection
} from "@/common/js/tableUtils";
import {Api_Scenario_List} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
} from "@/common/js/tableUtils";
import {Api_Scenario_List} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
export default {
export default {
name: "MsApiScenarioList",
components: {
HeaderLabelOperate,
@ -579,26 +579,8 @@ export default {
},
getReport() {
if (this.batchReportId) {
let url = "/api/scenario/report/get/" + this.batchReportId;
this.$get(url, response => {
this.report = response.data || {};
if (response.data) {
if (this.isNotRunning) {
try {
this.content = JSON.parse(this.report.content);
} catch (e) {
throw e;
}
this.result.loading = false;
this.$success("批量执行成功,请到报告页面查看详情!");
} else {
setTimeout(this.getReport, 2000)
}
} else {
this.result.loading = false;
this.$error(this.$t('api_report.not_exist'));
}
});
}
},
buildBatchParam(param) {
@ -610,7 +592,7 @@ export default {
this.$refs.runMode.open();
},
handleRunBatch(config){
handleRunBatch(config) {
this.infoDb = false;
let url = "/api/automation/run/batch";
let run = {config: config};
@ -812,36 +794,36 @@ export default {
});
},
}
}
}
</script>
<style scoped>
/deep/ .el-drawer__header {
/deep/ .el-drawer__header {
margin-bottom: 0px;
}
}
/deep/ .run-button {
/deep/ .run-button {
background-color: #409EFF;
border-color: #409EFF;
}
}
/deep/ .el-table__fixed-body-wrapper {
/deep/ .el-table__fixed-body-wrapper {
z-index: auto !important;
}
}
/deep/ .el-table__fixed-right {
/deep/ .el-table__fixed-right {
height: 100% !important;
}
}
/deep/ .el-table__fixed {
/deep/ .el-table__fixed {
height: 110px !important;
}
}
/deep/ .el-card__header {
/deep/ .el-card__header {
padding: 10px;
}
}
/deep/ .el-table__fixed-body-wrapper {
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
}
</style>

View File

@ -486,7 +486,6 @@ export default {
this.rowLoading = row.id;
this.$get('/api/testcase/get/' + row.caseId, (response) => {
console.log(response.data)
let apiCase = response.data;
let request = JSON.parse(apiCase.request);
request.name = row.id;
@ -512,7 +511,7 @@ export default {
request.name = row.id;
request.id = row.id;
request.useEnvironment = row.environmentId;
this.runData.push(request);
this.runData.unshift(request);
if (this.selectRows.size === index) {
resolve();
}

View File

@ -309,8 +309,6 @@ export default {
this.selectRows.forEach(row => {
this.buildExecuteParam(param,row);
});
console.log(param)
this.$post("/test/plan/scenario/case/run", param, response => {});
}
this.$message('任务执行中,请稍后刷新查看结果');