From ef64918cbd27ed4129873096f72ead332e8a45cc Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Fri, 28 Feb 2020 17:54:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/PerformanceTestObject.java | 30 +++++-------------- .../util/cache/CustomSettingVariable.java | 24 +++++++++++---- src/main/resources/applicationContext.xml | 2 ++ update.md | 7 ++++- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/main/java/yi/master/coretest/message/test/performance/PerformanceTestObject.java b/src/main/java/yi/master/coretest/message/test/performance/PerformanceTestObject.java index 30e568f..6162a5d 100644 --- a/src/main/java/yi/master/coretest/message/test/performance/PerformanceTestObject.java +++ b/src/main/java/yi/master/coretest/message/test/performance/PerformanceTestObject.java @@ -1,23 +1,7 @@ package yi.master.coretest.message.test.performance; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectOutputStream; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; - +import net.sf.json.JSONObject; +import net.sf.json.JsonConfig; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -25,7 +9,6 @@ import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.struts2.json.annotations.JSON; - import yi.master.business.advanced.bean.PerformanceTestConfig; import yi.master.business.advanced.bean.PerformanceTestResult; import yi.master.business.advanced.bean.config.performancetest.PerformanceTestAnalyzeResult; @@ -47,11 +30,14 @@ import yi.master.coretest.message.test.TestMessageScene; import yi.master.util.FrameworkUtil; import yi.master.util.PracticalUtils; import yi.master.util.cache.CacheUtil; +import yi.master.util.cache.CustomSettingVariable; import yi.master.util.excel.PoiExcelUtil; import yi.master.util.jsonlib.JsonDateValueProcessor; -import net.sf.json.JSONObject; -import net.sf.json.JsonConfig; +import java.io.*; +import java.sql.Timestamp; +import java.util.*; +import java.util.concurrent.ConcurrentLinkedQueue; /** @@ -315,7 +301,7 @@ public class PerformanceTestObject { FileOutputStream fos = null; ObjectOutputStream out = null; try { - filePath = FrameworkUtil.getProjectPath() + "/tmp/ptr/" + PracticalUtils.getUUID("") + ".txt"; + filePath = CustomSettingVariable.PT_RESULT_FILE_SAVE_PATH + PracticalUtils.getUUID("") + ".txt"; fos = new FileOutputStream(filePath); out = new ObjectOutputStream(fos); out.writeObject(result.getTestResults()); diff --git a/src/main/java/yi/master/util/cache/CustomSettingVariable.java b/src/main/java/yi/master/util/cache/CustomSettingVariable.java index f1c8091..5fad23b 100644 --- a/src/main/java/yi/master/util/cache/CustomSettingVariable.java +++ b/src/main/java/yi/master/util/cache/CustomSettingVariable.java @@ -16,15 +16,29 @@ import java.io.File; */ public class CustomSettingVariable { public static String GLOBAL_VARIABLE_FILE_SAVE_PATH = FrameworkUtil.getProjectPath() + File.separator + ".." + File.separator + "variableFileResources"; + public static String PT_RESULT_FILE_SAVE_PATH = FrameworkUtil.getProjectPath() + File.separator + ".." + File.separator + "tmp/ptr/"; public static void setSettingVariable (ServletContext context) { - Object str = context.getAttribute("globalVariableFileSavePath"); - if (str != null && StringUtils.isNotBlank(str.toString())) { - GLOBAL_VARIABLE_FILE_SAVE_PATH = str.toString(); + String str = checkFolder(context, "globalVariableFileSavePath"); + if (str != null) { + GLOBAL_VARIABLE_FILE_SAVE_PATH = str; } - if (!FileUtil.exist(GLOBAL_VARIABLE_FILE_SAVE_PATH)) { - FileUtil.mkdir(GLOBAL_VARIABLE_FILE_SAVE_PATH); + + str = checkFolder(context, "ptResultFileSavePath"); + if (str != null) { + PT_RESULT_FILE_SAVE_PATH = str; + } + } + + private static String checkFolder (ServletContext context, String attributeKey) { + Object str = context.getAttribute(attributeKey); + if (str == null || StringUtils.isBlank(str.toString())) { + return null; + } + if (!FileUtil.exist(str.toString())) { + FileUtil.mkdir(str.toString()); } + return str.toString(); } } diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml index 8ddad45..ba03622 100644 --- a/src/main/resources/applicationContext.xml +++ b/src/main/resources/applicationContext.xml @@ -132,6 +132,8 @@ + + diff --git a/update.md b/update.md index 51f07a4..056ab22 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,10 @@ +### v1.0.4 +#### 2020.2.28 +- 修复:性能测试结果文件保存出错的问题; + + ### v1.0.3 -#### 2020.2.20 +#### 2020.2.27 - 更新:单个场景调试时可自定义报文内容; - 修复:HTTP请求时返回302状态时报错的问题;(未测试) - 新增:集成swagger4j,可查看api文档,使用方法:修改swagger.properties中disabled=false,启动项目打开http://localhost:8080/doc/index.html,api注解使用请参考https://github.com/cpjit/swagger -- Gitee From 7149353a4a347ecd18098979a4cbba47938a4b73 Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Fri, 28 Feb 2020 18:55:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yi/master/util/cache/CustomSettingVariable.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/yi/master/util/cache/CustomSettingVariable.java b/src/main/java/yi/master/util/cache/CustomSettingVariable.java index 5fad23b..b056688 100644 --- a/src/main/java/yi/master/util/cache/CustomSettingVariable.java +++ b/src/main/java/yi/master/util/cache/CustomSettingVariable.java @@ -24,10 +24,18 @@ public class CustomSettingVariable { GLOBAL_VARIABLE_FILE_SAVE_PATH = str; } + if (!FileUtil.exist(GLOBAL_VARIABLE_FILE_SAVE_PATH)) { + FileUtil.mkdir(GLOBAL_VARIABLE_FILE_SAVE_PATH); + } + str = checkFolder(context, "ptResultFileSavePath"); if (str != null) { PT_RESULT_FILE_SAVE_PATH = str; } + + if (!FileUtil.exist(PT_RESULT_FILE_SAVE_PATH)) { + FileUtil.mkdir(PT_RESULT_FILE_SAVE_PATH); + } } private static String checkFolder (ServletContext context, String attributeKey) { @@ -35,9 +43,6 @@ public class CustomSettingVariable { if (str == null || StringUtils.isBlank(str.toString())) { return null; } - if (!FileUtil.exist(str.toString())) { - FileUtil.mkdir(str.toString()); - } return str.toString(); } -- Gitee From 915508137c84049c0c4233ed45181fc2fbcd0dca Mon Sep 17 00:00:00 2001 From: xuwangcheng Date: Fri, 28 Feb 2020 19:49:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=9C=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86=E6=B5=8B=E8=AF=95=E3=80=81=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E4=B8=AD=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E4=BD=BF=E7=94=A8=E4=BA=86=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=8E=A5=E5=8F=A3=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=97=A0=E6=B3=95=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=88=B0=E6=AD=A3=E7=A1=AE=E7=9A=84=E5=80=BC=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/message/action/AutoTestAction.java | 4 ++++ .../coretest/message/test/MessageAutoTest.java | 16 +++++++++++----- .../test/performance/PerformanceTestObject.java | 4 +++- update.md | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/yi/master/business/message/action/AutoTestAction.java b/src/main/java/yi/master/business/message/action/AutoTestAction.java index 5c3f69f..999ba66 100644 --- a/src/main/java/yi/master/business/message/action/AutoTestAction.java +++ b/src/main/java/yi/master/business/message/action/AutoTestAction.java @@ -20,6 +20,7 @@ import yi.master.business.testconfig.service.GlobalVariableService; import yi.master.business.testconfig.service.TestConfigService; import yi.master.business.user.bean.User; import yi.master.business.user.service.UserService; +import yi.master.constant.SystemConsts; import yi.master.coretest.message.test.MessageAutoTest; import yi.master.coretest.message.test.TestMessageScene; import yi.master.exception.AppErrorCode; @@ -132,6 +133,9 @@ public class AutoTestAction extends ActionSupport implements ModelDriven