From 26bd6003ae560ccd46b3faaa70f7abc1b2606ea9 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 21 Mar 2023 14:58:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=B1=E8=B4=A5=E9=87=8D=E8=AF=95=E5=81=B6?= =?UTF-8?q?=E5=8F=91=E6=88=90=E5=8A=9F=E8=AF=B7=E6=B1=82=E4=B9=9F=E8=A2=AB?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fit2-zhao --- .../controller/MsRetryLoopController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsRetryLoopController.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsRetryLoopController.java index f40221243d..3742de7da7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsRetryLoopController.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsRetryLoopController.java @@ -52,7 +52,24 @@ public class MsRetryLoopController extends MsTestElement { } private String script() { - String script = "// 失败重试控制\n" + "try{\n" + "\tint errorCount = prev.getErrorCount();\n" + "\tif(errorCount == 0 && prev.getFirstAssertionFailureMessage() == null ){\n" + "\t vars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "\t}\n" + "\tif(vars.get(\"" + ms_current_timer + "_num\") == null){\n" + "\t\tvars.put(\"" + ms_current_timer + "_num\", \"0\");\n" + "\t}else{\n" + "\t\tint retryNum= Integer.parseInt(vars.get(\"" + ms_current_timer + "_num\"));\n" + "\t\tlog.info(\"重试:\"+ retryNum);\n" + " \tprev.setSampleLabel(\"MsRetry_\"+ (retryNum + 1) + \"_\" + prev.getSampleLabel());\n" + "\t\tretryNum =retryNum +1;\n" + "\t\tvars.put(\"" + ms_current_timer + "_num\",retryNum + \"\");\n" + "\t}\n" + "\tif(vars.get(\"" + ms_current_timer + "_num\").equals( \"" + retryNum + "\")){\n" + "\t\tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "\t}\n" + "}catch (Exception e){\n" + "\tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "}\n"; + String script = "import org.apache.commons.lang3.StringUtils;" + + "\n// 失败重试控制" + + "\n" + "try{" + + "\n" + "\tint errorCount = prev.getErrorCount();" + + "\n" + "\tif(errorCount == 0 && StringUtils.isBlank(prev.getFirstAssertionFailureMessage()) ){" + + "\n" + "\t vars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "\t}" + + "\n" + "\tif(vars.get(\"" + ms_current_timer + "_num\") == null){" + + "\n" + "\t\tvars.put(\"" + ms_current_timer + "_num\", \"0\");" + + "\n" + "\t}else{" + + "\n" + "\t\tint retryNum= Integer.parseInt(vars.get(\"" + ms_current_timer + "_num\"));" + + "\n" + "\t\tlog.info(\"重试:\"+ retryNum);" + + "\n" + " \tprev.setSampleLabel(\"MsRetry_\"+ (retryNum + 1) + \"_\" + prev.getSampleLabel());" + + "\n" + "\t\tretryNum =retryNum +1;\n" + "\t\tvars.put(\"" + ms_current_timer + "_num\",retryNum + \"\");\n" + "\t}" + + "\n" + "\tif(vars.get(\"" + ms_current_timer + "_num\").equals( \"" + retryNum + "\")){" + + "\n" + "\t\tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "\t}" + + "\n" + "}catch (Exception e){" + + "\n" + "\tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" + "}" + + "\n"; return script; }