fix(测试计划): 修复多个测试计划关联同一个场景并发执行证书偶尔获取不到问题
Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
ebe66238a1
commit
352e466a30
|
@ -91,6 +91,7 @@ public class MsScenario extends MsTestElement {
|
||||||
HashTree scenarioTree = tree;
|
HashTree scenarioTree = tree;
|
||||||
// 取出自身场景环境
|
// 取出自身场景环境
|
||||||
ParameterConfig newConfig = new ParameterConfig(this.getProjectId(), false);
|
ParameterConfig newConfig = new ParameterConfig(this.getProjectId(), false);
|
||||||
|
newConfig.setReportId(config.getReportId());
|
||||||
if (this.isEnvironmentEnable()) {
|
if (this.isEnvironmentEnable()) {
|
||||||
this.setNewConfig(newConfig);
|
this.setNewConfig(newConfig);
|
||||||
newConfig.setRetryNum(config.getRetryNum());
|
newConfig.setRetryNum(config.getRetryNum());
|
||||||
|
|
|
@ -136,6 +136,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
|
sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName());
|
||||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
|
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
|
||||||
String resourceId = ElementUtil.setBaseParams(sampler, this.getParent(), config, this.getId(), this.getIndex());
|
String resourceId = ElementUtil.setBaseParams(sampler, this.getParent(), config, this.getId(), this.getIndex());
|
||||||
|
resourceId = StringUtils.isNotBlank(config.getReportId()) ? config.getReportId() : resourceId;
|
||||||
|
LogUtil.info("设置SSL证书配置{}", resourceId);
|
||||||
|
sampler.setProperty("MS-KEYSTORE-ID", resourceId);
|
||||||
|
|
||||||
sampler.setMethod(this.getMethod());
|
sampler.setMethod(this.getMethod());
|
||||||
sampler.setContentEncoding(StandardCharsets.UTF_8.name());
|
sampler.setContentEncoding(StandardCharsets.UTF_8.name());
|
||||||
|
@ -551,7 +554,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
keystoreConfig.setProperty("startIndex", 0);
|
keystoreConfig.setProperty("startIndex", 0);
|
||||||
keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PATH, msKeyStore.getPath());
|
keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PATH, msKeyStore.getPath());
|
||||||
keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PASSWORD, msKeyStore.getPassword());
|
keystoreConfig.setProperty(ElementConstants.MS_KEYSTORE_FILE_PASSWORD, msKeyStore.getPassword());
|
||||||
keystoreConfig.setProperty("MS-RESOURCE-ID", resourceId);
|
keystoreConfig.setProperty("MS-KEYSTORE-ID", resourceId);
|
||||||
httpSamplerTree.add(keystoreConfig);
|
httpSamplerTree.add(keystoreConfig);
|
||||||
config.getKeyStoreMap().put(this.getProjectId(), new MsKeyStore(msKeyStore.getPath(), msKeyStore.getPassword()));
|
config.getKeyStoreMap().put(this.getProjectId(), new MsKeyStore(msKeyStore.getPath(), msKeyStore.getPassword()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ public class ApiCaseSerialService {
|
||||||
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
||||||
config.setRetryNum(runRequest.getRetryNum());
|
config.setRetryNum(runRequest.getRetryNum());
|
||||||
}
|
}
|
||||||
|
config.setReportId(runRequest.getReportId());
|
||||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config);
|
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config);
|
||||||
LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId());
|
LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId());
|
||||||
return jmeterHashTree;
|
return jmeterHashTree;
|
||||||
|
|
|
@ -442,6 +442,7 @@ public class ApiScenarioExecuteService {
|
||||||
}
|
}
|
||||||
ParameterConfig config = new ParameterConfig(request.getProjectId(), false);
|
ParameterConfig config = new ParameterConfig(request.getProjectId(), false);
|
||||||
config.setScenarioId(request.getScenarioId());
|
config.setScenarioId(request.getScenarioId());
|
||||||
|
config.setReportId(request.getReportId());
|
||||||
if (MapUtils.isNotEmpty(request.getEnvironmentMap())) {
|
if (MapUtils.isNotEmpty(request.getEnvironmentMap())) {
|
||||||
apiScenarioEnvService.setEnvConfig(request.getEnvironmentMap(), config);
|
apiScenarioEnvService.setEnvConfig(request.getEnvironmentMap(), config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ public class GenerateHashTreeUtil {
|
||||||
config.setScenarioId(item.getId());
|
config.setScenarioId(item.getId());
|
||||||
config.setReportType(runRequest.getReportType());
|
config.setReportType(runRequest.getReportType());
|
||||||
config.setConfig(getEnv(scenario.getEnvironmentMap()));
|
config.setConfig(getEnv(scenario.getEnvironmentMap()));
|
||||||
|
config.setReportId(runRequest.getReportId());
|
||||||
|
|
||||||
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
||||||
config.setRetryNum(runRequest.getRetryNum());
|
config.setRetryNum(runRequest.getRetryNum());
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ public class ApiJMeterFileService {
|
||||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(remoteTestId, reportId, runMode, null);
|
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(remoteTestId, reportId, runMode, null);
|
||||||
runRequest.setReportType(reportType);
|
runRequest.setReportType(reportType);
|
||||||
runRequest.setQueueId(queueId);
|
runRequest.setQueueId(queueId);
|
||||||
|
runRequest.setReportId(reportId);
|
||||||
BooleanPool booleanPool = new BooleanPool();
|
BooleanPool booleanPool = new BooleanPool();
|
||||||
booleanPool.setK8s(true);
|
booleanPool.setK8s(true);
|
||||||
runRequest.setPool(booleanPool);
|
runRequest.setPool(booleanPool);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS
|
||||||
@Override
|
@Override
|
||||||
public void testEnded(String host) {
|
public void testEnded(String host) {
|
||||||
log.info("Destroying Keystore");
|
log.info("Destroying Keystore");
|
||||||
String resourceId = this.getPropertyAsString("MS-RESOURCE-ID");
|
String resourceId = this.getPropertyAsString("MS-KEYSTORE-ID");
|
||||||
SSLManager.getInstance().destroyKeystore(resourceId);
|
SSLManager.getInstance().destroyKeystore(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS
|
||||||
String path = this.getPropertyAsString("MS-KEYSTORE-FILE-PATH");
|
String path = this.getPropertyAsString("MS-KEYSTORE-FILE-PATH");
|
||||||
String password = this.getPropertyAsString("MS-KEYSTORE-FILE-PASSWORD");
|
String password = this.getPropertyAsString("MS-KEYSTORE-FILE-PASSWORD");
|
||||||
// 获取请求上的资源ID
|
// 获取请求上的资源ID
|
||||||
String resourceId = this.getPropertyAsString("MS-RESOURCE-ID");
|
String resourceId = this.getPropertyAsString("MS-KEYSTORE-ID");
|
||||||
if (StringUtils.isNotBlank(resourceId)) {
|
if (StringUtils.isNotBlank(resourceId)) {
|
||||||
KeystoreDTO dto = new KeystoreDTO();
|
KeystoreDTO dto = new KeystoreDTO();
|
||||||
dto.setStartIndex(startIndexAsInt);
|
dto.setStartIndex(startIndexAsInt);
|
||||||
|
|
|
@ -150,7 +150,7 @@ public abstract class SSLManager {
|
||||||
// 重新加载认证文件
|
// 重新加载认证文件
|
||||||
JMeterContext threadContext = JMeterContextService.getContext();
|
JMeterContext threadContext = JMeterContextService.getContext();
|
||||||
if (threadContext != null && threadContext.getCurrentSampler() != null) {
|
if (threadContext != null && threadContext.getCurrentSampler() != null) {
|
||||||
String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-RESOURCE-ID");
|
String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-KEYSTORE-ID");
|
||||||
if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) {
|
if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) {
|
||||||
log.info("重新加载认证文件{}", resourceId);
|
log.info("重新加载认证文件{}", resourceId);
|
||||||
KeystoreDTO dto = keyMap.get(resourceId);
|
KeystoreDTO dto = keyMap.get(resourceId);
|
||||||
|
@ -371,7 +371,7 @@ public abstract class SSLManager {
|
||||||
// 重新加载认证文件
|
// 重新加载认证文件
|
||||||
JMeterContext threadContext = JMeterContextService.getContext();
|
JMeterContext threadContext = JMeterContextService.getContext();
|
||||||
if (threadContext != null && threadContext.getCurrentSampler() != null) {
|
if (threadContext != null && threadContext.getCurrentSampler() != null) {
|
||||||
String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-RESOURCE-ID");
|
String resourceId = threadContext.getCurrentSampler().getPropertyAsString("MS-KEYSTORE-ID");
|
||||||
if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) {
|
if (StringUtils.isNotBlank(resourceId) && keyMap.containsKey(resourceId)) {
|
||||||
log.info("重新加载认证文件{}", resourceId);
|
log.info("重新加载认证文件{}", resourceId);
|
||||||
KeystoreDTO dto = keyMap.get(resourceId);
|
KeystoreDTO dto = keyMap.get(resourceId);
|
||||||
|
|
Loading…
Reference in New Issue