Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fc43d9967f
|
@ -7,6 +7,7 @@ exemptLabels:
|
||||||
- lifecycle/frozen
|
- lifecycle/frozen
|
||||||
- pinned
|
- pinned
|
||||||
- security
|
- security
|
||||||
|
- plan
|
||||||
staleLabel: stale
|
staleLabel: stale
|
||||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
markComment: >
|
markComment: >
|
||||||
|
|
|
@ -78,11 +78,28 @@ public class MsScenario extends MsTestElement {
|
||||||
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
||||||
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||||
});
|
});
|
||||||
|
// 场景变量
|
||||||
|
if (StringUtils.isNotEmpty(element.getString("variables"))) {
|
||||||
|
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
|
||||||
|
new TypeReference<LinkedList<ScenarioVariable>>() {
|
||||||
|
});
|
||||||
|
this.setVariables(variables);
|
||||||
}
|
}
|
||||||
|
// 场景请求头
|
||||||
|
if (StringUtils.isNotEmpty(element.getString("headers"))) {
|
||||||
|
LinkedList<KeyValue> headers = mapper.readValue(element.getString("headers"),
|
||||||
|
new TypeReference<LinkedList<KeyValue>>() {
|
||||||
|
});
|
||||||
|
this.setHeaders(headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设置共享cookie
|
||||||
config.setEnableCookieShare(enableCookieShare);
|
config.setEnableCookieShare(enableCookieShare);
|
||||||
if (StringUtils.isNotEmpty(environmentId)) {
|
if (StringUtils.isNotEmpty(environmentId)) {
|
||||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||||
|
|
|
@ -151,7 +151,7 @@ public abstract class MsTestElement {
|
||||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
|
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(element.getId());
|
||||||
if (apiDefinition != null) {
|
if (apiDefinition != null) {
|
||||||
element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {
|
element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {
|
||||||
});
|
});
|
||||||
|
@ -159,6 +159,7 @@ public abstract class MsTestElement {
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
LogUtil.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.aspectj.util.FileUtil;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.dom4j.QName;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -582,11 +581,13 @@ public class APITestService {
|
||||||
for (Element itemElement : sampleProxyElementList) {
|
for (Element itemElement : sampleProxyElementList) {
|
||||||
if (isFromScenario) {
|
if (isFromScenario) {
|
||||||
testName = itemElement.attributeValue(attribute_testName);
|
testName = itemElement.attributeValue(attribute_testName);
|
||||||
|
if (StringUtils.isNotBlank(testName)) {
|
||||||
String[] testNameArr = testName.split(scenarioCaseNameSplit);
|
String[] testNameArr = testName.split(scenarioCaseNameSplit);
|
||||||
if (testNameArr.length > 0) {
|
if (testNameArr.length > 0) {
|
||||||
testName = testNameArr[0];
|
testName = testNameArr[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
itemElement.attribute(attribute_testName).setText(testName);
|
itemElement.attribute(attribute_testName).setText(testName);
|
||||||
|
|
||||||
//double的话有额外处理方式
|
//double的话有额外处理方式
|
||||||
|
|
|
@ -457,12 +457,15 @@ public class ApiAutomationService {
|
||||||
});
|
});
|
||||||
scenario.setHashTree(elements);
|
scenario.setHashTree(elements);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(element.getString("variables"))) {
|
if (element != null && StringUtils.isNotEmpty(element.getString("variables"))) {
|
||||||
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
|
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
|
||||||
new TypeReference<LinkedList<ScenarioVariable>>() {
|
new TypeReference<LinkedList<ScenarioVariable>>() {
|
||||||
});
|
});
|
||||||
scenario.setVariables(variables);
|
scenario.setVariables(variables);
|
||||||
}
|
}
|
||||||
|
if (scenario == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// 针对导入的jmx 处理
|
// 针对导入的jmx 处理
|
||||||
if (CollectionUtils.isNotEmpty(scenario.getHashTree()) && (scenario.getHashTree().get(0) instanceof MsJmeterElement)) {
|
if (CollectionUtils.isNotEmpty(scenario.getHashTree()) && (scenario.getHashTree().get(0) instanceof MsJmeterElement)) {
|
||||||
scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config);
|
scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config);
|
||||||
|
@ -879,9 +882,13 @@ public class ApiAutomationService {
|
||||||
// 生成jmx
|
// 生成jmx
|
||||||
List<ApiScenrioExportJmx> resList = new ArrayList<>();
|
List<ApiScenrioExportJmx> resList = new ArrayList<>();
|
||||||
apiScenarioWithBLOBs.forEach(item -> {
|
apiScenarioWithBLOBs.forEach(item -> {
|
||||||
|
if (StringUtils.isNotEmpty(item.getScenarioDefinition())) {
|
||||||
String jmx = generateJmx(item);
|
String jmx = generateJmx(item);
|
||||||
|
if (StringUtils.isNotEmpty(jmx)) {
|
||||||
ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true));
|
ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true));
|
||||||
resList.add(scenrioExportJmx);
|
resList.add(scenrioExportJmx);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return resList;
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
if (nodeNameEquals(ele, HASH_TREE_ELEMENT)) {
|
if (nodeNameEquals(ele, HASH_TREE_ELEMENT)) {
|
||||||
parseHashTree(ele);
|
parseHashTree(ele);
|
||||||
} else if (nodeNameEquals(ele, TEST_PLAN)) {
|
} else if (nodeNameEquals(ele, TEST_PLAN)) {
|
||||||
processSetupTestPlan(ele);
|
|
||||||
processCheckoutConfigTestElement(ele);
|
processCheckoutConfigTestElement(ele);
|
||||||
processCheckoutDnsCacheManager(ele);
|
processCheckoutDnsCacheManager(ele);
|
||||||
processCheckoutArguments(ele);
|
processCheckoutArguments(ele);
|
||||||
|
@ -483,88 +482,6 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processSetupTestPlan(Element ele) {
|
|
||||||
Document document = ele.getOwnerDocument();
|
|
||||||
Node hashTree = ele.getNextSibling();
|
|
||||||
while (!(hashTree instanceof Element)) {
|
|
||||||
hashTree = hashTree.getNextSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
KafkaProperties kafkaProperties = CommonBeanFactory.getBean(KafkaProperties.class);
|
|
||||||
String bootstrapServers = kafkaProperties.getBootstrapServers();
|
|
||||||
String[] servers = StringUtils.split(bootstrapServers, ",");
|
|
||||||
for (String s : servers) {
|
|
||||||
String[] ipAndPort = StringUtils.split(s, ":");
|
|
||||||
Element setupElement = document.createElement("SetupThreadGroup");
|
|
||||||
setupElement.setAttribute("guiclass", "SetupThreadGroupGui");
|
|
||||||
setupElement.setAttribute("testclass", "SetupThreadGroup");
|
|
||||||
setupElement.setAttribute("testname", "setUp Thread Group");
|
|
||||||
setupElement.setAttribute("enabled", "true");
|
|
||||||
setupElement.appendChild(createStringProp(document, "ThreadGroup.on_sample_error", "stoptestnow"));
|
|
||||||
Element elementProp = document.createElement("elementProp");
|
|
||||||
elementProp.setAttribute("name", "ThreadGroup.main_controller");
|
|
||||||
elementProp.setAttribute("elementType", "LoopController");
|
|
||||||
elementProp.setAttribute("guiclass", "LoopControlPanel");
|
|
||||||
elementProp.setAttribute("testclass", "LoopController");
|
|
||||||
elementProp.setAttribute("testname", "Loop Controller");
|
|
||||||
elementProp.setAttribute("enabled", "true");
|
|
||||||
elementProp.appendChild(createBoolProp(document, "LoopController.continue_forever", false));
|
|
||||||
elementProp.appendChild(createIntProp(document, "LoopController.loops", 1));
|
|
||||||
setupElement.appendChild(elementProp);
|
|
||||||
setupElement.appendChild(createStringProp(document, "ThreadGroup.num_threads", "1"));
|
|
||||||
setupElement.appendChild(createStringProp(document, "ThreadGroup.ramp_time", "1"));
|
|
||||||
setupElement.appendChild(createStringProp(document, "ThreadGroup.duration", ""));
|
|
||||||
setupElement.appendChild(createStringProp(document, "ThreadGroup.delay", ""));
|
|
||||||
setupElement.appendChild(createBoolProp(document, "ThreadGroup.scheduler", false));
|
|
||||||
setupElement.appendChild(createBoolProp(document, "ThreadGroup.same_user_on_next_iteration", true));
|
|
||||||
hashTree.appendChild(setupElement);
|
|
||||||
|
|
||||||
Element setupHashTree = document.createElement(HASH_TREE_ELEMENT);
|
|
||||||
|
|
||||||
Element tcpSampler = document.createElement("TCPSampler");
|
|
||||||
tcpSampler.setAttribute("guiclass", "TCPSamplerGui");
|
|
||||||
tcpSampler.setAttribute("testclass", "TCPSampler");
|
|
||||||
tcpSampler.setAttribute("testname", "TCP Sampler");
|
|
||||||
tcpSampler.setAttribute("enabled", "true");
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.classname", "TCPClientImpl"));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.server", ipAndPort[0]));
|
|
||||||
tcpSampler.appendChild(createBoolProp(document, "TCPSampler.reUseConnection", true));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.port", ipAndPort[1]));
|
|
||||||
tcpSampler.appendChild(createBoolProp(document, "TCPSampler.nodelay", false));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.timeout", "100"));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.ctimeout", "100"));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.request", "1010"));
|
|
||||||
tcpSampler.appendChild(createBoolProp(document, "TCPSampler.closeConnection", false));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "TCPSampler.EolByte", "0"));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "ConfigTestElement.username", ""));
|
|
||||||
tcpSampler.appendChild(createStringProp(document, "ConfigTestElement.password", ""));
|
|
||||||
|
|
||||||
Element tcpSamplerHashTree = document.createElement(HASH_TREE_ELEMENT);
|
|
||||||
|
|
||||||
Element responseAssertion = document.createElement("ResponseAssertion");
|
|
||||||
responseAssertion.setAttribute("guiclass", "AssertionGui");
|
|
||||||
responseAssertion.setAttribute("testclass", "ResponseAssertion");
|
|
||||||
responseAssertion.setAttribute("testname", "Response Assertion");
|
|
||||||
responseAssertion.setAttribute("enabled", "true");
|
|
||||||
Element collectionProp = document.createElement("collectionProp");
|
|
||||||
collectionProp.setAttribute("name", "Asserion.test_strings");
|
|
||||||
collectionProp.appendChild(createStringProp(document, "49586", "200"));
|
|
||||||
responseAssertion.appendChild(collectionProp);
|
|
||||||
responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", ""));
|
|
||||||
responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code"));
|
|
||||||
responseAssertion.appendChild(createBoolProp(document, "Assertion.assume_success", false));
|
|
||||||
responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 8));
|
|
||||||
tcpSamplerHashTree.appendChild(responseAssertion);
|
|
||||||
// 添加空的hashtree
|
|
||||||
tcpSamplerHashTree.appendChild(document.createElement(HASH_TREE_ELEMENT));
|
|
||||||
|
|
||||||
setupHashTree.appendChild(tcpSampler);
|
|
||||||
setupHashTree.appendChild(tcpSamplerHashTree);
|
|
||||||
|
|
||||||
hashTree.appendChild(setupHashTree);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Element createBoolProp(Document document, String name, boolean value) {
|
private Element createBoolProp(Document document, String name, boolean value) {
|
||||||
Element boolProp = document.createElement("boolProp");
|
Element boolProp = document.createElement("boolProp");
|
||||||
boolProp.setAttribute("name", name);
|
boolProp.setAttribute("name", name);
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<slot name="button"></slot>
|
<slot name="button"></slot>
|
||||||
<el-tooltip content="Copy" placement="top">
|
<el-tooltip content="Copy" placement="top">
|
||||||
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow"/>
|
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" :disabled="data.referenced==='REF' || data.disabled"/>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip :content="$t('commons.remove')" placement="top">
|
<el-tooltip :content="$t('commons.remove')" placement="top">
|
||||||
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove"/>
|
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" :disabled="data.referenced==='REF' || data.disabled"/>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
{{ apiCase.createTime | timestampFormatDate }}
|
{{ apiCase.createTime | timestampFormatDate }}
|
||||||
{{ apiCase.createUser }} {{ $t('api_test.definition.request.create_info') }}
|
{{ apiCase.createUser }} {{ $t('api_test.definition.request.create_info') }}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span style="margin-left: 10px">
|
||||||
{{ apiCase.updateTime | timestampFormatDate }}
|
{{ apiCase.updateTime | timestampFormatDate }}
|
||||||
{{ apiCase.updateUser }} {{ $t('api_test.definition.request.update_info') }}
|
{{ apiCase.updateUser }} {{ $t('api_test.definition.request.update_info') }}
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in New Issue