fix(项目设置): 执行带有文件库的接口时增加控制台显示
https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001016881
This commit is contained in:
parent
85849f2108
commit
522374a9d2
|
@ -20,6 +20,7 @@ import org.apache.jmeter.services.FileServer;
|
||||||
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
|
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
|
||||||
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
|
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -60,7 +61,12 @@ public class MsApiBackendListener extends AbstractBackendListenerClient implemen
|
||||||
LoggerUtil.info("重试结果处理【" + dto.getReportId() + " 】结束");
|
LoggerUtil.info("重试结果处理【" + dto.getReportId() + " 】结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
dto.setConsole(FixedCapacityUtils.getJmeterLogger(dto.getReportId(), !StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString())));
|
String console = FixedCapacityUtils.getJmeterLogger(dto.getReportId(), !StringUtils.equals(dto.getReportType(), RunModeConstants.SET_REPORT.toString()));
|
||||||
|
if (FileUtils.isFolderExists(dto.getReportId())) {
|
||||||
|
console += "\r\n" + "tmp folder " + FileUtils.BODY_FILE_DIR + File.separator + dto.getReportId() + " has deleted.";
|
||||||
|
}
|
||||||
|
dto.setConsole(console);
|
||||||
|
|
||||||
// 入库存储
|
// 入库存储
|
||||||
CommonBeanFactory.getBean(TestResultService.class).saveResults(dto);
|
CommonBeanFactory.getBean(TestResultService.class).saveResults(dto);
|
||||||
LoggerUtil.info("进入TEST-END处理报告【" + dto.getReportId() + " 】" + dto.getRunMode() + " 整体执行完成");
|
LoggerUtil.info("进入TEST-END处理报告【" + dto.getReportId() + " 】" + dto.getRunMode() + " 整体执行完成");
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.jmeter.testelement.TestStateListener;
|
||||||
import org.apache.jmeter.testelement.property.BooleanProperty;
|
import org.apache.jmeter.testelement.property.BooleanProperty;
|
||||||
import org.apache.jmeter.threads.JMeterVariables;
|
import org.apache.jmeter.threads.JMeterVariables;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -110,7 +111,6 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
|
||||||
WebSocketUtils.sendMessageSingle(dto);
|
WebSocketUtils.sendMessageSingle(dto);
|
||||||
WebSocketUtils.onClose(this.getName());
|
WebSocketUtils.onClose(this.getName());
|
||||||
PoolExecBlockingQueueUtil.offer(this.getName());
|
PoolExecBlockingQueueUtil.offer(this.getName());
|
||||||
FileUtils.deleteBodyFiles(this.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -164,16 +164,24 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
|
||||||
transactionResult.getResponseResult().setConsole(console);
|
transactionResult.getResponseResult().setConsole(console);
|
||||||
//解析误报内容
|
//解析误报内容
|
||||||
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(transactionResult);
|
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(transactionResult);
|
||||||
|
if (FileUtils.isFolderExists(dto.getToReport())) {
|
||||||
|
expandDTO.getResponseResult().setConsole(expandDTO.getResponseResult().getConsole() + "\r\n" + "tmp folder " + FileUtils.BODY_FILE_DIR + File.separator + dto.getToReport() + " has deleted.");
|
||||||
|
}
|
||||||
JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(expandDTO));
|
JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(expandDTO));
|
||||||
dto.setContent("result_" + JSON.toJSONString(requestResultObject));
|
String consoleStr = JSON.toJSONString(requestResultObject);
|
||||||
|
dto.setContent("result_" + consoleStr);
|
||||||
WebSocketUtils.sendMessageSingle(dto);
|
WebSocketUtils.sendMessageSingle(dto);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
requestResult.getResponseResult().setConsole(console);
|
requestResult.getResponseResult().setConsole(console);
|
||||||
//解析误报内容
|
//解析误报内容
|
||||||
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(requestResult);
|
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(requestResult);
|
||||||
|
if (FileUtils.isFolderExists(dto.getToReport())) {
|
||||||
|
expandDTO.getResponseResult().setConsole(expandDTO.getResponseResult().getConsole() + "\r\n" + "tmp folder " + FileUtils.BODY_FILE_DIR + File.separator + dto.getToReport() + " has deleted.");
|
||||||
|
}
|
||||||
JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(expandDTO));
|
JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(expandDTO));
|
||||||
dto.setContent("result_" + JSON.toJSONString(requestResultObject));
|
String consoleStr = JSON.toJSONString(requestResultObject);
|
||||||
|
dto.setContent("result_" + consoleStr);
|
||||||
WebSocketUtils.sendMessageSingle(dto);
|
WebSocketUtils.sendMessageSingle(dto);
|
||||||
}
|
}
|
||||||
LoggerUtil.debug("send. " + this.getName());
|
LoggerUtil.debug("send. " + this.getName());
|
||||||
|
|
|
@ -515,6 +515,11 @@ public class FileUtils {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFolderExists(String requestId) {
|
||||||
|
File file = new File(BODY_FILE_DIR + File.separator + requestId);
|
||||||
|
return file.isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Object> getZipJar() {
|
public List<Object> getZipJar() {
|
||||||
List<Object> jarFiles = new LinkedList<>();
|
List<Object> jarFiles = new LinkedList<>();
|
||||||
// jar 包
|
// jar 包
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class FileManagerService {
|
||||||
try {
|
try {
|
||||||
list.addAll(FileCenter.getRepository(requestByStorageEntry.getKey()).getFileBatch(requestByStorageEntry.getValue()));
|
list.addAll(FileCenter.getRepository(requestByStorageEntry.getKey()).getFileBatch(requestByStorageEntry.getValue()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error("下载GIT文件失败!", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class FileMetadataService {
|
||||||
fileMetadata.setName(MetadataUtils.getFileNameByRemotePath(fileMetadata.getRepositoryPath()));
|
fileMetadata.setName(MetadataUtils.getFileNameByRemotePath(fileMetadata.getRepositoryPath()));
|
||||||
fileMetadata.setType(MetadataUtils.getFileType(fileMetadata.getRepositoryPath()));
|
fileMetadata.setType(MetadataUtils.getFileType(fileMetadata.getRepositoryPath()));
|
||||||
fileMetadata.setPath(fileMetadata.getRepositoryPath());
|
fileMetadata.setPath(fileMetadata.getRepositoryPath());
|
||||||
fileMetadata.setSize(Long.valueOf(0));
|
fileMetadata.setSize(gitFileInfo.getSize());
|
||||||
fileMetadata.setAttachInfo(JSONObject.toJSONString(gitFileInfo));
|
fileMetadata.setAttachInfo(JSONObject.toJSONString(gitFileInfo));
|
||||||
result.add(this.save(fileMetadata));
|
result.add(this.save(fileMetadata));
|
||||||
} else {
|
} else {
|
||||||
|
@ -590,7 +590,7 @@ public class FileMetadataService {
|
||||||
newMetadata.setAttachInfo(JSONObject.toJSONString(gitFileAttachInfo));
|
newMetadata.setAttachInfo(JSONObject.toJSONString(gitFileAttachInfo));
|
||||||
newMetadata.setName(baseMetadata.getName());
|
newMetadata.setName(baseMetadata.getName());
|
||||||
newMetadata.setType(baseMetadata.getType());
|
newMetadata.setType(baseMetadata.getType());
|
||||||
newMetadata.setSize(baseMetadata.getSize());
|
newMetadata.setSize(gitFileAttachInfo.getSize());
|
||||||
newMetadata.setCreateTime(operationTime);
|
newMetadata.setCreateTime(operationTime);
|
||||||
newMetadata.setUpdateTime(operationTime);
|
newMetadata.setUpdateTime(operationTime);
|
||||||
newMetadata.setStorage(baseMetadata.getStorage());
|
newMetadata.setStorage(baseMetadata.getStorage());
|
||||||
|
|
|
@ -128,7 +128,9 @@ public class GitRepositoryUtils {
|
||||||
if (!treeWalk.next()) {
|
if (!treeWalk.next()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
attachInfo = new GitFileAttachInfo(repositoryUrl, userName, token, branch, fileCommitId.getName(), filePath, commit.getFullMessage());
|
ObjectId objectId = treeWalk.getObjectId(0);
|
||||||
|
ObjectLoader loader = repo.open(objectId);
|
||||||
|
attachInfo = new GitFileAttachInfo(repositoryUrl, userName, token, branch, fileCommitId.getName(), filePath, commit.getFullMessage(), loader.getSize());
|
||||||
return attachInfo;
|
return attachInfo;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class GitFileAttachInfo extends FileAttachInfo {
|
||||||
private String commitId;
|
private String commitId;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private String commitMessage;
|
private String commitMessage;
|
||||||
|
private long size;
|
||||||
|
|
||||||
public String getRepositoryInfo() {
|
public String getRepositoryInfo() {
|
||||||
return repositoryPath + "-" + userName + "-" + token;
|
return repositoryPath + "-" + userName + "-" + token;
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
<span>{{ data.type }}</span>
|
<span>{{ data.type }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="!isRepositoryFile()" :label="$t('load_test.file_size')" prop="size">
|
<el-form-item :label="$t('load_test.file_size')" prop="size">
|
||||||
<span>{{ formatFileSize(data.size) }}</span>
|
<span>{{ formatFileSize(data.size) }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue