Merge branch 'v1.0' of https://github.com/metersphere/server into v1.0
This commit is contained in:
commit
d855dca091
|
@ -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<LoadTestDTO> 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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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=测试未运行
|
||||
|
|
|
@ -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=測試未運行
|
||||
|
|
|
@ -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'},
|
||||
|
|
Loading…
Reference in New Issue