From 17777353252310cc6a41d7aad7f5500892fc25e6 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 28 Jan 2021 14:38:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BC=98=E5=8C=96=E6=8A=A5=E5=91=8A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/MsScenario.java | 3 ++ .../dto/definition/request/MsTestElement.java | 43 +++++++++++++++++-- .../request/controller/MsIfController.java | 2 + .../request/controller/MsLoopController.java | 2 + .../request/processors/MsJSR223Processor.java | 5 ++- .../request/sampler/MsDubboSampler.java | 5 ++- .../request/sampler/MsHTTPSamplerProxy.java | 5 ++- .../request/sampler/MsJDBCSampler.java | 5 ++- .../request/sampler/MsTCPSampler.java | 5 ++- 9 files changed, 67 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index c48ff30480..71cbff9d69 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -71,6 +71,7 @@ public class MsScenario extends MsTestElement { ex.printStackTrace(); } } + config.setStep(this.name); config.setStepType("SCENARIO"); config.setEnableCookieShare(enableCookieShare); @@ -91,6 +92,8 @@ public class MsScenario extends MsTestElement { this.addRandom(tree, variables); if (CollectionUtils.isNotEmpty(hashTree)) { for (MsTestElement el : hashTree) { + // 给所有孩子加一个父亲标志 + el.setParent(this); el.toHashTree(tree, el.getHashTree(), config); } } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 976edef4e2..add5e31f44 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -29,10 +29,12 @@ import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.base.domain.ApiDefinitionWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; +import io.metersphere.commons.constants.LoopConstants; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import lombok.Data; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.config.Arguments; import org.apache.jmeter.config.CSVDataSet; import org.apache.jmeter.config.RandomVariableConfig; @@ -96,7 +98,10 @@ public abstract class MsTestElement { @JSONField(ordinal = 10) private LinkedList hashTree; + private MsTestElement parent; + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; + // 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境 public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { for (MsTestElement el : hashTree) { @@ -173,7 +178,7 @@ public abstract class MsTestElement { return null; } - protected void addCsvDataSet(HashTree tree,List variables) { + protected void addCsvDataSet(HashTree tree, List variables) { if (CollectionUtils.isNotEmpty(variables)) { List list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { @@ -197,7 +202,7 @@ public abstract class MsTestElement { } } - protected void addCounter(HashTree tree,List variables) { + protected void addCounter(HashTree tree, List variables) { if (CollectionUtils.isNotEmpty(variables)) { List list = variables.stream().filter(ScenarioVariable::isCounterValid).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { @@ -219,7 +224,7 @@ public abstract class MsTestElement { } } - protected void addRandom(HashTree tree,List variables) { + protected void addRandom(HashTree tree, List variables) { if (CollectionUtils.isNotEmpty(variables)) { List list = variables.stream().filter(ScenarioVariable::isRandom).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { @@ -240,6 +245,38 @@ public abstract class MsTestElement { } } + public MsTestElement getRootParent(MsTestElement element) { + if (element.getParent() == null) { + return element; + } + if ("LoopController".equals(element.getType())) { + return element; + } + return getRootParent(element.getParent()); + } + + protected String getParentName(MsTestElement element) { + if (element != null) { + MsTestElement parent = this.getRootParent(element); + if (parent != null) { + if ("LoopController".equals(parent.getType())) { + MsLoopController loopController = (MsLoopController) parent; + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { + return "While 循环-" + "${LoopCounterConfigXXX}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) { + return "ForEach 循环-" + "${LoopCounterConfigXXX}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) { + return "次数循环-" + "${LoopCounterConfigXXX}"; + } + } + return parent.getName(); + } + return element.getName(); + } + return ""; + } } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index 3f351f1c25..61a22081cf 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -32,6 +32,8 @@ public class MsIfController extends MsTestElement { final HashTree groupTree = tree.add(ifController()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { + // 给所有孩子加一个父亲标志 + el.setParent(this); el.toHashTree(groupTree, el.getHashTree(), config); }); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 57f279adfa..e82c9b07bb 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -83,6 +83,8 @@ public class MsLoopController extends MsTestElement { if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { + // 给所有孩子加一个父亲标志 + el.setParent(this); el.toHashTree(groupTree, el.getHashTree(), config); }); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index af9da5e11f..82c37ab305 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -39,7 +39,10 @@ public class MsJSR223Processor extends MsTestElement { } else { processor.setName("JSR223Processor"); } - if (config != null && StringUtils.isNotEmpty(config.getStep())) { + String name = this.getParentName(this.getParent()); + if (StringUtils.isNotEmpty(name)) { + processor.setName(this.getName() + "<->" + name); + } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if ("SCENARIO".equals(config.getStepType())) { processor.setName(this.getName() + "<->" + config.getStep()); } else { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index df146c68c6..8c37f68bb1 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -77,7 +77,10 @@ public class MsDubboSampler extends MsTestElement { private DubboSample dubboSample(ParameterConfig config) { DubboSample sampler = new DubboSample(); sampler.setName(this.getName()); - if (config != null && StringUtils.isNotEmpty(config.getStep())) { + String name = this.getParentName(this.getParent()); + if (StringUtils.isNotEmpty(name)) { + sampler.setName(this.getName() + "<->" + name); + } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if ("SCENARIO".equals(config.getStepType())) { sampler.setName(this.getName() + "<->" + config.getStep()); } else { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 3852db12a7..8035e67fa3 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -97,7 +97,10 @@ public class MsHTTPSamplerProxy extends MsTestElement { HTTPSamplerProxy sampler = new HTTPSamplerProxy(); sampler.setEnabled(true); sampler.setName(this.getName()); - if (config != null && StringUtils.isNotEmpty(config.getStep())) { + String name = this.getParentName(this.getParent()); + if (StringUtils.isNotEmpty(name)) { + sampler.setName(this.getName() + "<->" + name); + } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if ("SCENARIO".equals(config.getStepType())) { sampler.setName(this.getName() + "<->" + config.getStep()); } else { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 554d8fb504..26146e3565 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -110,7 +110,10 @@ public class MsJDBCSampler extends MsTestElement { private JDBCSampler jdbcSampler(ParameterConfig config) { JDBCSampler sampler = new JDBCSampler(); sampler.setName(this.getName()); - if (config != null && StringUtils.isNotEmpty(config.getStep())) { + String name = this.getParentName(this.getParent()); + if (StringUtils.isNotEmpty(name)) { + sampler.setName(this.getName() + "<->" + name); + } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if ("SCENARIO".equals(config.getStepType())) { sampler.setName(this.getName() + "<->" + config.getStep()); } else { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 286c829027..aef95b9163 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -102,7 +102,10 @@ public class MsTCPSampler extends MsTestElement { private TCPSampler tcpSampler(ParameterConfig config) { TCPSampler tcpSampler = new TCPSampler(); tcpSampler.setName(this.getName()); - if (config != null && StringUtils.isNotEmpty(config.getStep())) { + String name = this.getParentName(this.getParent()); + if (StringUtils.isNotEmpty(name)) { + tcpSampler.setName(this.getName() + "<->" + name); + } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if ("SCENARIO".equals(config.getStepType())) { tcpSampler.setName(this.getName() + "<->" + config.getStep()); } else { From bacfd8fc641d8436d8f6ec2c10861b1e9ec34145 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 28 Jan 2021 14:47:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E7=99=BB=E5=85=A5=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=96=87=E5=AD=97=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/login/Login.vue | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index c121db1877..73a287cc60 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -8,7 +8,6 @@
- Metersphere {{ $t('commons.welcome') }}
@@ -283,11 +282,6 @@ export default { margin: 165px 0px; } -.welcome span:first-child { - font-weight: bold; - margin-right: 3px; -} -