diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java index 6bba2dddd5..0c1989dca0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenrioExportJmx.java @@ -10,6 +10,7 @@ import java.util.List; public class ApiScenrioExportJmx { private String name; private String jmx; + private Integer version; List files; public ApiScenrioExportJmx(String name, String jmx) { diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java index 3a5ba77002..e47b2ce9d8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java @@ -40,6 +40,8 @@ public class SaveApiScenarioRequest { private String description; + private Integer version; + private MsTestElement scenarioDefinition; List bodyFileRequestIds; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 29538680d2..91c27a7bbd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -244,6 +244,7 @@ public class ApiAutomationService { checkNameExist(request); checkScenarioNum(request); final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); + scenario.setVersion(0); scenario.setCreateTime(System.currentTimeMillis()); scenario.setNum(getNextNum(request.getProjectId())); @@ -325,6 +326,14 @@ public class ApiAutomationService { esbApiParamService.checkScenarioRequests(request); final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); + + Integer version = apiScenarioMapper.selectByPrimaryKey(request.getId()).getVersion(); + if (version == null) { + scenario.setVersion(0); + } else { + scenario.setVersion(version + 1); + } + deleteUpdateBodyFile(scenario); List useUrl = this.parseUrl(scenario); scenario.setUseUrl(JSONArray.toJSONString(useUrl)); @@ -1544,7 +1553,7 @@ public class ApiAutomationService { } - public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception { + public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) { List apiScenarios = null; List ids = request.getIds(); apiScenarios = extApiScenarioMapper.selectIds(ids); @@ -1753,6 +1762,7 @@ public class ApiAutomationService { scenrioExportJmx.setFiles(fileList); } } + scenrioExportJmx.setVersion(item.getVersion()); resList.add(scenrioExportJmx); } } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java index bef31b76a2..d33144975c 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java @@ -49,5 +49,7 @@ public class ApiScenario implements Serializable { private String createUser; + private Integer version; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java index 39c31daeab..a56faf3328 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java @@ -1603,6 +1603,66 @@ public class ApiScenarioExample { addCriterion("create_user not between", value1, value2, "createUser"); return (Criteria) this; } + + public Criteria andVersionIsNull() { + addCriterion("version is null"); + return (Criteria) this; + } + + public Criteria andVersionIsNotNull() { + addCriterion("version is not null"); + return (Criteria) this; + } + + public Criteria andVersionEqualTo(Integer value) { + addCriterion("version =", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotEqualTo(Integer value) { + addCriterion("version <>", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThan(Integer value) { + addCriterion("version >", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionGreaterThanOrEqualTo(Integer value) { + addCriterion("version >=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThan(Integer value) { + addCriterion("version <", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionLessThanOrEqualTo(Integer value) { + addCriterion("version <=", value, "version"); + return (Criteria) this; + } + + public Criteria andVersionIn(List values) { + addCriterion("version in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotIn(List values) { + addCriterion("version not in", values, "version"); + return (Criteria) this; + } + + public Criteria andVersionBetween(Integer value1, Integer value2) { + addCriterion("version between", value1, value2, "version"); + return (Criteria) this; + } + + public Criteria andVersionNotBetween(Integer value1, Integer value2) { + addCriterion("version not between", value1, value2, "version"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTest.java b/backend/src/main/java/io/metersphere/base/domain/LoadTest.java index 4de4228a56..800eb34db8 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTest.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTest.java @@ -1,8 +1,7 @@ package io.metersphere.base.domain; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class LoadTest implements Serializable { @@ -28,5 +27,9 @@ public class LoadTest implements Serializable { private String createUser; + private Integer scenarioVersion; + + private String scenarioId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/LoadTestExample.java b/backend/src/main/java/io/metersphere/base/domain/LoadTestExample.java index f2591d944c..f43fefe4e5 100644 --- a/backend/src/main/java/io/metersphere/base/domain/LoadTestExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/LoadTestExample.java @@ -843,6 +843,136 @@ public class LoadTestExample { addCriterion("create_user not between", value1, value2, "createUser"); return (Criteria) this; } + + public Criteria andScenarioVersionIsNull() { + addCriterion("scenario_version is null"); + return (Criteria) this; + } + + public Criteria andScenarioVersionIsNotNull() { + addCriterion("scenario_version is not null"); + return (Criteria) this; + } + + public Criteria andScenarioVersionEqualTo(Integer value) { + addCriterion("scenario_version =", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionNotEqualTo(Integer value) { + addCriterion("scenario_version <>", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionGreaterThan(Integer value) { + addCriterion("scenario_version >", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionGreaterThanOrEqualTo(Integer value) { + addCriterion("scenario_version >=", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionLessThan(Integer value) { + addCriterion("scenario_version <", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionLessThanOrEqualTo(Integer value) { + addCriterion("scenario_version <=", value, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionIn(List values) { + addCriterion("scenario_version in", values, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionNotIn(List values) { + addCriterion("scenario_version not in", values, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionBetween(Integer value1, Integer value2) { + addCriterion("scenario_version between", value1, value2, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioVersionNotBetween(Integer value1, Integer value2) { + addCriterion("scenario_version not between", value1, value2, "scenarioVersion"); + return (Criteria) this; + } + + public Criteria andScenarioIdIsNull() { + addCriterion("scenario_id is null"); + return (Criteria) this; + } + + public Criteria andScenarioIdIsNotNull() { + addCriterion("scenario_id is not null"); + return (Criteria) this; + } + + public Criteria andScenarioIdEqualTo(String value) { + addCriterion("scenario_id =", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdNotEqualTo(String value) { + addCriterion("scenario_id <>", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdGreaterThan(String value) { + addCriterion("scenario_id >", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdGreaterThanOrEqualTo(String value) { + addCriterion("scenario_id >=", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdLessThan(String value) { + addCriterion("scenario_id <", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdLessThanOrEqualTo(String value) { + addCriterion("scenario_id <=", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdLike(String value) { + addCriterion("scenario_id like", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdNotLike(String value) { + addCriterion("scenario_id not like", value, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdIn(List values) { + addCriterion("scenario_id in", values, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdNotIn(List values) { + addCriterion("scenario_id not in", values, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdBetween(String value1, String value2) { + addCriterion("scenario_id between", value1, value2, "scenarioId"); + return (Criteria) this; + } + + public Criteria andScenarioIdNotBetween(String value1, String value2) { + addCriterion("scenario_id not between", value1, value2, "scenarioId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml index 17631f59f2..d6e7826446 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml @@ -24,6 +24,7 @@ + @@ -91,7 +92,8 @@ id, project_id, tags, user_id, api_scenario_module_id, module_path, `name`, `level`, `status`, principal, step_total, follow_people, schedule, create_time, update_time, - pass_rate, last_result, report_id, num, original_state, custom_num, create_user + pass_rate, last_result, report_id, num, original_state, custom_num, create_user, + version scenario_definition, description, use_url @@ -152,8 +154,8 @@ schedule, create_time, update_time, pass_rate, last_result, report_id, num, original_state, custom_num, - create_user, scenario_definition, description, - use_url) + create_user, version, scenario_definition, + description, use_url) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, @@ -161,8 +163,8 @@ #{schedule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{passRate,jdbcType=VARCHAR}, #{lastResult,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, #{originalState,jdbcType=VARCHAR}, #{customNum,jdbcType=VARCHAR}, - #{createUser,jdbcType=VARCHAR}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}, - #{useUrl,jdbcType=LONGVARCHAR}) + #{createUser,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, + #{description,jdbcType=LONGVARCHAR}, #{useUrl,jdbcType=LONGVARCHAR}) insert into api_scenario @@ -233,6 +235,9 @@ create_user, + + version, + scenario_definition, @@ -310,6 +315,9 @@ #{createUser,jdbcType=VARCHAR}, + + #{version,jdbcType=INTEGER}, + #{scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -396,6 +404,9 @@ create_user = #{record.createUser,jdbcType=VARCHAR}, + + version = #{record.version,jdbcType=INTEGER}, + scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -434,6 +445,7 @@ original_state = #{record.originalState,jdbcType=VARCHAR}, custom_num = #{record.customNum,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, + version = #{record.version,jdbcType=INTEGER}, scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR}, use_url = #{record.useUrl,jdbcType=LONGVARCHAR} @@ -464,7 +476,8 @@ num = #{record.num,jdbcType=INTEGER}, original_state = #{record.originalState,jdbcType=VARCHAR}, custom_num = #{record.customNum,jdbcType=VARCHAR}, - create_user = #{record.createUser,jdbcType=VARCHAR} + create_user = #{record.createUser,jdbcType=VARCHAR}, + version = #{record.version,jdbcType=INTEGER} @@ -535,6 +548,9 @@ create_user = #{createUser,jdbcType=VARCHAR}, + + version = #{version,jdbcType=INTEGER}, + scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -570,6 +586,7 @@ original_state = #{originalState,jdbcType=VARCHAR}, custom_num = #{customNum,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, + version = #{version,jdbcType=INTEGER}, scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR}, use_url = #{useUrl,jdbcType=LONGVARCHAR} @@ -597,7 +614,8 @@ num = #{num,jdbcType=INTEGER}, original_state = #{originalState,jdbcType=VARCHAR}, custom_num = #{customNum,jdbcType=VARCHAR}, - create_user = #{createUser,jdbcType=VARCHAR} + create_user = #{createUser,jdbcType=VARCHAR}, + version = #{version,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/LoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/LoadTestMapper.xml index f6c9fb14b0..c6a1066159 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/LoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/LoadTestMapper.xml @@ -13,6 +13,8 @@ + + @@ -78,7 +80,7 @@ id, project_id, `name`, description, create_time, update_time, `status`, test_resource_pool_id, - user_id, num, create_user + user_id, num, create_user, scenario_version, scenario_id load_configuration, advanced_configuration @@ -135,13 +137,15 @@ insert into load_test (id, project_id, `name`, description, create_time, update_time, `status`, test_resource_pool_id, user_id, - num, create_user, load_configuration, - advanced_configuration) + num, create_user, scenario_version, + scenario_id, load_configuration, advanced_configuration + ) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, - #{num,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{loadConfiguration,jdbcType=LONGVARCHAR}, - #{advancedConfiguration,jdbcType=LONGVARCHAR}) + #{num,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{scenarioVersion,jdbcType=INTEGER}, + #{scenarioId,jdbcType=VARCHAR}, #{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR} + ) insert into load_test @@ -179,6 +183,12 @@ create_user, + + scenario_version, + + + scenario_id, + load_configuration, @@ -220,6 +230,12 @@ #{createUser,jdbcType=VARCHAR}, + + #{scenarioVersion,jdbcType=INTEGER}, + + + #{scenarioId,jdbcType=VARCHAR}, + #{loadConfiguration,jdbcType=LONGVARCHAR}, @@ -270,6 +286,12 @@ create_user = #{record.createUser,jdbcType=VARCHAR}, + + scenario_version = #{record.scenarioVersion,jdbcType=INTEGER}, + + + scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, + load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}, @@ -294,6 +316,8 @@ user_id = #{record.userId,jdbcType=VARCHAR}, num = #{record.num,jdbcType=INTEGER}, create_user = #{record.createUser,jdbcType=VARCHAR}, + scenario_version = #{record.scenarioVersion,jdbcType=INTEGER}, + scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR}, advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR} @@ -312,7 +336,9 @@ test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR}, num = #{record.num,jdbcType=INTEGER}, - create_user = #{record.createUser,jdbcType=VARCHAR} + create_user = #{record.createUser,jdbcType=VARCHAR}, + scenario_version = #{record.scenarioVersion,jdbcType=INTEGER}, + scenario_id = #{record.scenarioId,jdbcType=VARCHAR} @@ -350,6 +376,12 @@ create_user = #{createUser,jdbcType=VARCHAR}, + + scenario_version = #{scenarioVersion,jdbcType=INTEGER}, + + + scenario_id = #{scenarioId,jdbcType=VARCHAR}, + load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}, @@ -371,6 +403,8 @@ user_id = #{userId,jdbcType=VARCHAR}, num = #{num,jdbcType=INTEGER}, create_user = #{createUser,jdbcType=VARCHAR}, + scenario_version = #{scenarioVersion,jdbcType=INTEGER}, + scenario_id = #{scenarioId,jdbcType=VARCHAR}, load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR}, advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -386,7 +420,9 @@ test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR}, num = #{num,jdbcType=INTEGER}, - create_user = #{createUser,jdbcType=VARCHAR} + create_user = #{createUser,jdbcType=VARCHAR}, + scenario_version = #{scenarioVersion,jdbcType=INTEGER}, + scenario_id = #{scenarioId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index d81bebf4ad..596e1309c1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -144,7 +144,7 @@