From 478d6db83b809c3c83a9479765991cb2373a45a1 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 19 Aug 2020 15:41:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=92=8C=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=92=8C=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/scenario/Scenario.java | 1 + .../dto/scenario/request/DubboRequest.java | 2 + .../api/dto/scenario/request/HttpRequest.java | 2 + .../api/test/components/ApiScenarioConfig.vue | 35 ++++++++-- .../components/collapse/ApiCollapseItem.vue | 2 + .../components/request/ApiRequestConfig.vue | 35 +++++++++- .../api/test/model/ScenarioModel.js | 65 +++++++++++-------- frontend/src/i18n/en-US.js | 4 +- frontend/src/i18n/zh-CN.js | 4 +- frontend/src/i18n/zh-TW.js | 4 +- 10 files changed, 115 insertions(+), 39 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java index 654689f7ff..e2c8ac1e50 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Scenario.java @@ -15,4 +15,5 @@ public class Scenario { private List headers; private List requests; private DubboConfig dubboConfig; + private Boolean enable; } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java index c8202d07b6..33bdc7c3be 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/DubboRequest.java @@ -49,4 +49,6 @@ public class DubboRequest implements Request { private BeanShellPreProcessor beanShellPreProcessor; @JSONField(ordinal = 13) private BeanShellPostProcessor beanShellPostProcessor; + @JSONField(ordinal = 14) + private Boolean enable; } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java index efe616f29f..c5cfac764d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java @@ -41,4 +41,6 @@ public class HttpRequest implements Request { private BeanShellPreProcessor beanShellPreProcessor; @JSONField(ordinal = 12) private BeanShellPostProcessor beanShellPostProcessor; + @JSONField(ordinal = 13) + private Boolean enable; } diff --git a/frontend/src/business/components/api/test/components/ApiScenarioConfig.vue b/frontend/src/business/components/api/test/components/ApiScenarioConfig.vue index 1e9dee1661..ce88447354 100644 --- a/frontend/src/business/components/api/test/components/ApiScenarioConfig.vue +++ b/frontend/src/business/components/api/test/components/ApiScenarioConfig.vue @@ -5,13 +5,13 @@ + :title="scenario.name" :name="index" :class="{'disable-scenario': !scenario.enable}"> @@ -108,6 +114,12 @@ export default { this.select(this.scenarios[0]); } }, + disableScenario: function (index) { + this.scenarios[index].enable = false; + }, + enableScenario: function (index) { + this.scenarios[index].enable = true; + }, handleChange: function (index) { this.select(this.scenarios[index]); }, @@ -119,6 +131,12 @@ export default { case "delete": this.deleteScenario(command.index); break; + case "disable": + this.disableScenario(command.index); + break; + case "enable": + this.enableScenario(command.index); + break; } }, select: function (obj, scenario) { @@ -203,9 +221,9 @@ export default { width: 100%; } - .scenario-name > #hint { - color: #8a8b8d; - } + /*.scenario-name > #hint {*/ + /*color: #8a8b8d;*/ + /*}*/ .scenario-btn { text-align: center; @@ -241,4 +259,9 @@ export default { .scenario-draggable { background-color: #909399; } + + .disable-scenario >>> .el-collapse-item__header { + border-right: 2px solid #909399; + color: #8a8b8d; + } diff --git a/frontend/src/business/components/api/test/components/collapse/ApiCollapseItem.vue b/frontend/src/business/components/api/test/components/collapse/ApiCollapseItem.vue index add6a4e7ff..9dc50e2a7e 100644 --- a/frontend/src/business/components/api/test/components/collapse/ApiCollapseItem.vue +++ b/frontend/src/business/components/api/test/components/collapse/ApiCollapseItem.vue @@ -113,6 +113,7 @@ diff --git a/frontend/src/business/components/api/test/components/request/ApiRequestConfig.vue b/frontend/src/business/components/api/test/components/request/ApiRequestConfig.vue index 249b045212..e6baee86da 100644 --- a/frontend/src/business/components/api/test/components/request/ApiRequestConfig.vue +++ b/frontend/src/business/components/api/test/components/request/ApiRequestConfig.vue @@ -2,7 +2,7 @@
+ :class="{'selected': isSelected(request), 'disable-request': !request.enable}">
{{request.showType()}} @@ -23,6 +23,12 @@ {{$t('api_test.request.delete')}} + + {{$t('api_test.scenario.disable')}} + + + {{$t('api_test.scenario.enable')}} +
@@ -70,7 +76,7 @@ computed: { isSelected() { return function (request) { - return this.selected.id === request.id; + return this.selected === request; } } }, @@ -89,6 +95,12 @@ let request = this.scenario.requests[index]; this.scenario.requests.push(new RequestFactory(request)); }, + disableRequest: function (index) { + this.scenario.requests[index].enable = false; + }, + enableRequest: function (index) { + this.scenario.requests[index].enable = true; + }, deleteRequest: function (index) { this.scenario.requests.splice(index, 1); if (this.scenario.requests.length === 0) { @@ -103,6 +115,12 @@ case "delete": this.deleteRequest(command.index); break; + case "disable": + this.disableRequest(command.index); + break; + case "enable": + this.enableRequest(command.index); + break; } }, select: function (request) { @@ -186,4 +204,17 @@ opacity: 0.5; background-color: #909399; } + + .request-item.disable-request { + border-left-color: #909399; + } + + .disable-request .request-type { + background-color: #909399; + } + + .disable-request .request-method { + color: #909399; + } + diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 22ddb31906..c959b3a681 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -207,6 +207,7 @@ export class Scenario extends BaseConfig { this.dubboConfig = undefined; this.environment = undefined; this.enableCookieShare = false; + this.enable = true; this.set(options); this.sets({variables: KeyValue, headers: KeyValue, requests: RequestFactory}, options); @@ -304,6 +305,7 @@ export class HttpRequest extends Request { this.debugReport = undefined; this.beanShellPreProcessor = undefined; this.beanShellPostProcessor = undefined; + this.enable = true; this.set(options); this.sets({parameters: KeyValue, headers: KeyValue}, options); @@ -383,6 +385,7 @@ export class DubboRequest extends Request { this.debugReport = undefined; this.beanShellPreProcessor = new BeanShellProcessor(options.beanShellPreProcessor); this.beanShellPostProcessor = new BeanShellProcessor(options.beanShellPostProcessor); + this.enable = true; this.sets({args: KeyValue, attachmentArgs: KeyValue}, options); } @@ -807,44 +810,50 @@ class JMXGenerator { addScenarios(testPlan, scenarios) { scenarios.forEach(s => { - let scenario = s.clone(); - let threadGroup = new ThreadGroup(scenario.name || ""); + if (s.enable) { + let scenario = s.clone(); - this.addScenarioVariables(threadGroup, scenario); + let threadGroup = new ThreadGroup(scenario.name || ""); - this.addScenarioHeaders(threadGroup, scenario); + this.addScenarioVariables(threadGroup, scenario); - this.addScenarioCookieManager(threadGroup, scenario); + this.addScenarioHeaders(threadGroup, scenario); - scenario.requests.forEach(request => { - if (!request.isValid()) return; - let sampler; + this.addScenarioCookieManager(threadGroup, scenario); - if (request instanceof DubboRequest) { - sampler = new DubboSample(request.name || "", new JMXDubboRequest(request, scenario.dubboConfig)); - } + scenario.requests.forEach(request => { + if (request.enable) { + if (!request.isValid()) return; + let sampler; - if (request instanceof HttpRequest) { - sampler = new HTTPSamplerProxy(request.name || "", new JMXHttpRequest(request, scenario.environment)); - this.addRequestHeader(sampler, request); - if (request.method.toUpperCase() === 'GET') { - this.addRequestArguments(sampler, request); - } else { - this.addRequestBody(sampler, request); + if (request instanceof DubboRequest) { + sampler = new DubboSample(request.name || "", new JMXDubboRequest(request, scenario.dubboConfig)); + } + + if (request instanceof HttpRequest) { + sampler = new HTTPSamplerProxy(request.name || "", new JMXHttpRequest(request, scenario.environment)); + this.addRequestHeader(sampler, request); + if (request.method.toUpperCase() === 'GET') { + this.addRequestArguments(sampler, request); + } else { + this.addRequestBody(sampler, request); + } + } + + this.addBeanShellProcessor(sampler, request); + + this.addRequestAssertion(sampler, request); + + this.addRequestExtractor(sampler, request); + + threadGroup.put(sampler); } - } + }) - this.addBeanShellProcessor(sampler, request); + testPlan.put(threadGroup); + } - this.addRequestAssertion(sampler, request); - - this.addRequestExtractor(sampler, request); - - threadGroup.put(sampler); - }) - - testPlan.put(threadGroup); }) } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 876f38fa8c..b5c3f65c10 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -397,7 +397,9 @@ export default { headers: "Headers", kv_description: "Variables are available for all requests", copy: "Copy scenario", - delete: "Delete scenario" + delete: "Delete scenario", + disable: "Disable", + enable: "Enable" }, request: { copy: "Copy request", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 312dee0e64..e11b05de12 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -397,7 +397,9 @@ export default { headers: "请求头", kv_description: "所有请求可以使用自定义变量", copy: "复制场景", - delete: "删除场景" + delete: "删除场景", + disable: "禁用", + enable: "启用" }, request: { copy: "复制请求", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 6ab426fbc4..370cb2e519 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -396,7 +396,9 @@ export default { headers: "請求頭", kv_description: "所有請求可以使用自定義變數", copy: "複製場景", - delete: "删除場景" + delete: "删除場景", + disable: "禁用", + enable: "啟用" }, request: { copy: "複製請求",