refactor(接口测试): 脚本下载优化处理
This commit is contained in:
parent
5f700a5b44
commit
cac0150c9d
|
@ -51,7 +51,7 @@ public class ApiJmeterFileController {
|
||||||
byte[] bytes = apiJmeterFileService.downloadJmeterFiles(runMode, testId, reportId);
|
byte[] bytes = apiJmeterFileService.downloadJmeterFiles(runMode, testId, reportId);
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + testId + ".zip\"")
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + reportId + "_" + testId + ".zip\"")
|
||||||
.body(bytes);
|
.body(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
package io.metersphere.api.dto.definition.request.assertions.document;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.metersphere.vo.Condition;
|
|
||||||
import io.metersphere.vo.ElementCondition;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.jmeter.util.JMeterUtils;
|
|
||||||
import org.apache.oro.text.regex.Pattern;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DocumentUtils {
|
|
||||||
|
|
||||||
public static boolean documentChecked(Object subj, String condition, ThreadLocal<DecimalFormat> decimalFormatter) {
|
|
||||||
if (StringUtils.isNotEmpty(condition)) {
|
|
||||||
ElementCondition elementCondition = JSON.parseObject(condition, ElementCondition.class);
|
|
||||||
boolean isTrue = true;
|
|
||||||
if (CollectionUtils.isNotEmpty(elementCondition.getConditions())) {
|
|
||||||
for (Condition item : elementCondition.getConditions()) {
|
|
||||||
String expectedValue = item.getValue() != null ? item.getValue().toString() : "";
|
|
||||||
String resValue = objectToString(subj, decimalFormatter);
|
|
||||||
switch (item.getKey()) {
|
|
||||||
case "value_eq":
|
|
||||||
isTrue = StringUtils.equals(resValue, expectedValue);
|
|
||||||
break;
|
|
||||||
case "value_not_eq":
|
|
||||||
isTrue = !StringUtils.equals(resValue, expectedValue);
|
|
||||||
break;
|
|
||||||
case "value_in":
|
|
||||||
isTrue = StringUtils.contains(resValue, expectedValue);
|
|
||||||
break;
|
|
||||||
case "length_eq":
|
|
||||||
isTrue = getLength(subj, decimalFormatter) == numberOf(item.getValue());
|
|
||||||
break;
|
|
||||||
case "length_not_eq":
|
|
||||||
isTrue = getLength(subj, decimalFormatter) != numberOf(item.getValue());
|
|
||||||
break;
|
|
||||||
case "length_gt":
|
|
||||||
isTrue = getLength(subj, decimalFormatter) > numberOf(item.getValue());
|
|
||||||
break;
|
|
||||||
case "length_lt":
|
|
||||||
isTrue = getLength(subj, decimalFormatter) < numberOf(item.getValue());
|
|
||||||
break;
|
|
||||||
case "regular":
|
|
||||||
Pattern pattern = JMeterUtils.getPatternCache().getPattern(expectedValue);
|
|
||||||
isTrue = JMeterUtils.getMatcher().matches(resValue, pattern);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isTrue) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isTrue;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String objectToString(Object subj, ThreadLocal<DecimalFormat> decimalFormatter) {
|
|
||||||
String str;
|
|
||||||
if (subj == null) {
|
|
||||||
str = "null";
|
|
||||||
} else if (subj instanceof Map) {
|
|
||||||
str = new Gson().toJson(subj);
|
|
||||||
} else if (!(subj instanceof Double) && !(subj instanceof Float)) {
|
|
||||||
str = subj.toString();
|
|
||||||
} else {
|
|
||||||
str = ((DecimalFormat) decimalFormatter.get()).format(subj);
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static int getLength(Object value) {
|
|
||||||
if (value != null) {
|
|
||||||
if (value instanceof List) {
|
|
||||||
return ((List) value).size();
|
|
||||||
}
|
|
||||||
return value.toString().length();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getLength(Object value, ThreadLocal<DecimalFormat> decimalFormatter) {
|
|
||||||
if (value != null) {
|
|
||||||
if (value instanceof Map) {
|
|
||||||
return ((Map) value).size();
|
|
||||||
} else if (value instanceof List) {
|
|
||||||
return ((List) value).size();
|
|
||||||
} else if (!(value instanceof Double) && !(value instanceof Float)) {
|
|
||||||
return value.toString().length();
|
|
||||||
} else {
|
|
||||||
return ((DecimalFormat) decimalFormatter.get()).format(value).length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long numberOf(Object value) {
|
|
||||||
if (value != null) {
|
|
||||||
try {
|
|
||||||
return Long.parseLong(value.toString());
|
|
||||||
} catch (Exception e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String documentMsg(Object resValue, String condition) {
|
|
||||||
String msg = "";
|
|
||||||
if (StringUtils.isNotEmpty(condition)) {
|
|
||||||
ElementCondition elementCondition = JSON.parseObject(condition, ElementCondition.class);
|
|
||||||
if (CollectionUtils.isNotEmpty(elementCondition.getConditions())) {
|
|
||||||
for (Condition item : elementCondition.getConditions()) {
|
|
||||||
if (StringUtils.equalsAny(item.getKey(), "value_eq", "value_not_eq", "value_in")) {
|
|
||||||
msg = resValue != null ? resValue.toString() : "";
|
|
||||||
} else if (StringUtils.equalsAny(item.getKey(), "length_eq", "length_not_eq", "length_gt", "length_lt")) {
|
|
||||||
msg = "长度是:" + getLength(resValue) + "";
|
|
||||||
} else {
|
|
||||||
msg = resValue != null ? resValue.toString() : "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -150,6 +150,17 @@ public class ExecThreadPoolExecutor {
|
||||||
return workerQueue.stream().filter(task -> StringUtils.equals(((ExecTask) task).getRequest().getReportId(), reportId)).count() > 0;
|
return workerQueue.stream().filter(task -> StringUtils.equals(((ExecTask) task).getRequest().getReportId(), reportId)).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkPlanReport(String planReportId) {
|
||||||
|
// 检查缓冲区
|
||||||
|
Queue<JmeterRunRequestDTO> bufferQueue = msRejectedExecutionHandler.getBufferQueue();
|
||||||
|
if (CollectionUtils.isNotEmpty(bufferQueue)) {
|
||||||
|
return bufferQueue.stream().filter(task -> StringUtils.equals(task.getTestPlanReportId(), planReportId)).count() > 0;
|
||||||
|
}
|
||||||
|
// 检查等待队列
|
||||||
|
BlockingQueue workerQueue = threadPool.getQueue();
|
||||||
|
return workerQueue.stream().filter(task -> StringUtils.equals(((ExecTask) task).getRequest().getTestPlanReportId(), planReportId)).count() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorkerQueue() {
|
public String getWorkerQueue() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
BlockingQueue workerQueue = threadPool.getQueue();
|
BlockingQueue workerQueue = threadPool.getQueue();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.api.exec.schedule;
|
package io.metersphere.api.exec.schedule;
|
||||||
|
|
||||||
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
import io.metersphere.api.cache.TestPlanReportExecuteCatch;
|
||||||
|
import io.metersphere.api.exec.queue.ExecThreadPoolExecutor;
|
||||||
import io.metersphere.api.jmeter.MessageCache;
|
import io.metersphere.api.jmeter.MessageCache;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.track.service.TestPlanReportService;
|
import io.metersphere.track.service.TestPlanReportService;
|
||||||
|
@ -27,7 +28,9 @@ public class TestPlanReportListenerScheduled {
|
||||||
private void listener(String planReportId) {
|
private void listener(String planReportId) {
|
||||||
LoggerUtil.info("检查测试计划执行报告:【" + planReportId + "】");
|
LoggerUtil.info("检查测试计划执行报告:【" + planReportId + "】");
|
||||||
if (TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId) != null) {
|
if (TestPlanReportExecuteCatch.getTestPlanExecuteInfo(planReportId) != null) {
|
||||||
CommonBeanFactory.getBean(TestPlanReportService.class).countReport(planReportId);
|
if (!CommonBeanFactory.getBean(ExecThreadPoolExecutor.class).checkPlanReport(planReportId)) {
|
||||||
|
CommonBeanFactory.getBean(TestPlanReportService.class).countReport(planReportId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageCache.jobReportCache.remove(planReportId);
|
MessageCache.jobReportCache.remove(planReportId);
|
||||||
LoggerUtil.info("测试计划执行报告:【" + planReportId + "】执行完成,剩余队列:" + MessageCache.jobReportCache.size());
|
LoggerUtil.info("测试计划执行报告:【" + planReportId + "】执行完成,剩余队列:" + MessageCache.jobReportCache.size());
|
||||||
|
|
|
@ -3,7 +3,7 @@ package io.metersphere.api.jmeter;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import io.metersphere.api.service.ApiScenarioReportService;
|
import io.metersphere.api.service.ApiScenarioReportService;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -29,10 +29,10 @@ public class FixedTask {
|
||||||
if (MessageCache.concurrencyCounter != null && MessageCache.concurrencyCounter.size() > 0) {
|
if (MessageCache.concurrencyCounter != null && MessageCache.concurrencyCounter.size() > 0) {
|
||||||
for (String key : MessageCache.concurrencyCounter.keySet()) {
|
for (String key : MessageCache.concurrencyCounter.keySet()) {
|
||||||
ReportCounter counter = MessageCache.concurrencyCounter.get(key);
|
ReportCounter counter = MessageCache.concurrencyCounter.get(key);
|
||||||
LogUtil.info("集成报告:【" + key + "】总执行场景:【" + counter.getTestIds().size() + "】已经执行完成场景:【" + counter.getCompletedIds().size() + "】");
|
LoggerUtil.info("集成报告:【" + key + "】总执行场景:【" + counter.getTestIds().size() + "】已经执行完成场景:【" + counter.getCompletedIds().size() + "】");
|
||||||
List<String> filterList = counter.getTestIds().stream().filter(t -> !counter.getCompletedIds().contains(t)).collect(Collectors.toList());
|
List<String> filterList = counter.getTestIds().stream().filter(t -> !counter.getCompletedIds().contains(t)).collect(Collectors.toList());
|
||||||
|
|
||||||
LogUtil.debug("剩余要执行的报告" + JSON.toJSONString(filterList));
|
LoggerUtil.debug("剩余要执行的报告" + JSON.toJSONString(filterList));
|
||||||
// 合并
|
// 合并
|
||||||
if (counter.getCompletedIds().size() >= counter.getTestIds().size()) {
|
if (counter.getCompletedIds().size() >= counter.getTestIds().size()) {
|
||||||
scenarioReportService.margeReport(key);
|
scenarioReportService.margeReport(key);
|
||||||
|
@ -51,14 +51,14 @@ public class FixedTask {
|
||||||
// 资源池中已经没有执行的请求了
|
// 资源池中已经没有执行的请求了
|
||||||
int runningCount = scenarioReportService.get(key, counter);
|
int runningCount = scenarioReportService.get(key, counter);
|
||||||
if (runningCount == 0) {
|
if (runningCount == 0) {
|
||||||
LogUtil.error("发生未知异常,进行资源合并,请检查资源池是否正常运行");
|
LoggerUtil.error("发生未知异常,进行资源合并,请检查资源池是否正常运行");
|
||||||
scenarioReportService.margeReport(key);
|
scenarioReportService.margeReport(key);
|
||||||
guardTask.remove(key);
|
guardTask.remove(key);
|
||||||
MessageCache.concurrencyCounter.remove(key);
|
MessageCache.concurrencyCounter.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogUtil.error(ex.getMessage());
|
LoggerUtil.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,36 +195,38 @@ public class ApiDefinitionExecResultService {
|
||||||
Map<String, String> caseReportMap = new HashMap<>();
|
Map<String, String> caseReportMap = new HashMap<>();
|
||||||
boolean isFirst = true;
|
boolean isFirst = true;
|
||||||
int countExpectProcessResultCount = 0;
|
int countExpectProcessResultCount = 0;
|
||||||
for (RequestResult resultItem : requestResults) {
|
if (CollectionUtils.isNotEmpty(requestResults)) {
|
||||||
if (!StringUtils.startsWithAny(resultItem.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
for (RequestResult resultItem : requestResults) {
|
||||||
countExpectProcessResultCount++;
|
if (!StringUtils.startsWithAny(resultItem.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
||||||
|
countExpectProcessResultCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
LoggerUtil.info("接收到定时任务执行结果【 " + requestResults.size() + " 】");
|
||||||
LoggerUtil.info("接收到定时任务执行结果【 " + requestResults.size() + " 】");
|
|
||||||
|
|
||||||
for (RequestResult item : requestResults) {
|
for (RequestResult item : requestResults) {
|
||||||
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
||||||
ApiDefinitionExecResult saveResult = this.save(item, dto.getReportId(), dto.getConsole(), countExpectProcessResultCount, dto.getRunMode(), dto.getTestId(), isFirst);
|
ApiDefinitionExecResult saveResult = this.save(item, dto.getReportId(), dto.getConsole(), countExpectProcessResultCount, dto.getRunMode(), dto.getTestId(), isFirst);
|
||||||
String status = item.isSuccess() ? "success" : "error";
|
String status = item.isSuccess() ? "success" : "error";
|
||||||
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||||
TestPlanApiCase apiCase = testPlanApiCaseService.getById(dto.getTestId());
|
TestPlanApiCase apiCase = testPlanApiCaseService.getById(dto.getTestId());
|
||||||
if (apiCase != null) {
|
if (apiCase != null) {
|
||||||
apiCase.setStatus(status);
|
apiCase.setStatus(status);
|
||||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||||
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
|
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
testPlanApiCaseService.setExecResult(dto.getTestId(), status, item.getStartTime());
|
||||||
|
testCaseReviewApiCaseService.setExecResult(dto.getTestId(), status, item.getStartTime());
|
||||||
}
|
}
|
||||||
} else {
|
if (StringUtils.isNotEmpty(dto.getTestId())) {
|
||||||
testPlanApiCaseService.setExecResult(dto.getTestId(), status, item.getStartTime());
|
apiIdResultMap.put(dto.getTestId(), item.isSuccess() ? TestPlanApiExecuteStatus.SUCCESS.name() : TestPlanApiExecuteStatus.FAILD.name());
|
||||||
testCaseReviewApiCaseService.setExecResult(dto.getTestId(), status, item.getStartTime());
|
}
|
||||||
|
//更新报告ID
|
||||||
|
caseReportMap.put(dto.getTestId(), saveResult.getId());
|
||||||
|
isFirst = false;
|
||||||
|
// 串行队列
|
||||||
|
SerialBlockingQueueUtil.offer(dto, SerialBlockingQueueUtil.END_SIGN);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(dto.getTestId())) {
|
|
||||||
apiIdResultMap.put(dto.getTestId(), item.isSuccess() ? TestPlanApiExecuteStatus.SUCCESS.name() : TestPlanApiExecuteStatus.FAILD.name());
|
|
||||||
}
|
|
||||||
//更新报告ID
|
|
||||||
caseReportMap.put(dto.getTestId(), saveResult.getId());
|
|
||||||
isFirst = false;
|
|
||||||
// 串行队列
|
|
||||||
SerialBlockingQueueUtil.offer(dto, SerialBlockingQueueUtil.END_SIGN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateTestCaseStates(dto.getTestId());
|
updateTestCaseStates(dto.getTestId());
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class ApiJmeterFileService {
|
||||||
}
|
}
|
||||||
hashTree = GenerateHashTreeUtil.generateHashTree(scenario, reportId, planEnvMap);
|
hashTree = GenerateHashTreeUtil.generateHashTree(scenario, reportId, planEnvMap);
|
||||||
}
|
}
|
||||||
return zipFilesToByteArray(remoteTestId, hashTree);
|
return zipFilesToByteArray((reportId + "_" + remoteTestId), hashTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadJmeterJar() {
|
public byte[] downloadJmeterJar() {
|
||||||
|
|
|
@ -39,6 +39,12 @@
|
||||||
v-on:requestResult="requestResult"
|
v-on:requestResult="requestResult"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
<el-tab-pane name="console">
|
||||||
|
<template slot="label">
|
||||||
|
<span class="console">{{ $t('api_test.definition.request.console') }}</span>
|
||||||
|
</template>
|
||||||
|
<pre>{{ content.console }}</pre>
|
||||||
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
<ms-api-report-export
|
<ms-api-report-export
|
||||||
|
|
|
@ -23,65 +23,65 @@ export function STEP() {
|
||||||
['CustomizeReq', getDefaultSamplerMenu()],
|
['CustomizeReq', getDefaultSamplerMenu()],
|
||||||
['MaxSamplerProxy', getDefaultSamplerMenu()],
|
['MaxSamplerProxy', getDefaultSamplerMenu()],
|
||||||
['GenericController', getAll()],
|
['GenericController', getAll()],
|
||||||
['AllSamplerProxy', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "Sampler", "AbstractSampler","JSR223Processor"]],
|
['AllSamplerProxy', ['HTTPSamplerProxy', 'DubboSampler', 'JDBCSampler', 'TCPSampler', 'Sampler', 'AbstractSampler', 'JSR223Processor']],
|
||||||
['DEFINITION', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler"]],
|
['DEFINITION', ['HTTPSamplerProxy', 'DubboSampler', 'JDBCSampler', 'TCPSampler']],
|
||||||
['AllCanExecType', ["HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "JSR223Processor", "AbstractSampler"]]]);
|
['AllCanExecType', ['HTTPSamplerProxy', 'DubboSampler', 'JDBCSampler', 'TCPSampler', 'JSR223Processor', 'AbstractSampler']]]);
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ELEMENT_TYPE = {
|
export const ELEMENT_TYPE = {
|
||||||
scenario: "scenario",
|
scenario: 'scenario',
|
||||||
HTTPSamplerProxy: "HTTPSamplerProxy",
|
HTTPSamplerProxy: 'HTTPSamplerProxy',
|
||||||
OT_IMPORT: "OT_IMPORT",
|
OT_IMPORT: 'OT_IMPORT',
|
||||||
IfController: "IfController",
|
IfController: 'IfController',
|
||||||
TransactionController: "TransactionController",
|
TransactionController: 'TransactionController',
|
||||||
ConstantTimer: "ConstantTimer",
|
ConstantTimer: 'ConstantTimer',
|
||||||
JSR223Processor: "JSR223Processor",
|
JSR223Processor: 'JSR223Processor',
|
||||||
JSR223PreProcessor: "JSR223PreProcessor",
|
JSR223PreProcessor: 'JSR223PreProcessor',
|
||||||
JSR223PostProcessor: "JSR223PostProcessor",
|
JSR223PostProcessor: 'JSR223PostProcessor',
|
||||||
JDBCPostProcessor: "JDBCPostProcessor",
|
JDBCPostProcessor: 'JDBCPostProcessor',
|
||||||
JDBCPreProcessor: "JDBCPreProcessor",
|
JDBCPreProcessor: 'JDBCPreProcessor',
|
||||||
Assertions: "Assertions",
|
Assertions: 'Assertions',
|
||||||
Extract: "Extract",
|
Extract: 'Extract',
|
||||||
CustomizeReq: "CustomizeReq",
|
CustomizeReq: 'CustomizeReq',
|
||||||
LoopController: "LoopController",
|
LoopController: 'LoopController',
|
||||||
Plugin: "Plugin"
|
Plugin: 'Plugin'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TYPE_TO_C = new Map([
|
export const TYPE_TO_C = new Map([
|
||||||
['scenario', "io.metersphere.api.dto.definition.request.MsScenario"],
|
['scenario', 'io.metersphere.api.dto.definition.request.MsScenario'],
|
||||||
['HTTPSamplerProxy', "io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy"],
|
['HTTPSamplerProxy', 'io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy'],
|
||||||
['DubboSampler', "io.metersphere.api.dto.definition.request.sampler.MsDubboSampler"],
|
['DubboSampler', 'io.metersphere.api.dto.definition.request.sampler.MsDubboSampler'],
|
||||||
['JDBCSampler', "io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler"],
|
['JDBCSampler', 'io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler'],
|
||||||
['TCPSampler', "io.metersphere.api.dto.definition.request.sampler.MsTCPSampler"],
|
['TCPSampler', 'io.metersphere.api.dto.definition.request.sampler.MsTCPSampler'],
|
||||||
['IfController', "io.metersphere.api.dto.definition.request.controller.MsIfController"],
|
['IfController', 'io.metersphere.api.dto.definition.request.controller.MsIfController'],
|
||||||
['TransactionController', "io.metersphere.api.dto.definition.request.controller.MsTransactionController"],
|
['TransactionController', 'io.metersphere.api.dto.definition.request.controller.MsTransactionController'],
|
||||||
['LoopController', "io.metersphere.api.dto.definition.request.controller.MsLoopController"],
|
['LoopController', 'io.metersphere.api.dto.definition.request.controller.MsLoopController'],
|
||||||
['ConstantTimer', "io.metersphere.api.dto.definition.request.timer.MsConstantTimer"],
|
['ConstantTimer', 'io.metersphere.api.dto.definition.request.timer.MsConstantTimer'],
|
||||||
['JSR223Processor', "io.metersphere.api.dto.definition.request.processors.MsJSR223Processor"],
|
['JSR223Processor', 'io.metersphere.api.dto.definition.request.processors.MsJSR223Processor'],
|
||||||
['JSR223PreProcessor', "io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor"],
|
['JSR223PreProcessor', 'io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor'],
|
||||||
['JSR223PostProcessor', "io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor"],
|
['JSR223PostProcessor', 'io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor'],
|
||||||
['JDBCPreProcessor', "io.metersphere.api.dto.definition.request.processors.pre.MsJDBCPreProcessor"],
|
['JDBCPreProcessor', 'io.metersphere.api.dto.definition.request.processors.pre.MsJDBCPreProcessor'],
|
||||||
['JDBCPostProcessor', "io.metersphere.api.dto.definition.request.processors.post.MsJDBCPostProcessor"],
|
['JDBCPostProcessor', 'io.metersphere.api.dto.definition.request.processors.post.MsJDBCPostProcessor'],
|
||||||
['Assertions', "io.metersphere.api.dto.definition.request.assertions.MsAssertions"],
|
['Assertions', 'io.metersphere.api.dto.definition.request.assertions.MsAssertions'],
|
||||||
['Extract', "io.metersphere.api.dto.definition.request.extract.MsExtract"],
|
['Extract', 'io.metersphere.api.dto.definition.request.extract.MsExtract'],
|
||||||
['JmeterElement', "io.metersphere.api.dto.definition.request.unknown.MsJmeterElement"],
|
['JmeterElement', 'io.metersphere.api.dto.definition.request.unknown.MsJmeterElement'],
|
||||||
['TestPlan', "io.metersphere.api.dto.definition.request.MsTestPlan"],
|
['TestPlan', 'io.metersphere.api.dto.definition.request.MsTestPlan'],
|
||||||
['ThreadGroup', "io.metersphere.api.dto.definition.request.MsThreadGroup"],
|
['ThreadGroup', 'io.metersphere.api.dto.definition.request.MsThreadGroup'],
|
||||||
['DNSCacheManager', "io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager"],
|
['DNSCacheManager', 'io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager'],
|
||||||
['DebugSampler', "io.metersphere.api.dto.definition.request.sampler.MsDebugSampler"],
|
['DebugSampler', 'io.metersphere.api.dto.definition.request.sampler.MsDebugSampler'],
|
||||||
['AuthManager', "io.metersphere.api.dto.definition.request.auth.MsAuthManager"]
|
['AuthManager', 'io.metersphere.api.dto.definition.request.auth.MsAuthManager']
|
||||||
])
|
])
|
||||||
|
|
||||||
export const PLUGIN_ELEMENTS = new Map([
|
export const PLUGIN_ELEMENTS = new Map([
|
||||||
['menu_post_processors', ['HtmlExtractor', 'JMESPathExtractor', 'JSONPostProcessor', 'RegexExtractor', 'BoundaryExtractor', 'JSR223PostProcessor', 'Separator', 'JDBCPostProcessor', 'XPath2Extractor', 'XPathExtractor', 'ResultAction', 'DebugPostProcessor', 'BeanShellPostProcessor']],
|
['menu_post_processors', ['HtmlExtractor', 'JMESPathExtractor', 'JSONPostProcessor', 'RegexExtractor', 'BoundaryExtractor', 'JSR223PostProcessor', 'Separator', 'JDBCPostProcessor', 'XPath2Extractor', 'XPathExtractor', 'ResultAction', 'DebugPostProcessor', 'BeanShellPostProcessor']],
|
||||||
['menu_assertions', ["Assertions", "Extract", 'Assertion', 'JSONPathAssertion', 'SizeAssertion', 'JSR223Assertion', 'XPath2Assertion', 'Separator', 'HTMLAssertion', 'JMESPathAssertion', 'MD5HexAssertion', 'SMIMEAssertion', 'XMLSchemaAssertion', 'XMLAssertion', 'XPathAssertion', 'DurationAssertion', 'CompareAssertion', 'BeanShellAssertion']],
|
['menu_assertions', ['Assertions', 'Extract', 'Assertion', 'JSONPathAssertion', 'SizeAssertion', 'JSR223Assertion', 'XPath2Assertion', 'Separator', 'HTMLAssertion', 'JMESPathAssertion', 'MD5HexAssertion', 'SMIMEAssertion', 'XMLSchemaAssertion', 'XMLAssertion', 'XPathAssertion', 'DurationAssertion', 'CompareAssertion', 'BeanShellAssertion']],
|
||||||
['menu_listener', ['AbstractVisualizer', 'AbstractListener', 'ViewResultsFullVisualizer', 'SummaryReport', 'StatVisualizer', 'BackendListener', 'Separator', 'JSR223Listener', 'ResultSaver', 'RespTimeGraphVisualizer', 'GraphVisualizer', 'AssertionVisualizer', 'ComparisonVisualizer', 'StatGraphVisualizer', 'Summariser', 'TableVisualizer', 'SimpleDataWriter', 'MailerVisualizer', 'BeanShellListener']],
|
['menu_listener', ['AbstractVisualizer', 'AbstractListener', 'ViewResultsFullVisualizer', 'SummaryReport', 'StatVisualizer', 'BackendListener', 'Separator', 'JSR223Listener', 'ResultSaver', 'RespTimeGraphVisualizer', 'GraphVisualizer', 'AssertionVisualizer', 'ComparisonVisualizer', 'StatGraphVisualizer', 'Summariser', 'TableVisualizer', 'SimpleDataWriter', 'MailerVisualizer', 'BeanShellListener']],
|
||||||
['menu_pre_processors', ['AbstractPostProcessor', 'JSR223PreProcessor', 'UserParameters', 'Separator', 'AnchorModifier', 'URLRewritingModifier', 'JDBCPreProcessor', 'SampleTimeout', 'RegExUserParameters', 'BeanShellPreProcessor']],
|
['menu_pre_processors', ['AbstractPostProcessor', 'JSR223PreProcessor', 'UserParameters', 'Separator', 'AnchorModifier', 'URLRewritingModifier', 'JDBCPreProcessor', 'SampleTimeout', 'RegExUserParameters', 'BeanShellPreProcessor']],
|
||||||
['menu_logic_controller', ['GenericController', "IfController", "LoopController", 'IfControllerPanel', 'TransactionController', 'LoopControlPanel', 'WhileController', 'Separator', 'ForeachControlPanel', 'IncludeController', 'RunTime', 'CriticalSectionController', 'InterleaveControl', 'OnceOnlyController', 'RecordController', 'LogicController', 'RandomControl', 'RandomOrderController', 'ThroughputController', 'SwitchController', 'ModuleController']],
|
['menu_logic_controller', ['GenericController', 'scenario', 'IfController', 'LoopController', 'IfControllerPanel', 'TransactionController', 'LoopControlPanel', 'WhileController', 'Separator', 'ForeachControlPanel', 'IncludeController', 'RunTime', 'CriticalSectionController', 'InterleaveControl', 'OnceOnlyController', 'RecordController', 'LogicController', 'RandomControl', 'RandomOrderController', 'ThroughputController', 'SwitchController', 'ModuleController']],
|
||||||
['menu_fragments', ['TestFragmentController']],
|
['menu_fragments', ['TestFragmentController']],
|
||||||
['menu_non_test_elements', ['ProxyControl', 'HttpMirrorControl', 'GenerateTree', 'PropertyControl']],
|
['menu_non_test_elements', ['ProxyControl', 'HttpMirrorControl', 'GenerateTree', 'PropertyControl']],
|
||||||
['menu_generative_controller', ["HTTPSamplerProxy", "JSR223Processor", "DubboSampler", "JDBCSampler", "TCPSampler", "Sampler", 'AbstractSampler', 'CustomizeReq', 'HttpTestSample', 'TestAction', 'DebugSampler', 'JSR223Sampler', 'Separator', 'AjpSampler', 'AccessLogSampler', 'BeanShellSampler', 'BoltSampler', 'FtpTestSampler', 'GraphQLHTTPSampler', 'JDBCSampler', 'JMSPublisher', 'JMSSampler', 'JMSSubscriber', 'JUnitTestSampler', 'JavaTestSampler', 'LdapExtTestSampler', 'LdapTestSampler', 'SystemSampler', 'SmtpSampler', 'TCPSampler', 'MailReaderSampler']],
|
['menu_generative_controller', ['HTTPSamplerProxy', 'JSR223Processor', 'DubboSampler', 'JDBCSampler', 'TCPSampler', 'Sampler', 'AbstractSampler', 'CustomizeReq', 'HttpTestSample', 'TestAction', 'DebugSampler', 'JSR223Sampler', 'Separator', 'AjpSampler', 'AccessLogSampler', 'BeanShellSampler', 'BoltSampler', 'FtpTestSampler', 'GraphQLHTTPSampler', 'JDBCSampler', 'JMSPublisher', 'JMSSampler', 'JMSSubscriber', 'JUnitTestSampler', 'JavaTestSampler', 'LdapExtTestSampler', 'LdapTestSampler', 'SystemSampler', 'SmtpSampler', 'TCPSampler', 'MailReaderSampler']],
|
||||||
['menu_threads', ['SetupThreadGroup', 'PostThreadGroup', 'ThreadGroup']],
|
['menu_threads', ['SetupThreadGroup', 'PostThreadGroup', 'ThreadGroup']],
|
||||||
['menu_timer', ['ConstantTimer', 'UniformRandomTimer', 'PreciseThroughputTimer', 'ConstantThroughputTimer', 'Separator', 'JSR223Timer', 'SyncTimer', 'PoissonRandomTimer', 'GaussianRandomTimer', 'BeanShellTimer']],
|
['menu_timer', ['ConstantTimer', 'UniformRandomTimer', 'PreciseThroughputTimer', 'ConstantThroughputTimer', 'Separator', 'JSR223Timer', 'SyncTimer', 'PoissonRandomTimer', 'GaussianRandomTimer', 'BeanShellTimer']],
|
||||||
['menu_config_element', ['CSVDataSet', 'HeaderPanel', 'CookiePanel', 'CacheManager', 'HttpDefaults', 'Separator', 'BoltConnectionElement', 'DNSCachePanel', 'FtpConfig', 'AuthPanel', 'DataSourceElement', 'JavaConfig', 'LdapExtConfig', 'LdapConfig', 'TCPConfig', 'KeystoreConfig', 'ArgumentsPanel', 'LoginConfig', 'SimpleConfig', 'CounterConfig', 'RandomVariableConfig']],
|
['menu_config_element', ['CSVDataSet', 'HeaderPanel', 'CookiePanel', 'CacheManager', 'HttpDefaults', 'Separator', 'BoltConnectionElement', 'DNSCachePanel', 'FtpConfig', 'AuthPanel', 'DataSourceElement', 'JavaConfig', 'LdapExtConfig', 'LdapConfig', 'TCPConfig', 'KeystoreConfig', 'ArgumentsPanel', 'LoginConfig', 'SimpleConfig', 'CounterConfig', 'RandomVariableConfig']],
|
||||||
|
@ -102,7 +102,7 @@ export function init() {
|
||||||
let allArray = [];
|
let allArray = [];
|
||||||
allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_generative_controller'));
|
allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_generative_controller'));
|
||||||
allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_logic_controller'));
|
allArray = allArray.concat(PLUGIN_ELEMENTS.get('menu_logic_controller'));
|
||||||
allArray = allArray.concat(["scenario", "ConstantTimer", "JSR223Processor"]);
|
allArray = allArray.concat(['scenario', 'ConstantTimer', 'JSR223Processor']);
|
||||||
return allArray;
|
return allArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,27 +2,23 @@
|
||||||
<el-header style="width: 100% ;padding: 0px">
|
<el-header style="width: 100% ;padding: 0px">
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="api.protocol==='HTTP'? 7:9">
|
<el-col :span="1">
|
||||||
<el-tooltip :content="api.name">
|
|
||||||
<span class="ms-col-name"> {{api.name}}</span>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="api.protocol==='HTTP'? 6:8">
|
|
||||||
<el-tag size="mini" :style="{'background-color': getColor(true, api.method), border: getColor(true, api.method)}" class="api-el-tag">
|
<el-tag size="mini" :style="{'background-color': getColor(true, api.method), border: getColor(true, api.method)}" class="api-el-tag">
|
||||||
{{ api.method}}
|
{{ api.method }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="api.protocol==='HTTP'? 4:0">
|
<el-col :span="9">
|
||||||
<div class="variable-combine" style="margin-left: 10px">{{api.path ===null ? " " : api.path}}</div>
|
<div class="variable-combine"> {{ api.name }}</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="9">
|
||||||
|
<div class="variable-combine" style="margin-left: 10px">{{ api.path === null ? " " : api.path }}</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="5">
|
<el-col :span="5">
|
||||||
<div>
|
<ms-environment-select
|
||||||
<ms-environment-select
|
:project-id="projectId"
|
||||||
:project-id="projectId"
|
:is-read-only="isReadOnly"
|
||||||
:is-read-only="isReadOnly"
|
:useEnvironment='useEnvironment'
|
||||||
:useEnvironment='useEnvironment'
|
@setEnvironment="setEnvironment" ref="environmentSelect"/>
|
||||||
@setEnvironment="setEnvironment" ref="environmentSelect"/>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -31,112 +27,113 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
|
||||||
import MsTag from "../../../../common/components/MsTag";
|
import MsTag from "../../../../common/components/MsTag";
|
||||||
import MsEnvironmentSelect from "./MsEnvironmentSelect";
|
import MsEnvironmentSelect from "./MsEnvironmentSelect";
|
||||||
import {API_METHOD_COLOUR} from "../../model/JsonData";
|
import {API_METHOD_COLOUR} from "../../model/JsonData";
|
||||||
export default {
|
|
||||||
name: "ApiCaseHeader",
|
export default {
|
||||||
components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig},
|
name: "ApiCaseHeader",
|
||||||
data() {
|
components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig},
|
||||||
return {
|
data() {
|
||||||
methodColorMap: new Map(API_METHOD_COLOUR),
|
return {
|
||||||
}
|
methodColorMap: new Map(API_METHOD_COLOUR),
|
||||||
},
|
}
|
||||||
props: {
|
},
|
||||||
api: Object,
|
props: {
|
||||||
projectId: String,
|
api: Object,
|
||||||
priorities: Array,
|
projectId: String,
|
||||||
isReadOnly: Boolean,
|
priorities: Array,
|
||||||
useEnvironment: String,
|
isReadOnly: Boolean,
|
||||||
isCaseEdit: Boolean,
|
useEnvironment: String,
|
||||||
condition: {
|
isCaseEdit: Boolean,
|
||||||
type: Object,
|
condition: {
|
||||||
default() {
|
type: Object,
|
||||||
return {}
|
default() {
|
||||||
},
|
return {}
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
refreshEnvironment(){
|
|
||||||
this.$refs.environmentSelect.refreshEnvironment();
|
|
||||||
},
|
|
||||||
setEnvironment(data) {
|
|
||||||
if(data){
|
|
||||||
this.$emit('setEnvironment', data.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
open() {
|
|
||||||
this.$refs.searchBar.open();
|
|
||||||
},
|
|
||||||
addCase() {
|
|
||||||
this.$emit('addCase');
|
|
||||||
this.refreshEnvironment();
|
|
||||||
},
|
|
||||||
getColor(enable, method) {
|
|
||||||
if (enable) {
|
|
||||||
return this.methodColorMap.get(method);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
refreshEnvironment() {
|
||||||
|
this.$refs.environmentSelect.refreshEnvironment();
|
||||||
|
},
|
||||||
|
setEnvironment(data) {
|
||||||
|
if (data) {
|
||||||
|
this.$emit('setEnvironment', data.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
open() {
|
||||||
|
this.$refs.searchBar.open();
|
||||||
|
},
|
||||||
|
addCase() {
|
||||||
|
this.$emit('addCase');
|
||||||
|
this.refreshEnvironment();
|
||||||
|
},
|
||||||
|
getColor(enable, method) {
|
||||||
|
if (enable) {
|
||||||
|
return this.methodColorMap.get(method);
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.el-card-btn {
|
.el-card-btn {
|
||||||
float: right;
|
float: right;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: 0 0;
|
background: 0 0;
|
||||||
border: none;
|
border: none;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.variable-combine {
|
.variable-combine {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-col {
|
.el-col {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-api-header-select {
|
.ms-api-header-select {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-col {
|
.el-col {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.api-el-tag {
|
.api-el-tag {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-all {
|
.select-all {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-col-name {
|
.ms-col-name {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0 5px;
|
margin: 0 5px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue