fix(接口测试): 恢复临界控制器修复同名锁问题
This commit is contained in:
parent
31154f55a4
commit
97db604539
|
@ -8,6 +8,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.dto.EnvironmentType;
|
import io.metersphere.api.dto.EnvironmentType;
|
||||||
|
import io.metersphere.api.dto.definition.request.controller.MsCriticalSectionController;
|
||||||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||||
import io.metersphere.api.dto.mockconfig.MockConfigStaticData;
|
import io.metersphere.api.dto.mockconfig.MockConfigStaticData;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
|
@ -158,7 +159,10 @@ public class MsScenario extends MsTestElement {
|
||||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
||||||
config.setVariables(this.variables);
|
config.setVariables(this.variables);
|
||||||
}
|
}
|
||||||
final HashTree scenarioTree = tree;
|
HashTree scenarioTree = tree;
|
||||||
|
if (config != null && !config.getExcludeScenarioIds().contains(this.getId())) {
|
||||||
|
scenarioTree = MsCriticalSectionController.createHashTree(tree, this.getName());
|
||||||
|
}
|
||||||
// 场景变量和环境变量
|
// 场景变量和环境变量
|
||||||
Arguments arguments = arguments(config);
|
Arguments arguments = arguments(config);
|
||||||
if (arguments != null) {
|
if (arguments != null) {
|
||||||
|
|
|
@ -67,6 +67,10 @@ public class ParameterConfig extends MsParameter {
|
||||||
private String scenarioId;
|
private String scenarioId;
|
||||||
|
|
||||||
private String reportType;
|
private String reportType;
|
||||||
|
/**
|
||||||
|
* 排除生成临界控制器的场景
|
||||||
|
*/
|
||||||
|
private List<String> excludeScenarioIds = new ArrayList<>();
|
||||||
|
|
||||||
private List<String> csvFilePaths = new ArrayList<>();
|
private List<String> csvFilePaths = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.apache.jmeter.testelement.TestElement;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MsCriticalSectionController extends MsTestElement {
|
public class MsCriticalSectionController extends MsTestElement {
|
||||||
|
|
||||||
|
@ -18,11 +19,21 @@ public class MsCriticalSectionController extends MsTestElement {
|
||||||
|
|
||||||
public static HashTree createHashTree(HashTree tree, String name) {
|
public static HashTree createHashTree(HashTree tree, String name) {
|
||||||
CriticalSectionController criticalSectionController = new CriticalSectionController();
|
CriticalSectionController criticalSectionController = new CriticalSectionController();
|
||||||
criticalSectionController.setName(StringUtils.isNotEmpty(name) ? "Csc_" + name : "Scenario Critical Section Controller");
|
criticalSectionController.setName(StringUtils.isNotEmpty(name) ? "Csc_" + name
|
||||||
criticalSectionController.setLockName("global_lock");
|
: "Scenario Critical Section Controller");
|
||||||
|
criticalSectionController.setLockName("global_lock_" + getUUID(8));
|
||||||
criticalSectionController.setEnabled(true);
|
criticalSectionController.setEnabled(true);
|
||||||
criticalSectionController.setProperty(TestElement.TEST_CLASS, CriticalSectionController.class.getName());
|
criticalSectionController.setProperty(TestElement.TEST_CLASS, CriticalSectionController.class.getName());
|
||||||
criticalSectionController.setProperty(TestElement.GUI_CLASS, "CriticalSectionControllerGui");
|
criticalSectionController.setProperty(TestElement.GUI_CLASS, "CriticalSectionControllerGui");
|
||||||
return tree.add(criticalSectionController);
|
return tree.add(criticalSectionController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUUID(int len) {
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
StringBuffer str = new StringBuffer();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
str.append(uuid.charAt(i));
|
||||||
|
}
|
||||||
|
return str.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -871,6 +871,7 @@ public class ApiAutomationService {
|
||||||
testPlan.setHashTree(new LinkedList<>());
|
testPlan.setHashTree(new LinkedList<>());
|
||||||
ParameterConfig config = new ParameterConfig();
|
ParameterConfig config = new ParameterConfig();
|
||||||
config.setOperating(true);
|
config.setOperating(true);
|
||||||
|
config.getExcludeScenarioIds().add(apiScenario.getId());
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MsScenario scenario = JSONObject.parseObject(apiScenario.getScenarioDefinition(), MsScenario.class);
|
MsScenario scenario = JSONObject.parseObject(apiScenario.getScenarioDefinition(), MsScenario.class);
|
||||||
|
|
Loading…
Reference in New Issue