From b5df16df7c149daceb7ff339525ce97af672bc5e Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 20 May 2020 18:55:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=9D=E5=AD=98metric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/domain/LoadTestReport.java | 2 + .../base/domain/LoadTestReportDetail.java | 8 +- .../domain/LoadTestReportDetailExample.java | 60 +++++++++ .../base/domain/LoadTestReportWithBLOBs.java | 18 --- .../mapper/LoadTestReportDetailMapper.java | 5 +- .../mapper/LoadTestReportDetailMapper.xml | 117 ++++++++++-------- .../base/mapper/LoadTestReportMapper.java | 17 ++- .../base/mapper/LoadTestReportMapper.xml | 109 +++++++--------- .../service/PerformanceTestService.java | 8 +- .../performance/service/ReportService.java | 4 +- .../db/migration/V2__metersphere_ddl.sql | 9 +- .../src/main/resources/generatorConfig.xml | 2 +- 12 files changed, 204 insertions(+), 155 deletions(-) delete mode 100644 backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java index c0d76f67ce..2a60c2d011 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java @@ -18,5 +18,7 @@ public class LoadTestReport implements Serializable { private String status; + private String description; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetail.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetail.java index 442ce74b06..2167109815 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetail.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetail.java @@ -1,13 +1,15 @@ package io.metersphere.base.domain; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import java.io.Serializable; @Data -public class LoadTestReportDetail implements Serializable { - private String reportId; - +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class LoadTestReportDetail extends LoadTestReportDetailKey implements Serializable { private String content; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetailExample.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetailExample.java index af84db6d79..e87f61a8e7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetailExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportDetailExample.java @@ -173,6 +173,66 @@ public class LoadTestReportDetailExample { addCriterion("report_id not between", value1, value2, "reportId"); return (Criteria) this; } + + public Criteria andPartIsNull() { + addCriterion("part is null"); + return (Criteria) this; + } + + public Criteria andPartIsNotNull() { + addCriterion("part is not null"); + return (Criteria) this; + } + + public Criteria andPartEqualTo(Long value) { + addCriterion("part =", value, "part"); + return (Criteria) this; + } + + public Criteria andPartNotEqualTo(Long value) { + addCriterion("part <>", value, "part"); + return (Criteria) this; + } + + public Criteria andPartGreaterThan(Long value) { + addCriterion("part >", value, "part"); + return (Criteria) this; + } + + public Criteria andPartGreaterThanOrEqualTo(Long value) { + addCriterion("part >=", value, "part"); + return (Criteria) this; + } + + public Criteria andPartLessThan(Long value) { + addCriterion("part <", value, "part"); + return (Criteria) this; + } + + public Criteria andPartLessThanOrEqualTo(Long value) { + addCriterion("part <=", value, "part"); + return (Criteria) this; + } + + public Criteria andPartIn(List values) { + addCriterion("part in", values, "part"); + return (Criteria) this; + } + + public Criteria andPartNotIn(List values) { + addCriterion("part not in", values, "part"); + return (Criteria) this; + } + + public Criteria andPartBetween(Long value1, Long value2) { + addCriterion("part between", value1, value2, "part"); + return (Criteria) this; + } + + public Criteria andPartNotBetween(Long value1, Long value2) { + addCriterion("part not between", value1, value2, "part"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java deleted file mode 100644 index 3e8d33d570..0000000000 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.metersphere.base.domain; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.io.Serializable; - -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class LoadTestReportWithBLOBs extends LoadTestReport implements Serializable { - private String description; - - private String content; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.java b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.java index d19c9961ed..85bac87235 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.java @@ -2,6 +2,7 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.LoadTestReportDetail; import io.metersphere.base.domain.LoadTestReportDetailExample; +import io.metersphere.base.domain.LoadTestReportDetailKey; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -11,7 +12,7 @@ public interface LoadTestReportDetailMapper { int deleteByExample(LoadTestReportDetailExample example); - int deleteByPrimaryKey(String reportId); + int deleteByPrimaryKey(LoadTestReportDetailKey key); int insert(LoadTestReportDetail record); @@ -21,7 +22,7 @@ public interface LoadTestReportDetailMapper { List selectByExample(LoadTestReportDetailExample example); - LoadTestReportDetail selectByPrimaryKey(String reportId); + LoadTestReportDetail selectByPrimaryKey(LoadTestReportDetailKey key); int updateByExampleSelective(@Param("record") LoadTestReportDetail record, @Param("example") LoadTestReportDetailExample example); diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.xml index 8a19ff8977..ba7d53c95a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportDetailMapper.xml @@ -3,6 +3,7 @@ + @@ -66,7 +67,8 @@ - report_id + report_id, + part content @@ -101,18 +103,20 @@ order by ${orderByClause} - - - delete from load_test_report_detail - where report_id = #{reportId,jdbcType=VARCHAR} - + + + DELETE FROM load_test_report_detail + WHERE report_id = #{reportId,jdbcType=VARCHAR} + AND part = #{part,jdbcType=BIGINT} + delete from load_test_report_detail @@ -120,27 +124,35 @@ - insert into load_test_report_detail (report_id, content) - values (#{reportId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR}) + insert into load_test_report_detail (report_id, part, content + ) + values (#{reportId,jdbcType=VARCHAR}, #{part,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR} + ) insert into load_test_report_detail - - - report_id, - - - content, - - - - - #{reportId,jdbcType=VARCHAR}, - - - #{content,jdbcType=LONGVARCHAR}, - - + + + report_id, + + + part, + + + content, + + + + + #{reportId,jdbcType=VARCHAR}, + + + #{part,jdbcType=BIGINT}, + + + #{content,jdbcType=LONGVARCHAR}, + + update load_test_report_detail - - - report_id = #{record.reportId,jdbcType=VARCHAR}, - - - content = #{record.content,jdbcType=LONGVARCHAR}, - - + + + report_id = #{record.reportId,jdbcType=VARCHAR}, + + + part = #{record.part,jdbcType=BIGINT}, + + + content = #{record.content,jdbcType=LONGVARCHAR}, + + - update load_test_report_detail - set report_id = #{record.reportId,jdbcType=VARCHAR}, + update load_test_report_detail + set report_id = #{record.reportId,jdbcType=VARCHAR}, + part = #{record.part,jdbcType=BIGINT}, content = #{record.content,jdbcType=LONGVARCHAR} - + - update load_test_report_detail - set report_id = #{record.reportId,jdbcType=VARCHAR} - + update load_test_report_detail + set report_id = #{record.reportId,jdbcType=VARCHAR}, + part = #{record.part,jdbcType=BIGINT} + @@ -184,11 +201,13 @@ content = #{content,jdbcType=LONGVARCHAR}, - where report_id = #{reportId,jdbcType=VARCHAR} + where report_id = #{reportId,jdbcType=VARCHAR} + and part = #{part,jdbcType=BIGINT} - update load_test_report_detail - set content = #{content,jdbcType=LONGVARCHAR} - where report_id = #{reportId,jdbcType=VARCHAR} + update load_test_report_detail + set content = #{content,jdbcType=LONGVARCHAR} + where report_id = #{reportId,jdbcType=VARCHAR} + and part = #{part,jdbcType=BIGINT} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.java index 018fc00eaa..8bddc4ec16 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.java @@ -2,7 +2,6 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.LoadTestReport; import io.metersphere.base.domain.LoadTestReportExample; -import io.metersphere.base.domain.LoadTestReportWithBLOBs; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -14,25 +13,25 @@ public interface LoadTestReportMapper { int deleteByPrimaryKey(String id); - int insert(LoadTestReportWithBLOBs record); + int insert(LoadTestReport record); - int insertSelective(LoadTestReportWithBLOBs record); + int insertSelective(LoadTestReport record); - List selectByExampleWithBLOBs(LoadTestReportExample example); + List selectByExampleWithBLOBs(LoadTestReportExample example); List selectByExample(LoadTestReportExample example); - LoadTestReportWithBLOBs selectByPrimaryKey(String id); + LoadTestReport selectByPrimaryKey(String id); - int updateByExampleSelective(@Param("record") LoadTestReportWithBLOBs record, @Param("example") LoadTestReportExample example); + int updateByExampleSelective(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example); - int updateByExampleWithBLOBs(@Param("record") LoadTestReportWithBLOBs record, @Param("example") LoadTestReportExample example); + int updateByExampleWithBLOBs(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example); int updateByExample(@Param("record") LoadTestReport record, @Param("example") LoadTestReportExample example); - int updateByPrimaryKeySelective(LoadTestReportWithBLOBs record); + int updateByPrimaryKeySelective(LoadTestReport record); - int updateByPrimaryKeyWithBLOBs(LoadTestReportWithBLOBs record); + int updateByPrimaryKeyWithBLOBs(LoadTestReport record); int updateByPrimaryKey(LoadTestReport record); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml index 5027029ccf..eae844a677 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml @@ -9,9 +9,8 @@ - - - + + @@ -75,7 +74,7 @@ id, test_id, name, create_time, update_time, status - description, content + description @@ -218,25 +211,21 @@ description = #{record.description,jdbcType=LONGVARCHAR}, - - content = #{record.content,jdbcType=LONGVARCHAR}, - - update load_test_report - set id = #{record.id,jdbcType=VARCHAR}, + update load_test_report + set id = #{record.id,jdbcType=VARCHAR}, test_id = #{record.testId,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, status = #{record.status,jdbcType=VARCHAR}, - description = #{record.description,jdbcType=LONGVARCHAR}, - content = #{record.content,jdbcType=LONGVARCHAR} - + description = #{record.description,jdbcType=LONGVARCHAR} + @@ -252,17 +241,17 @@ - - update load_test_report - - - test_id = #{testId,jdbcType=VARCHAR}, - - - name = #{name,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=BIGINT}, + + update load_test_report + + + test_id = #{testId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, @@ -273,23 +262,19 @@ description = #{description,jdbcType=LONGVARCHAR}, - - content = #{content,jdbcType=LONGVARCHAR}, - where id = #{id,jdbcType=VARCHAR} - - update load_test_report - set test_id = #{testId,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT}, - status = #{status,jdbcType=VARCHAR}, - description = #{description,jdbcType=LONGVARCHAR}, - content = #{content,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=VARCHAR} - + + UPDATE load_test_report + SET test_id = #{testId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + status = #{status,jdbcType=VARCHAR}, + description = #{description,jdbcType=LONGVARCHAR} + WHERE id = #{id,jdbcType=VARCHAR} + update load_test_report set test_id = #{testId,jdbcType=VARCHAR}, diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 7ee2d6043f..54ef43abc5 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -79,7 +79,9 @@ public class PerformanceTestService { // delete load_test_report, delete load_test_report_detail reportIdList.forEach(reportId -> { - loadTestReportDetailMapper.deleteByPrimaryKey(reportId); + LoadTestReportDetailExample example = new LoadTestReportDetailExample(); + example.createCriteria().andReportIdEqualTo(reportId); + loadTestReportDetailMapper.deleteByExample(example); reportService.deleteReport(reportId); }); @@ -202,7 +204,7 @@ public class PerformanceTestService { } private void startEngine(LoadTestWithBLOBs loadTest, Engine engine) { - LoadTestReportWithBLOBs testReport = new LoadTestReportWithBLOBs(); + LoadTestReport testReport = new LoadTestReport(); testReport.setId(engine.getReportId()); testReport.setCreateTime(engine.getStartTime()); testReport.setUpdateTime(engine.getStartTime()); @@ -216,13 +218,13 @@ public class PerformanceTestService { loadTest.setStatus(PerformanceTestStatus.Starting.name()); loadTestMapper.updateByPrimaryKeySelective(loadTest); // 启动正常插入 report - testReport.setContent(HEADERS); testReport.setStatus(PerformanceTestStatus.Starting.name()); loadTestReportMapper.insertSelective(testReport); LoadTestReportDetail reportDetail = new LoadTestReportDetail(); reportDetail.setContent(HEADERS); reportDetail.setReportId(testReport.getId()); + reportDetail.setPart(1L); loadTestReportDetailMapper.insertSelective(reportDetail); // append \n extLoadTestReportMapper.appendLine(testReport.getId(), "\n"); diff --git a/backend/src/main/java/io/metersphere/performance/service/ReportService.java b/backend/src/main/java/io/metersphere/performance/service/ReportService.java index 95eaa13bd9..53bb573428 100644 --- a/backend/src/main/java/io/metersphere/performance/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/ReportService.java @@ -57,7 +57,7 @@ public class ReportService { MSException.throwException("report id cannot be null"); } - LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(loadTestReport.getTestId()); LogUtil.info("Delete report started, report ID: %s" + reportId); @@ -142,7 +142,7 @@ public class ReportService { } public void checkReportStatus(String reportId) { - LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); + LoadTestReport loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId); String reportStatus = loadTestReport.getStatus(); if (StringUtils.equals(PerformanceTestStatus.Running.name(), reportStatus)) { MSException.throwException("Reporting in progress..."); diff --git a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql index 83e091e935..fe3fdeef0b 100644 --- a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql +++ b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql @@ -51,7 +51,6 @@ CREATE TABLE IF NOT EXISTS `load_test_report` ( `test_id` varchar(50) NOT NULL COMMENT 'Test ID this test report belongs to', `name` varchar(64) NOT NULL COMMENT 'Test report name', `description` varchar(255) DEFAULT NULL COMMENT 'Test report name', - `content` longtext, `create_time` bigint(13) NOT NULL COMMENT 'Create timestamp', `update_time` bigint(13) NOT NULL COMMENT 'Update timestamp', `status` varchar(64) NOT NULL COMMENT 'Status of this test run', @@ -64,11 +63,9 @@ CREATE TABLE IF NOT EXISTS `load_test_report` ( CREATE TABLE IF NOT EXISTS `load_test_report_detail` ( `report_id` varchar(50) NOT NULL, `content` longtext, - PRIMARY KEY (`report_id`) -) - ENGINE=InnoDB - DEFAULT CHARSET=utf8mb4 - COLLATE=utf8mb4_bin; + `part` bigint(11) NOT NULL, + PRIMARY KEY (`report_id`,`part`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `load_test_report_log` ( `id` varchar(50) NOT NULL, diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index 67af9f5eb0..a1692aed6d 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -59,7 +59,7 @@ - +
\ No newline at end of file