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 fa183b844a..acb3e50de5 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReport.java @@ -39,5 +39,7 @@ public class LoadTestReport implements Serializable { private Long testDuration; + private String testResourcePoolId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java index d3bb349f3c..9824c27f54 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportExample.java @@ -1243,6 +1243,76 @@ public class LoadTestReportExample { addCriterion("test_duration not between", value1, value2, "testDuration"); return (Criteria) this; } + + public Criteria andTestResourcePoolIdIsNull() { + addCriterion("test_resource_pool_id is null"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdIsNotNull() { + addCriterion("test_resource_pool_id is not null"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdEqualTo(String value) { + addCriterion("test_resource_pool_id =", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdNotEqualTo(String value) { + addCriterion("test_resource_pool_id <>", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdGreaterThan(String value) { + addCriterion("test_resource_pool_id >", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdGreaterThanOrEqualTo(String value) { + addCriterion("test_resource_pool_id >=", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdLessThan(String value) { + addCriterion("test_resource_pool_id <", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdLessThanOrEqualTo(String value) { + addCriterion("test_resource_pool_id <=", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdLike(String value) { + addCriterion("test_resource_pool_id like", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdNotLike(String value) { + addCriterion("test_resource_pool_id not like", value, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdIn(List values) { + addCriterion("test_resource_pool_id in", values, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdNotIn(List values) { + addCriterion("test_resource_pool_id not in", values, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdBetween(String value1, String value2) { + addCriterion("test_resource_pool_id between", value1, value2, "testResourcePoolId"); + return (Criteria) this; + } + + public Criteria andTestResourcePoolIdNotBetween(String value1, String value2) { + addCriterion("test_resource_pool_id not between", value1, value2, "testResourcePoolId"); + 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 index dfcfb4e5ba..dd71ca2ba6 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestReportWithBLOBs.java @@ -15,5 +15,7 @@ public class LoadTestReportWithBLOBs extends LoadTestReport implements Serializa private String jmxContent; + private String advancedConfiguration; + private static final long serialVersionUID = 1L; } \ 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 89d05f97bc..2574ff4dec 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestReportMapper.xml @@ -19,11 +19,13 @@ + + @@ -86,10 +88,10 @@ id, test_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, file_id, max_users, avg_response_time, tps, project_id, test_name, test_start_time, test_end_time, - test_duration + test_duration, test_resource_pool_id - description, load_configuration, jmx_content + description, load_configuration, jmx_content, advanced_configuration @@ -342,6 +360,9 @@ test_duration = #{record.testDuration,jdbcType=BIGINT}, + + test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -351,6 +372,9 @@ jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR}, + + advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR}, + @@ -375,9 +399,11 @@ test_start_time = #{record.testStartTime,jdbcType=BIGINT}, test_end_time = #{record.testEndTime,jdbcType=BIGINT}, test_duration = #{record.testDuration,jdbcType=BIGINT}, + test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR}, load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}, - jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR} + jmx_content = #{record.jmxContent,jdbcType=LONGVARCHAR}, + advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR} @@ -400,7 +426,8 @@ test_name = #{record.testName,jdbcType=VARCHAR}, test_start_time = #{record.testStartTime,jdbcType=BIGINT}, test_end_time = #{record.testEndTime,jdbcType=BIGINT}, - test_duration = #{record.testDuration,jdbcType=BIGINT} + test_duration = #{record.testDuration,jdbcType=BIGINT}, + test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR} @@ -456,6 +483,9 @@ test_duration = #{testDuration,jdbcType=BIGINT}, + + test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -465,6 +495,9 @@ jmx_content = #{jmxContent,jdbcType=LONGVARCHAR}, + + advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -486,9 +519,11 @@ test_start_time = #{testStartTime,jdbcType=BIGINT}, test_end_time = #{testEndTime,jdbcType=BIGINT}, test_duration = #{testDuration,jdbcType=BIGINT}, + test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR}, description = #{description,jdbcType=LONGVARCHAR}, load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}, - jmx_content = #{jmxContent,jdbcType=LONGVARCHAR} + jmx_content = #{jmxContent,jdbcType=LONGVARCHAR}, + advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -508,7 +543,8 @@ test_name = #{testName,jdbcType=VARCHAR}, test_start_time = #{testStartTime,jdbcType=BIGINT}, test_end_time = #{testEndTime,jdbcType=BIGINT}, - test_duration = #{testDuration,jdbcType=BIGINT} + test_duration = #{testDuration,jdbcType=BIGINT}, + test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/performance/service/MetricQueryService.java b/backend/src/main/java/io/metersphere/performance/service/MetricQueryService.java index 43d6e4dcc0..c281cb7eb5 100644 --- a/backend/src/main/java/io/metersphere/performance/service/MetricQueryService.java +++ b/backend/src/main/java/io/metersphere/performance/service/MetricQueryService.java @@ -6,9 +6,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.client.utils.StringUtils; import io.metersphere.base.domain.LoadTestReportWithBLOBs; -import io.metersphere.base.domain.LoadTestWithBLOBs; import io.metersphere.base.domain.TestResource; -import io.metersphere.base.mapper.LoadTestMapper; import io.metersphere.base.mapper.LoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.commons.constants.ParamConstants; @@ -32,7 +30,6 @@ import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; import java.util.*; @Service @@ -46,8 +43,6 @@ public class MetricQueryService { @Resource private LoadTestReportMapper loadTestReportMapper; @Resource - private LoadTestMapper loadTestMapper; - @Resource private PerformanceReportService performanceReportService; @Resource private ExtLoadTestReportMapper extLoadTestReportMapper; @@ -163,9 +158,7 @@ public class MetricQueryService { public List queryMetric(String reportId) { List instances = new ArrayList<>(); LoadTestReportWithBLOBs report = loadTestReportMapper.selectByPrimaryKey(reportId); - String testId = report.getTestId(); - LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId); - String poolId = loadTestWithBLOBs.getTestResourcePoolId(); + String poolId = report.getTestResourcePoolId(); List resourceList = testResourceService.getTestResourceList(poolId); // 默认监控资源池下的节点 if (CollectionUtils.isNotEmpty(resourceList)) { @@ -177,7 +170,7 @@ public class MetricQueryService { } }); } - String advancedConfiguration = loadTestWithBLOBs.getAdvancedConfiguration(); + String advancedConfiguration = report.getAdvancedConfiguration(); JSONObject jsonObject = JSON.parseObject(advancedConfiguration); JSONArray monitorParams = jsonObject.getJSONArray("monitorParams"); if (monitorParams == null) { @@ -247,9 +240,7 @@ public class MetricQueryService { }); LoadTestReportWithBLOBs report = loadTestReportMapper.selectByPrimaryKey(reportId); - String testId = report.getTestId(); - LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(testId); - String advancedConfiguration = loadTestWithBLOBs.getAdvancedConfiguration(); + String advancedConfiguration = report.getAdvancedConfiguration(); JSONObject jsonObject = JSON.parseObject(advancedConfiguration); JSONArray monitorParams = jsonObject.getJSONArray("monitorParams"); if (monitorParams == null) { 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 4d4615ed0f..5ff79a297b 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -354,8 +354,10 @@ public class PerformanceTestService { loadTestMapper.updateByPrimaryKeySelective(loadTest); // 启动正常插入 report testReport.setLoadConfiguration(loadTest.getLoadConfiguration()); + testReport.setAdvancedConfiguration(loadTest.getAdvancedConfiguration()); testReport.setStatus(PerformanceTestStatus.Starting.name()); testReport.setProjectId(loadTest.getProjectId()); + testReport.setTestResourcePoolId(loadTest.getTestResourcePoolId()); testReport.setTestName(loadTest.getName()); loadTestReportMapper.insertSelective(testReport); diff --git a/backend/src/main/resources/db/migration/V83__v1.10_release.sql b/backend/src/main/resources/db/migration/V83__v1.10_release.sql index 4c9ca30c37..e95ec3e25e 100644 --- a/backend/src/main/resources/db/migration/V83__v1.10_release.sql +++ b/backend/src/main/resources/db/migration/V83__v1.10_release.sql @@ -8,11 +8,21 @@ ALTER TABLE load_test_report ALTER TABLE load_test_report ADD jmx_content LONGTEXT NULL; +ALTER TABLE load_test_report + ADD advanced_configuration LONGTEXT NULL; + +alter table load_test_report + add test_resource_pool_id VARCHAR(50) null; + UPDATE load_test_report JOIN load_test ON load_test.id = load_test_report.test_id SET load_test_report.project_id = load_test.project_id; UPDATE load_test_report JOIN load_test ON load_test.id = load_test_report.test_id SET load_test_report.test_name = load_test.name; + +UPDATE load_test_report JOIN load_test ON load_test.id = test_id +SET load_test_report.advanced_configuration = load_test.advanced_configuration; + -- schedule alter table schedule add config VARCHAR(500) null;