在furion平台启动性能测试任务时,20台肉鸡,每台肉鸡1000个并发线程,但是实际日志收集到到信息仅仅1000个线程,查看肉鸡的日志:
问题定位
- 查看对应路径的文件
- 很明显该文件存在,打开文件,文件内容正常
- 还是看看具体的报错信息吧,定位到具体的代码段信息
/**
* Creates an association between a filename and a File inputOutputObject,
* and stores it for later use - unless it is already stored.
*
* @param filename - relative (to base) or absolute file name (must not be null or empty)
* @param charsetName - the character set encoding to use for the file (may be null)
* @param alias - the name to be used to access the object (must not be null)
* @param hasHeader true if the file has a header line describing the contents
* @return the header line; may be null
* @throws IllegalArgumentException if header could not be read or filename is null or empty
*/
public synchronized String reserveFile(String filename, String charsetName, String alias, boolean hasHeader) {
if (filename == null || filename.isEmpty()){
throw new IllegalArgumentException("Filename must not be null or empty");
}
if (alias == null){
throw new IllegalArgumentException("Alias must not be null");
}
FileEntry fileEntry = files.get(alias);
if (fileEntry == null) {
fileEntry = new FileEntry(resolveFileFromPath(filename), null, charsetName);
if (filename.equals(alias)){
log.info("Stored: {}", filename);
} else {
log.info("Stored: {} Alias: {}", filename, alias);
}
files.put(alias, fileEntry);
if (hasHeader) {
try {
fileEntry.headerLine = readLine(alias, false);
if (fileEntry.headerLine == null) {
fileEntry.exception = new EOFException("File is empty: " + fileEntry.file);
}
} catch (IOException | IllegalArgumentException e) {
fileEntry.exception = e;
}
}
}
if (hasHeader && fileEntry.headerLine == null) {
throw new IllegalArgumentException("Could not read file header line for file " + filename,
fileEntry.exception);
}
return fileEntry.headerLine;
}
从代码中读取文件fileEntry.headerLine = readLine(alias, false);
,找不到文件时异常处理 fileEntry.exception = e;
,将异常赋值给fileEntry.exception
从代码上看问题出现在赋值这里,因为第一次读取这个文件异常后,后续即使有这个文件存在但仍会上抛这个异常导致
ps:在一开始的现象中,仅仅有一台肉鸡可以正常运行,因为第一次同步csv文件时仅仅同步给了那一台肉鸡且运行
解决方案
- 修改jmeter源码修复这个问题,去掉异常赋值等方式
- 从源码中可以看到
hasHeader
也是其中一个判断因素,在jmeter的脚本jmx文件中,可以将该属性配置为False
根据方案2修改后再次执行,果然解决问题