feat(接口测试): 场景定时任务模版增加免登录参数
--story=1010916 --user=王孝刚 接口场景列表定时任务通知模板支持配置报告链接免登录跳转 https://www.tapd.cn/55049933/s/1322348
This commit is contained in:
parent
c1be3798ff
commit
5da4ae7bff
|
@ -878,13 +878,13 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
private static MsTestElement getMqttElement(Object key, String className) {
|
||||
MsTestElement elementNode;
|
||||
try {
|
||||
Class<?> clazz = null;
|
||||
clazz = Class.forName(className);
|
||||
Class<?> clazz = Class.forName(className);
|
||||
Object instance = clazz.getConstructor().newInstance();
|
||||
Method methods2 = clazz.getMethod("importJmx", Object.class);
|
||||
Object invoke = methods2.invoke(instance, key);
|
||||
Method mqttMethod = clazz.getMethod("importJmx", Object.class);
|
||||
Object invoke = mqttMethod.invoke(instance, key);
|
||||
elementNode = (MsTestElement) invoke;
|
||||
} catch (Exception e) {
|
||||
LogUtil.info("MQTT反射方法报错", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return elementNode;
|
||||
|
|
|
@ -6,10 +6,7 @@ import io.metersphere.api.jmeter.utils.ReportStatusUtil;
|
|||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.PropertyConstant;
|
||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.enums.ApiReportStatus;
|
||||
import io.metersphere.commons.enums.ExecutionExecuteTypeEnum;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
|
@ -56,6 +53,8 @@ public class TestResultService {
|
|||
private ApiTestCaseService apiTestCaseService;
|
||||
@Resource
|
||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||
@Resource
|
||||
BaseShareInfoService baseShareInfoService;
|
||||
|
||||
// 场景
|
||||
private static final List<String> scenarioRunModes = new ArrayList<>() {{
|
||||
|
@ -275,7 +274,7 @@ public class TestResultService {
|
|||
String event = StringUtils.EMPTY;
|
||||
String successContext = "${operator}执行接口自动化成功: ${name}" + ", 报告: ${reportUrl}";
|
||||
String failedContext = "${operator}执行接口自动化失败: ${name}" + ", 报告: ${reportUrl}";
|
||||
|
||||
String shareUrl = getScenarioShareUrl(report.getId(), report.getUserId());
|
||||
if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())) {
|
||||
subject = "Jenkins任务通知";
|
||||
}
|
||||
|
@ -294,9 +293,19 @@ public class TestResultService {
|
|||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||
paramMap.put("reportUrl", reportUrl);
|
||||
paramMap.put("operator", report.getExecutor());
|
||||
paramMap.put("scenarioShareUrl", baseSystemConfigDTO.getUrl() + "/api/share-api-report" + shareUrl);
|
||||
paramMap.putAll(new BeanMap(report));
|
||||
paramMap.putAll(new BeanMap(scenario));
|
||||
NoticeModel noticeModel = NoticeModel.builder().operator(report.getUserId()).successContext(successContext).failedContext(failedContext).testId(testId).status(report.getStatus()).event(event).subject(subject).paramMap(paramMap).build();
|
||||
noticeSendService.send(report.getTriggerMode(), NoticeConstants.TaskType.API_DEFINITION_TASK, noticeModel);
|
||||
}
|
||||
|
||||
public String getScenarioShareUrl(String scenarioReportId, String userId) {
|
||||
ShareInfo shareRequest = new ShareInfo();
|
||||
shareRequest.setCustomData(scenarioReportId);
|
||||
shareRequest.setShareType(ShareType.API_REPORT.name());
|
||||
shareRequest.setCreateUserId(userId);
|
||||
ShareInfo shareInfo = baseShareInfoService.generateShareInfo(shareRequest);
|
||||
return baseShareInfoService.conversionShareInfoToDTO(shareInfo).getShareUrl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,10 @@ export default {
|
|||
label: this.$t('api_test.automation.scenario.principal'),
|
||||
value: 'principal',
|
||||
},
|
||||
{
|
||||
label: this.$t('report.plan_share_url'),
|
||||
value: 'scenarioShareUrl',
|
||||
},
|
||||
{
|
||||
label: this.$t('api_test.automation.step_total'),
|
||||
value: 'stepTotal',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum ShareType {
|
||||
Single, Batch, PLAN_REPORT, PLAN_DB_REPORT
|
||||
Single, Batch, PLAN_REPORT, PLAN_DB_REPORT, API_REPORT
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue