diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsLoopControllerConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsLoopControllerConverter.java index 25eeb66892..5d4394c858 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsLoopControllerConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsLoopControllerConverter.java @@ -3,16 +3,14 @@ package io.metersphere.api.parser.jmeter; import io.metersphere.api.dto.request.controller.LoopType; import io.metersphere.api.dto.request.controller.MsLoopController; import io.metersphere.api.dto.request.controller.WhileConditionType; -import io.metersphere.api.parser.jmeter.processor.ScriptFilter; import io.metersphere.plugin.api.dto.ParameterConfig; import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter; -import io.metersphere.project.constants.ScriptLanguageType; import io.metersphere.sdk.util.LogUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.control.*; -import org.apache.jmeter.modifiers.JSR223PreProcessor; import org.apache.jmeter.protocol.java.sampler.JSR223Sampler; +import org.apache.jmeter.sampler.TestAction; import org.apache.jmeter.save.SaveService; import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.timers.ConstantTimer; @@ -43,6 +41,21 @@ public class MsLoopControllerConverter extends AbstractJmeterElementConverter" + element.getWhileController().getTimeout() + ")}"; + IfController ifController = ifController(ifCondition, element.getEnable()); + TestAction testAction = new TestAction(); + testAction.setEnabled(true); + testAction.setName("结束循环"); + testAction.setProperty("ActionProcessor.action", 5); + testAction.setProperty(TestElement.TEST_CLASS, TestAction.class.getName()); + testAction.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestActionGui")); + testAction.setProperty("ActionProcessor.target",0); + + groupTree.add(ifController, testAction); + } + } @@ -64,23 +77,9 @@ public class MsLoopControllerConverter extends AbstractJmeterElementConverter %s ){ - vars.put("%s", "stop"); - log.info( "结束循环"); - } - }catch (Exception e){ - log.info( e.getMessage()); - vars.put("%s", "stop"); - } - - """; - - return String.format(script, element.getCurrentTime(), element.getCurrentTime(), element.getCurrentTime(), element.getWhileController().getTimeout(), element.getCurrentTime(), element.getCurrentTime()); - } private void addPreProc(HashTree hashTree, MsLoopController element) { JSR223Sampler sampler = new JSR223Sampler(); sampler.setName("MS_CLEAR_LOOPS_VAR_" + element.getCurrentTime()); sampler.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName()); sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); - sampler.setProperty("scriptLanguage", ScriptLanguageType.BEANSHELL.name().toLowerCase()); - ScriptFilter.verify(ScriptLanguageType.BEANSHELL.name().toLowerCase(), element.getName(), script(element)); - sampler.setProperty("script", "vars.put(\"" + element.getCurrentTime() + "\", null);"); + sampler.setProperty("script", "${__time(,\"" + element.getCurrentTime() + "\")};"); hashTree.add(sampler); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/extract/JSONPathExtractConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/extract/JSONPathExtractConverter.java index 450b83dd74..4d6e20b500 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/extract/JSONPathExtractConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/extract/JSONPathExtractConverter.java @@ -23,6 +23,7 @@ public class JSONPathExtractConverter extends ExtractConverter extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass(JSON_POST_PROCESSOR_GUI)); extractor.setRefNames(msExtract.getVariableName()); extractor.setJsonPathExpressions(msExtract.getExpression()); + extractor.setProperty("JSONPostProcessor.compute_concat", true); // 处理匹配多条等匹配规则 extractor.setMatchNumbers(parseResultMatchingRule(msExtract).toString()); extractor.setEnabled(msExtract.getEnable()); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java index 2307be96e5..416cb9f3c5 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java @@ -238,6 +238,9 @@ public class ApiReportService { List apiReportSteps = new ArrayList<>(); apiReportSteps.add(apiReportStepDTO); apiReportDTO.setChildren(apiReportSteps); + } else { + apiReportDTO.setTotal(1L); + apiReportDTO.setPendingCount(1L); } return apiReportDTO; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java index 6c4fa9f4f9..d042f5cc6e 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java @@ -5,7 +5,6 @@ import com.github.pagehelper.page.PageMethod; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.exception.MSException; -import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.Organization; import io.metersphere.system.domain.Schedule; @@ -23,7 +22,6 @@ import org.quartz.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.lang.reflect.Method; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -205,25 +203,10 @@ public class TaskCenterService { public void enable(String id) { Schedule schedule = checkScheduleExit(id); - //根据全路径获取类 通过反射获取类 schedule.setEnable(!schedule.getEnable()); scheduleService.editSchedule(schedule); - try { - String className = schedule.getJob(); - Class clazz = Class.forName(className); - Object instance = clazz.getDeclaredConstructor().newInstance(); - - // 调用无参方法 - Method method = clazz.getMethod("getTriggerKey", String.class); - Object result = method.invoke(instance, schedule.getResourceId()); - - Method method1 = clazz.getMethod("getJobKey", String.class); - Object result1 = method1.invoke(instance, schedule.getResourceId()); - - scheduleService.addOrUpdateCronJob(schedule, (JobKey) result1, (TriggerKey) result, clazz); - } catch (Exception e) { - LogUtils.error("enable schedule error", e); - } + scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()), + new TriggerKey(schedule.getKey(),schedule.getJob()), schedule.getJob().getClass()); } diff --git a/frontend/src/views/api-test/components/condition/content.vue b/frontend/src/views/api-test/components/condition/content.vue index 1019d156c7..f878eddde1 100644 --- a/frontend/src/views/api-test/components/condition/content.vue +++ b/frontend/src/views/api-test/components/condition/content.vue @@ -339,6 +339,7 @@ :min="0" :precision="0" :max="600000" + :default-value="1000" class="w-[160px]" model-event="input" /> diff --git a/frontend/src/views/api-test/components/fastExtraction/moreSetting.vue b/frontend/src/views/api-test/components/fastExtraction/moreSetting.vue index 7aace8c3f7..713f452ce6 100644 --- a/frontend/src/views/api-test/components/fastExtraction/moreSetting.vue +++ b/frontend/src/views/api-test/components/fastExtraction/moreSetting.vue @@ -29,7 +29,7 @@ -
+
{{ t('apiTestDebug.resultMatchRule') }}
@@ -116,7 +116,6 @@ const props = defineProps<{ config: ExpressionConfig; isPopover?: boolean; // 是否是弹出框展示,弹出框展示时才显示表达式类型 - isShowResultMatchRules?: boolean; }>(); const emit = defineEmits<{ (e: 'update:config', config: ExpressionConfig): void; diff --git a/frontend/src/views/api-test/scenario/components/config.ts b/frontend/src/views/api-test/scenario/components/config.ts index 952610f6d7..d1658d8d7c 100644 --- a/frontend/src/views/api-test/scenario/components/config.ts +++ b/frontend/src/views/api-test/scenario/components/config.ts @@ -48,7 +48,7 @@ export const defaultConditionController = { // 条件控制器 export const defaultTimeController = { - delay: 0, // 等待时间 + delay: 1000, // 等待时间 }; // 场景配置