chore: sdk对JMeter相关依赖移动到plugin中

This commit is contained in:
fit2-zhao 2024-01-30 11:05:29 +08:00 committed by Craftsman
parent c7f697debe
commit 9653799413
6 changed files with 23 additions and 102 deletions

View File

@ -29,6 +29,24 @@
<artifactId>jorphan</artifactId>
<version>${jmeter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_components</artifactId>
<version>${jmeter.version}</version>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.metersphere</groupId>
<artifactId>metersphere-jmeter-functions</artifactId>
<version>${metersphere-jmeter-functions.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -14,23 +14,6 @@
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_components</artifactId>
<version>${jmeter.version}</version>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.metersphere</groupId>
<artifactId>metersphere-jmeter-functions</artifactId>
<version>${metersphere-jmeter-functions.version}</version>
</dependency>
<!-- 基础包 -->
<dependency>
<groupId>io.metersphere</groupId>

View File

@ -1,82 +0,0 @@
package io.metersphere.sdk.util;
import io.metersphere.sdk.dto.api.result.RequestResult;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.samplers.SampleResult;
import java.util.*;
import java.util.stream.Collectors;
/**
* 重试报告处理util
*/
public class RetryResultUtils {
public final static String RETRY = "MsRetry_";
public final static String RETRY_CN = "RETRY";
public final static String RETRY_FIRST_CN = "RETRY_FIRST";
public final static String MS_CLEAR_LOOPS_VAR = "MS_CLEAR_LOOPS_VAR_";
public final static int RETRY_RES_NUM = 11;
/**
* 合并掉重试结果保留最后十次重试结果
*/
public static void mergeRetryResults(List<RequestResult> results) {
if (CollectionUtils.isNotEmpty(results)) {
Map<String, List<RequestResult>> resultMap = results.stream().collect(Collectors.groupingBy(RequestResult::getResourceId));
List<RequestResult> list = new LinkedList<>();
resultMap.forEach((k, v) -> {
if (CollectionUtils.isNotEmpty(v)) {
// 校验是否含重试结果
List<RequestResult> isRetryResults = v
.stream()
.filter(c -> StringUtils.isNotEmpty(c.getName()) && c.getName().startsWith(RETRY))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(isRetryResults)) {
// 取最后执行的10
if (v.size() > 10) {
v.sort(Comparator.comparing(RequestResult::getResourceId));
RequestResult sampleResult = v.getFirst();
List<RequestResult> topTens = v.subList(v.size() - RETRY_RES_NUM, v.size());
topTens.set(0, sampleResult);
assembleName(topTens);
list.addAll(topTens);
} else {
assembleName(v);
list.addAll(v);
}
} else {
// 成功的结果
list.addAll(v);
}
}
});
results.clear();
results.addAll(list);
}
}
private static void assembleName(List<RequestResult> list) {
// 名称排序处理
for (int i = 0; i < list.size(); i++) {
list.get(i).setName(list.get(i).getName().replaceAll(RETRY, RETRY_CN));
if (list.get(i).getName().endsWith("_")) {
list.get(i).setName(list.get(i).getName().substring(0, list.get(i).getName().length() - 1));
}
if (i == 0) {
list.get(i).setName(StringUtils.isNotEmpty(list.get(i).getName())
? RETRY_FIRST_CN + "_" + list.get(i).getName() : RETRY_FIRST_CN);
}
}
}
public static List<SampleResult> clearLoops(List<SampleResult> results) {
if (CollectionUtils.isNotEmpty(results)) {
return results.stream().filter(sampleResult ->
StringUtils.isNotEmpty(sampleResult.getSampleLabel())
&& !sampleResult.getSampleLabel().startsWith(MS_CLEAR_LOOPS_VAR))
.collect(Collectors.toList());
}
return results;
}
}

View File

@ -2,9 +2,9 @@ package io.metersphere.api.dto.definition;
import io.metersphere.system.dto.sdk.BasePageRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
import java.io.Serial;
import java.io.Serializable;

View File

@ -1,14 +1,16 @@
package io.metersphere.project.dto.environment;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
import java.io.Serial;
import java.io.Serializable;
@Data
public class EnvironmentGroupProjectDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "环境组id")
private String environmentGroupId;

View File

@ -2,9 +2,9 @@ package io.metersphere.project.dto.environment;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
import java.util.List;