--bug=1007555 --user=宋天阳 测试计划定时任务-设置环境参数错误 https://www.tapd.cn/55049933/s/1061753;--bug=1007479 --user=宋天阳 服务集成中的提示图片无法显示 https://www.tapd.cn/55049933/s/1061758
This commit is contained in:
parent
57ffb143bd
commit
dda3915812
|
@ -7,6 +7,8 @@ import io.metersphere.api.service.MsResultService;
|
||||||
import io.metersphere.api.service.TestResultService;
|
import io.metersphere.api.service.TestResultService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jmeter.samplers.SampleResult;
|
import org.apache.jmeter.samplers.SampleResult;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -31,6 +33,8 @@ public class APIBackendListenerHandler {
|
||||||
@Resource
|
@Resource
|
||||||
private MsResultService resultService;
|
private MsResultService resultService;
|
||||||
|
|
||||||
|
Logger testPlanLog = LoggerFactory.getLogger("testPlanExecuteLog");
|
||||||
|
|
||||||
public void handleTeardownTest(List<SampleResult> queue, String runMode, String testId, String debugReportId) throws Exception {
|
public void handleTeardownTest(List<SampleResult> queue, String runMode, String testId, String debugReportId) throws Exception {
|
||||||
TestResult testResult = new TestResult();
|
TestResult testResult = new TestResult();
|
||||||
testResult.setTestId(testId);
|
testResult.setTestId(testId);
|
||||||
|
@ -42,7 +46,7 @@ public class APIBackendListenerHandler {
|
||||||
// 线程名称: <场景名> <场景Index>-<请求Index>, 例如:Scenario 2-1
|
// 线程名称: <场景名> <场景Index>-<请求Index>, 例如:Scenario 2-1
|
||||||
if (StringUtils.equals(result.getSampleLabel(), RunningParamKeys.RUNNING_DEBUG_SAMPLER_NAME)) {
|
if (StringUtils.equals(result.getSampleLabel(), RunningParamKeys.RUNNING_DEBUG_SAMPLER_NAME)) {
|
||||||
String evnStr = result.getResponseDataAsString();
|
String evnStr = result.getResponseDataAsString();
|
||||||
apiEnvironmentRunningParamService.parseEvn(evnStr);
|
ExecutedHandleSingleton.parseEnvironment(evnStr);
|
||||||
} else {
|
} else {
|
||||||
resultService.formatTestResult(testResult, scenarios, result);
|
resultService.formatTestResult(testResult, scenarios, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package io.metersphere.api.jmeter;
|
||||||
|
|
||||||
|
import io.metersphere.api.service.ApiEnvironmentRunningParamService;
|
||||||
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行结束后的处理(单例类)
|
||||||
|
*
|
||||||
|
* @author song.tianyang
|
||||||
|
* @Date 2021/10/29 11:22 上午
|
||||||
|
*/
|
||||||
|
public class ExecutedHandleSingleton {
|
||||||
|
private static volatile ApiEnvironmentRunningParamService apiEnvironmentRunningParamService = CommonBeanFactory.getBean(ApiEnvironmentRunningParamService.class);
|
||||||
|
static Logger testPlanLog = LoggerFactory.getLogger("testPlanExecuteLog");
|
||||||
|
private ExecutedHandleSingleton() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static void parseEnvironment(String evnStr) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}catch (Exception e){
|
||||||
|
}
|
||||||
|
apiEnvironmentRunningParamService.parseEvn(evnStr);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,14 @@ package io.metersphere.api.service;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -20,8 +25,13 @@ import javax.annotation.Resource;
|
||||||
public class ApiEnvironmentRunningParamService {
|
public class ApiEnvironmentRunningParamService {
|
||||||
@Resource
|
@Resource
|
||||||
ApiTestEnvironmentService apiTestEnvironmentService;
|
ApiTestEnvironmentService apiTestEnvironmentService;
|
||||||
|
@Resource
|
||||||
|
SqlSessionFactory sqlSessionFactory;
|
||||||
|
|
||||||
|
Logger testPlanLog = LoggerFactory.getLogger("testPlanExecuteLog");
|
||||||
|
|
||||||
public synchronized void addParam(String enviromentId, String key, String value) {
|
public synchronized void addParam(String enviromentId, String key, String value) {
|
||||||
|
|
||||||
if(StringUtils.isEmpty(key)){
|
if(StringUtils.isEmpty(key)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +96,22 @@ public class ApiEnvironmentRunningParamService {
|
||||||
commonConfig.put("variables",variables);
|
commonConfig.put("variables",variables);
|
||||||
configObj.put("commonConfig",commonConfig);
|
configObj.put("commonConfig",commonConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
apiTestEnvironmentWithBLOBs.setConfig(configObj.toJSONString());
|
apiTestEnvironmentWithBLOBs.setConfig(configObj.toJSONString());
|
||||||
apiTestEnvironmentService.update(apiTestEnvironmentWithBLOBs);
|
|
||||||
|
SqlSession sqlSession = null;
|
||||||
|
try {
|
||||||
|
sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE);
|
||||||
|
ApiTestEnvironmentMapper batchMapper = sqlSession.getMapper(ApiTestEnvironmentMapper.class);
|
||||||
|
batchMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironmentWithBLOBs);
|
||||||
|
sqlSession.commit();
|
||||||
|
}catch (Exception e){
|
||||||
|
sqlSession.rollback();
|
||||||
|
}finally {
|
||||||
|
sqlSession.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
testPlanLog.info("update by sty: "+enviromentId + ":[" + key +":"+ value +"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parseEvn(String envStr) {
|
public void parseEvn(String envStr) {
|
||||||
|
|
|
@ -874,6 +874,7 @@ public class ApiTestCaseService {
|
||||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||||
if (environment != null && environment.getConfig() != null) {
|
if (environment != null && environment.getConfig() != null) {
|
||||||
EnvironmentConfig environmentConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
EnvironmentConfig environmentConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||||
|
environmentConfig.setApiEnvironmentid(environment.getId());
|
||||||
envConfig.put(testCaseWithBLOBs.getProjectId(), environmentConfig);
|
envConfig.put(testCaseWithBLOBs.getProjectId(), environmentConfig);
|
||||||
parameterConfig.setConfig(envConfig);
|
parameterConfig.setConfig(envConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<el-input v-model="form.issuetype" :placeholder="$t('organization.integration.input_azure_issuetype')"/>
|
<el-input v-model="form.issuetype" :placeholder="$t('organization.integration.input_azure_issuetype')"/>
|
||||||
<ms-instructions-icon effect="light">
|
<ms-instructions-icon effect="light">
|
||||||
<template>
|
<template>
|
||||||
<img class="jira-image" src="src/assets/azureDevops-type.png"/>
|
<img class="jira-image" src="@/assets/azureDevops-type.png"/>
|
||||||
</template>
|
</template>
|
||||||
</ms-instructions-icon>
|
</ms-instructions-icon>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<el-input v-model="form.storytype" :placeholder="$t('organization.integration.input_azure_storytype')"/>
|
<el-input v-model="form.storytype" :placeholder="$t('organization.integration.input_azure_storytype')"/>
|
||||||
<ms-instructions-icon effect="light">
|
<ms-instructions-icon effect="light">
|
||||||
<template>
|
<template>
|
||||||
<img class="jira-image" src="src/assets/azureDevops-type.png"/>
|
<img class="jira-image" src="@/assets/azureDevops-type.png"/>
|
||||||
</template>
|
</template>
|
||||||
</ms-instructions-icon>
|
</ms-instructions-icon>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
Loading…
Reference in New Issue