diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index a918fd4589..554d8fb504 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -24,7 +24,6 @@ import org.apache.jmeter.testelement.TestElement; import org.apache.jorphan.collections.HashTree; import java.util.List; -import java.util.stream.Collectors; @Data @EqualsAndHashCode(callSuper = true) @@ -51,7 +50,7 @@ public class MsJDBCSampler extends MsTestElement { @JSONField(ordinal = 28) private String dataSourceId; @JSONField(ordinal = 29) - private String protocol="SQL"; + private String protocol = "SQL"; @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { @@ -62,7 +61,8 @@ public class MsJDBCSampler extends MsTestElement { this.getRefElement(this); } if (StringUtils.isNotEmpty(dataSourceId)) { - initDataSource(); + this.dataSource = null; + this.initDataSource(); } if (this.dataSource == null) { MSException.throwException("数据源为空无法执行"); @@ -79,14 +79,16 @@ public class MsJDBCSampler extends MsTestElement { private void initDataSource() { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); - ApiTestEnvironmentWithBLOBs environment = environmentService.get(this.dataSourceId); + ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId); if (environment != null && environment.getConfig() != null) { - EnvironmentConfig config = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); - if (CollectionUtils.isNotEmpty(config.getDatabaseConfigs())) { - List databaseConfigs = config.getDatabaseConfigs().stream().filter((DatabaseConfig d) -> this.dataSourceId.equals(d.getId())).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(databaseConfigs)) { - this.dataSource = databaseConfigs.get(0); - } + EnvironmentConfig envConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); + if (CollectionUtils.isNotEmpty(envConfig.getDatabaseConfigs())) { + envConfig.getDatabaseConfigs().forEach(item -> { + if (item.getId().equals(this.dataSourceId)) { + this.dataSource = item; + return; + } + }); } } } diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index 489d58abfb..ae9fbf35be 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -297,6 +297,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl requestResult.setHeaders(result.getRequestHeaders()); requestResult.setRequestSize(result.getSentBytes()); requestResult.setStartTime(result.getStartTime()); + requestResult.setEndTime(result.getEndTime()); requestResult.setTotalAssertions(result.getAssertionResults().length); requestResult.setSuccess(result.isSuccessful()); requestResult.setError(result.getErrorCount()); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java b/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java index d3c20cac4e..b90c0c0db0 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java @@ -18,6 +18,8 @@ public class RequestResult { private long startTime; + private long endTime; + private int error; private boolean success; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 0fcf3f2735..6c945f5d2e 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -163,6 +163,7 @@ public class ApiScenarioReportService { String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError())); testPlanApiScenario.setPassRate(passRate); testPlanApiScenario.setReportId(report.getId()); + testPlanApiScenario.setUpdateTime(System.currentTimeMillis()); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); } returnReport = report; @@ -220,6 +221,7 @@ public class ApiScenarioReportService { apiScenarioReportDetailMapper.insert(detail); testPlanApiScenario.setReportId(report.getId()); + testPlanApiScenario.setUpdateTime(System.currentTimeMillis()); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); lastReport = report; diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 387ca56312..a641c1331e 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 387ca56312b62ae5edb3d7f34afa08946d86d621 +Subproject commit a641c1331e1813b5294a1d0e380b8682a78754e1 diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 7017e65001..d8b76fefaf 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -14,7 +14,7 @@ - + { + scenario.requestResults.forEach((request) => { + if (request.startTime && Number(request.startTime) < startTime) { + startTime = request.startTime; + } + if (request.endTime && Number(request.endTime) > endTime) { + endTime = request.endTime; + } + }) + }) + if (startTime < endTime) { + this.totalTime = endTime - startTime + 100; + } + } + }, requestResult(requestResult) { this.active(); this.isRequestResult = false; diff --git a/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue b/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue index 7c1ccaf628..9fad795746 100644 --- a/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue +++ b/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue @@ -1,17 +1,21 @@ @@ -68,6 +68,16 @@ this.$emit('change', this.hostTable); }, add: function (r) { + let row = { + ip: '', + domain: '', + status: 'edit', + annotation: '', + uuid: this.uuid(), + } + this.hostTable.push(row); + }, + copy: function (r) { let row = { ip: '', domain: '', diff --git a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue index 91ff1f1c4e..7d2c7cf487 100644 --- a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue +++ b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue @@ -4,7 +4,7 @@ {{$t('commons.trigger_mode.schedule')}} {{$t('commons.trigger_mode.schedule')}} {{$t('commons.trigger_mode.api')}} - 用例触发 + {{$t('commons.trigger_mode.case')}} diff --git a/frontend/src/business/components/performance/report/PerformanceTestReport.vue b/frontend/src/business/components/performance/report/PerformanceTestReport.vue index 5fe70104e4..8034e345ea 100644 --- a/frontend/src/business/components/performance/report/PerformanceTestReport.vue +++ b/frontend/src/business/components/performance/report/PerformanceTestReport.vue @@ -143,6 +143,7 @@ export default { {text: this.$t('commons.trigger_mode.manual'), value: 'MANUAL'}, {text: this.$t('commons.trigger_mode.schedule'), value: 'SCHEDULE'}, {text: this.$t('commons.trigger_mode.api'), value: 'API'}, + {text: this.$t('commons.trigger_mode.case'), value: 'CASE'}, ], buttons: [ { diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index ad7a13f10a..791dcb6ef2 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -31,14 +31,14 @@ @select="handleSelect" @cell-mouse-enter="showPopover" row-key="id" - class="test-content adjust-table ms-select-all" + class="test-content adjust-table ms-select-all-fixed" ref="table" @row-click="handleEdit"> -