From bf3051cfe78ff35d68f948bc8cfb1b5bb2f4c634 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:31:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?'=E5=8E=BB=E6=8E=89=E5=8E=9F=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=A4=8D=E6=9D=82=E5=BA=A6=E6=A0=A1=E9=AA=8C'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/settings/personal/PersonSetting.vue | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontend/src/business/components/settings/personal/PersonSetting.vue b/frontend/src/business/components/settings/personal/PersonSetting.vue index 343975f7a3..07050c3259 100644 --- a/frontend/src/business/components/settings/personal/PersonSetting.vue +++ b/frontend/src/business/components/settings/personal/PersonSetting.vue @@ -128,12 +128,6 @@ rules:{ password: [ {required: true, message: this.$t('user.input_password'), trigger: 'blur'}, - { - required: true, - pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/, - message: this.$t('member.password_format_is_incorrect'), - trigger: 'blur' - } ], newpassword: [ {required: true, message: this.$t('user.input_password'), trigger: 'blur'}, From 4bb76b6f507d44f477ccce8f5e52f2460f42dc14 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 16 Jun 2020 16:33:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=89=8D=E6=A3=80=E6=9F=A5kafka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PerformanceTestService.java | 33 +++++++++++++++++++ .../resources/i18n/messages_en_US.properties | 1 + .../resources/i18n/messages_zh_CN.properties | 1 + .../resources/i18n/messages_zh_TW.properties | 1 + 4 files changed, 36 insertions(+) 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 b539a94f88..87da37f9f6 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -11,6 +11,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.config.KafkaProperties; import io.metersphere.controller.request.OrderRequest; import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.LoadTestDTO; @@ -28,6 +29,9 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.Socket; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; @@ -62,6 +66,8 @@ public class PerformanceTestService { private TestResourceService testResourceService; @Resource private ReportService reportService; + @Resource + private KafkaProperties kafkaProperties; public List list(QueryTestPlanRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); @@ -197,6 +203,8 @@ public class PerformanceTestService { if (StringUtils.equalsAny(loadTest.getStatus(), PerformanceTestStatus.Running.name(), PerformanceTestStatus.Starting.name())) { MSException.throwException(Translator.get("load_test_is_running")); } + // check kafka + checkKafka(); LogUtil.info("Load test started " + loadTest.getName()); // engine type (NODE) @@ -212,6 +220,31 @@ public class PerformanceTestService { return engine.getReportId(); } + private void checkKafka() { + String bootstrapServers = kafkaProperties.getBootstrapServers(); + String[] servers = StringUtils.split(bootstrapServers, ","); + try { + for (String s : servers) { + String[] ipAndPort = s.split(":"); + //1,建立tcp + String ip = ipAndPort[0]; + int port = Integer.parseInt(ipAndPort[1]); + Socket soc = new Socket(); + soc.connect(new InetSocketAddress(ip, port), 1000); // 1s timeout + //2.输入内容 + String content = "1010"; + byte[] bs = content.getBytes(); + OutputStream os = soc.getOutputStream(); + os.write(bs); + //3.关闭 + soc.close(); + } + } catch (Exception e) { + LogUtil.error(e); + MSException.throwException(Translator.get("load_test_kafka_invalid")); + } + } + private void startEngine(LoadTestWithBLOBs loadTest, Engine engine) { LoadTestReport testReport = new LoadTestReport(); testReport.setId(engine.getReportId()); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 26299d19df..00701a76ea 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -34,6 +34,7 @@ run_load_test_file_not_found=Unable to run test, unable to get test file meta in run_load_test_file_content_not_found=Cannot run test, cannot get test file content, test ID= run_load_test_file_init_error=Failed to run test, failed to initialize run environment, test ID= load_test_is_running=Load test is running, please wait. +load_test_kafka_invalid=Kafka is not available, please check the configuration cannot_edit_load_test_running=Cannot modify the running test test_not_found=Test cannot be found: test_not_running=Test is not running diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index a4a484939f..4605816ba7 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -34,6 +34,7 @@ run_load_test_file_not_found=无法运行测试,无法获取测试文件元信 run_load_test_file_content_not_found=无法运行测试,无法获取测试文件内容,测试ID: run_load_test_file_init_error=无法运行测试,初始化运行环境失败,测试ID: load_test_is_running=测试正在运行, 请等待 +load_test_kafka_invalid=Kafka 不可用,请检查配置 cannot_edit_load_test_running=不能修改正在运行的测试 test_not_found=测试不存在: test_not_running=测试未运行 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 84ff087fb3..265ae7182f 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -34,6 +34,7 @@ run_load_test_file_not_found=無法運行測試,無法獲取測試文件元信 run_load_test_file_content_not_found=無法運行測試,無法獲取測試文件內容,測試ID: run_load_test_file_init_error=無法運行測試,初始化運行環境失敗,測試ID: load_test_is_running=測試正在運行, 請等待 +load_test_kafka_invalid=Kafka 不可用,請檢查配置 cannot_edit_load_test_running=不能修改正在運行的測試 test_not_found=測試不存在: test_not_running=測試未運行