This commit is contained in:
chenjianxing 2020-04-29 15:50:21 +08:00
commit 1c155bd982
16 changed files with 666 additions and 135 deletions

View File

@ -0,0 +1,27 @@
package io.metersphere.base.domain;
import java.io.Serializable;
public class LoadTestReportLog implements Serializable {
private String reportId;
private String content;
private static final long serialVersionUID = 1L;
public String getReportId() {
return reportId;
}
public void setReportId(String reportId) {
this.reportId = reportId == null ? null : reportId.trim();
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}

View File

@ -0,0 +1,270 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class LoadTestReportLogExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public LoadTestReportLogExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andReportIdIsNull() {
addCriterion("report_id is null");
return (Criteria) this;
}
public Criteria andReportIdIsNotNull() {
addCriterion("report_id is not null");
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,35 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.LoadTestReportLog;
import io.metersphere.base.domain.LoadTestReportLogExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface LoadTestReportLogMapper {
long countByExample(LoadTestReportLogExample example);
int deleteByExample(LoadTestReportLogExample example);
int deleteByPrimaryKey(String reportId);
int insert(LoadTestReportLog record);
int insertSelective(LoadTestReportLog record);
List<LoadTestReportLog> selectByExampleWithBLOBs(LoadTestReportLogExample example);
List<LoadTestReportLog> selectByExample(LoadTestReportLogExample example);
LoadTestReportLog selectByPrimaryKey(String reportId);
int updateByExampleSelective(@Param("record") LoadTestReportLog record, @Param("example") LoadTestReportLogExample example);
int updateByExampleWithBLOBs(@Param("record") LoadTestReportLog record, @Param("example") LoadTestReportLogExample example);
int updateByExample(@Param("record") LoadTestReportLog record, @Param("example") LoadTestReportLogExample example);
int updateByPrimaryKeySelective(LoadTestReportLog record);
int updateByPrimaryKeyWithBLOBs(LoadTestReportLog record);
}

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.LoadTestReportLogMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.LoadTestReportLog">
<id column="report_id" jdbcType="VARCHAR" property="reportId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestReportLog">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
report_id
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportLogExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from load_test_report_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.LoadTestReportLogExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from load_test_report_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from load_test_report_log
where report_id = #{reportId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from load_test_report_log
where report_id = #{reportId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.LoadTestReportLogExample">
delete from load_test_report_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestReportLog">
insert into load_test_report_log (report_id, content)
values (#{reportId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestReportLog">
insert into load_test_report_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reportId != null">
report_id,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestReportLogExample" resultType="java.lang.Long">
select count(*) from load_test_report_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update load_test_report_log
<set>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update load_test_report_log
set report_id = #{record.reportId,jdbcType=VARCHAR},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update load_test_report_log
set report_id = #{record.reportId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.LoadTestReportLog">
update load_test_report_log
<set>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where report_id = #{reportId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.LoadTestReportLog">
update load_test_report_log
set content = #{content,jdbcType=LONGVARCHAR}
where report_id = #{reportId,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -20,6 +20,7 @@ public class KafkaProperties {
private String clientId;
private String connectionsMaxIdleMs;
private KafkaProperties.Ssl ssl = new KafkaProperties.Ssl();
private KafkaProperties.Log log = new KafkaProperties.Log();
public String getAcks() {
return acks;
@ -239,4 +240,24 @@ public class KafkaProperties {
public void setSsl(Ssl ssl) {
this.ssl = ssl;
}
public static class Log {
private String topic;
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
}
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
}

View File

@ -15,6 +15,7 @@ public class EngineContext {
private String reportId;
private Map<String, Object> properties = new HashMap<>();
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
public String getTestId() {
return testId;
@ -48,6 +49,14 @@ public class EngineContext {
this.properties.putAll(props);
}
public Map<String, String> getEnv() {
return env;
}
public void setEnv(Map<String, String> env) {
this.env = env;
}
public Object getProperty(String key) {
return this.properties.get(key);
}

View File

@ -9,6 +9,7 @@ import io.metersphere.base.domain.TestResourcePool;
import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.constants.ResourcePoolTypeEnum;
import io.metersphere.commons.exception.MSException;
import io.metersphere.config.KafkaProperties;
import io.metersphere.engine.docker.DockerTestEngine;
import io.metersphere.engine.kubernetes.KubernetesTestEngine;
import io.metersphere.i18n.Translator;
@ -31,6 +32,7 @@ import java.util.stream.Collectors;
public class EngineFactory {
private static FileService fileService;
private static TestResourcePoolService testResourcePoolService;
private static KafkaProperties kafkaProperties;
public static Engine createEngine(LoadTestWithBLOBs loadTest) {
String resourcePoolId = loadTest.getTestResourcePoolId();
@ -78,6 +80,12 @@ public class EngineFactory {
engineContext.setResourcePoolId(loadTest.getTestResourcePoolId());
engineContext.setStartTime(startTime);
engineContext.setReportId(reportId);
HashMap<String, String> env = new HashMap<String, String>() {{
put("BOOTSTRAP_SERVERS", kafkaProperties.getBootstrapServers());
put("LOG_TOPIC", kafkaProperties.getLog().getTopic());
put("REPORT_ID", reportId);
}};
engineContext.setEnv(env);
if (StringUtils.isNotEmpty(loadTest.getLoadConfiguration())) {
final JSONArray jsonArray = JSONObject.parseArray(loadTest.getLoadConfiguration());
@ -130,4 +138,9 @@ public class EngineFactory {
public void setTestResourcePoolService(TestResourcePoolService testResourcePoolService) {
EngineFactory.testResourcePoolService = testResourcePoolService;
}
@Resource
public void setKafkaProperties(KafkaProperties kafkaProperties) {
EngineFactory.kafkaProperties = kafkaProperties;
}
}

View File

@ -82,6 +82,7 @@ public class DockerTestEngine extends AbstractEngine {
testRequest.setFileString(content);
testRequest.setImage(JMETER_IMAGE);
testRequest.setTestData(context.getTestData());
testRequest.setEnv(context.getEnv());
restTemplate.postForObject(uri, testRequest, String.class);
}

View File

@ -9,6 +9,7 @@ public class TestRequest extends BaseRequest {
private String fileString;
private String image;
private Map<String, String> testData = new HashMap<>();
private Map<String, String> env = new HashMap<>();
public int getSize() {
return size;
@ -41,4 +42,12 @@ public class TestRequest extends BaseRequest {
public void setTestData(Map<String, String> testData) {
this.testData = testData;
}
public Map<String, String> getEnv() {
return env;
}
public void setEnv(Map<String, String> env) {
this.env = env;
}
}

View File

@ -5,7 +5,6 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportDetailMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
@ -22,8 +21,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -51,6 +48,8 @@ public class PerformanceTestService {
private LoadTestReportDetailMapper loadTestReportDetailMapper;
@Resource
private ExtLoadTestReportDetailMapper extLoadTestReportDetailMapper;
@Resource
private LoadTestReportLogMapper loadTestReportLogMapper;
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
return extLoadTestMapper.list(request);
@ -201,6 +200,11 @@ public class PerformanceTestService {
extLoadTestReportMapper.appendLine(testReport.getId(), "\n");
// append \n
extLoadTestReportDetailMapper.appendLine(testReport.getId(), "\n");
// 保存 load_test_report_log
LoadTestReportLog record = new LoadTestReportLog();
record.setReportId(testReport.getId());
record.setContent(StringUtils.EMPTY);
loadTestReportLogMapper.insert(record);
} catch (MSException e) {
LogUtil.error(e);
loadTest.setStatus(PerformanceTestStatus.Error.name());

View File

@ -15,6 +15,7 @@ import io.metersphere.dto.OrganizationMemberDTO;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.dto.UserRoleHelpDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.user.SessionUser;
import io.metersphere.user.SessionUtils;
import org.apache.commons.lang3.StringUtils;
@ -22,7 +23,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@ -54,11 +54,11 @@ public class UserService {
private void checkUserParam(User user) {
if (StringUtils.isBlank(user.getName())) {
MSException.throwException("user_name_empty");
MSException.throwException(Translator.get("user_name_is_null"));
}
if (StringUtils.isBlank(user.getEmail())) {
MSException.throwException("user_email_empty");
MSException.throwException(Translator.get("user_email_is_null"));
}
// password
}
@ -76,7 +76,7 @@ public class UserService {
criteria.andEmailEqualTo(user.getEmail());
List<User> userList = userMapper.selectByExample(userExample);
if (!CollectionUtils.isEmpty(userList)) {
MSException.throwException("user_email_is_exist");
MSException.throwException(Translator.get("user_email_already_exists"));
}
userMapper.insertSelective(user);
}
@ -128,107 +128,6 @@ public class UserService {
userMapper.updateByPrimaryKeySelective(user);
}
/*public List<Role> getUserRolesList(String userId) {
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<UserRole> userRolesList = userRoleMapper.selectByExample(userRoleExample);
List<String> roleIds = userRolesList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
RoleExample roleExample = new RoleExample();
roleExample.createCriteria().andIdIn(roleIds);
return roleMapper.selectByExample(roleExample);
}
public List<UserRoleDTO> getUserRoleList(String userId) {
if (StringUtils.isEmpty(userId)) {
return new ArrayList<>();
}
return convertUserRoleDTO(extUserRoleMapper.getUserRoleHelpList(userId));
}*/
private List<UserRoleDTO> convertUserRoleDTO(List<UserRoleHelpDTO> helpDTOList) {
StringBuilder buffer = new StringBuilder();
Map<String, UserRoleDTO> roleMap = new HashMap<>();
List<UserRoleDTO> resultList = new ArrayList<>();
List<UserRoleDTO> otherList = new ArrayList<>();
Set<String> orgSet = new HashSet<>();
Set<String> workspaceSet = new HashSet<>();
for (UserRoleHelpDTO helpDTO : helpDTOList) {
UserRoleDTO userRoleDTO = roleMap.get(helpDTO.getSourceId());
if (userRoleDTO == null) {
userRoleDTO = new UserRoleDTO();
if (!StringUtils.isEmpty(helpDTO.getParentId())) {
workspaceSet.add(helpDTO.getParentId());
userRoleDTO.setType("workspace");
} else {
orgSet.add(helpDTO.getSourceId());
userRoleDTO.setType("organization");
}
userRoleDTO.setId(helpDTO.getSourceId());
userRoleDTO.setRoleId(helpDTO.getRoleId());
userRoleDTO.setName(helpDTO.getSourceName());
userRoleDTO.setParentId(helpDTO.getParentId());
userRoleDTO.setDesc(helpDTO.getRoleName());
} else {
userRoleDTO.setDesc(userRoleDTO.getDesc() + "," + helpDTO.getRoleName());
}
roleMap.put(helpDTO.getSourceId(), userRoleDTO);
}
if (!StringUtils.isEmpty(buffer.toString())) {
UserRoleDTO dto = new UserRoleDTO();
dto.setId("admin");
dto.setType("admin");
dto.setDesc(buffer.toString());
resultList.add(dto);
}
for (String org : orgSet) {
workspaceSet.remove(org);
}
List<UserRoleDTO> orgWorkSpace = new ArrayList<>(roleMap.values());
if (!CollectionUtils.isEmpty(workspaceSet)) {
for (String orgId : workspaceSet) {
Organization organization = organizationMapper.selectByPrimaryKey(orgId);
if (organization != null) {
UserRoleDTO dto = new UserRoleDTO();
dto.setId(orgId);
dto.setName(organization.getName());
dto.setSwitchable(false);
dto.setType("organization");
orgWorkSpace.add(dto);
}
}
}
orgWorkSpace.sort((o1, o2) -> {
if (o1.getParentId() == null) {
return -1;
}
if (o2.getParentId() == null) {
return 1;
}
return o1.getParentId().compareTo(o2.getParentId());
});
resultList.addAll(orgWorkSpace);
resultList.addAll(otherList);
return resultList;
}
public void switchUserRole(UserDTO user, String sign, String sourceId) {
User newUser = new User();
if (StringUtils.equals("organization", sign)) {
@ -325,20 +224,16 @@ public class UserService {
public boolean checkUserPassword(String userId, String password) {
if (StringUtils.isBlank(userId)) {
MSException.throwException("Username cannot be null");
MSException.throwException(Translator.get("user_name_is_null"));
}
if (StringUtils.isBlank(password)) {
MSException.throwException("Password cannot be null");
MSException.throwException(Translator.get("password_is_null"));
}
UserExample example = new UserExample();
example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password));
return userMapper.countByExample(example) > 0;
}
public List<OrganizationMemberDTO> getOrganizationMemberDTO(QueryOrgMemberRequest request) {
return extUserRoleMapper.getOrganizationMemberDTO(request);
}
/**
* 查询该组织外的其他用户列表
*/

View File

@ -20,7 +20,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@ -59,9 +58,9 @@ public class WorkspaceService {
if (workspaceMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("workspace_name_already_exists"));
}
workspace.setId(UUID.randomUUID().toString()); // 设置ID
workspace.setId(UUID.randomUUID().toString());
workspace.setCreateTime(currentTime);
workspace.setUpdateTime(currentTime); // 首次 update time
workspace.setUpdateTime(currentTime);
workspaceMapper.insertSelective(workspace);
} else {
workspace.setUpdateTime(currentTime);
@ -112,19 +111,6 @@ public class WorkspaceService {
}
}
public void checkWorkspaceOwnerByTestManager(String workspaceId) {
checkWorkspaceIsExist(workspaceId);
SessionUser user = SessionUtils.getUser();
List<String> wsIds = user.getUserRoles().stream()
.filter(ur -> RoleConstants.TEST_MANAGER.equals(ur.getRoleId()))
.map(UserRole::getSourceId)
.collect(Collectors.toList());
boolean contains = wsIds.contains(workspaceId);
if (!contains) {
MSException.throwException(Translator.get("workspace_does_not_belong_to_user"));
}
}
public void checkWorkspaceOwner(String workspaceId) {
checkWorkspaceIsExist(workspaceId);
WorkspaceExample example = new WorkspaceExample();
@ -150,7 +136,7 @@ public class WorkspaceService {
WorkspaceExample example = new WorkspaceExample();
example.createCriteria().andIdEqualTo(workspaceId);
if (workspaceMapper.countByExample(example) == 0) {
MSException.throwException("workspace_not_exist");
MSException.throwException(Translator.get("workspace_not_exists"));
}
}

View File

@ -82,6 +82,14 @@ CREATE TABLE IF NOT EXISTS `load_test_report_result` (
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `load_test_report_log` (
`report_id` varchar(50) NOT NULL,
`content` longtext,
PRIMARY KEY (`report_id`)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_bin;
CREATE TABLE IF NOT EXISTS `organization` (
`id` varchar(50) NOT NULL COMMENT 'Organization ID',

View File

@ -23,4 +23,9 @@ max_thread_insufficient=The number of concurrent users exceeds
cannot_edit_load_test_running=Cannot modify the running test
test_not_found=Test cannot be found:
test_not_running=Test is not running
before_delete_plan=There is an associated test case under this plan, please unlink it first!
before_delete_plan=There is an associated test case under this plan, please unlink it first!
user_email_already_exists=User email already exists
user_name_is_null=User name cannot be null
user_email_is_null=User email cannot be null
password_is_null=Password cannot be null
workspace_not_exists=Workspace is not exists

View File

@ -23,4 +23,9 @@ max_thread_insufficient=并发用户数超额
cannot_edit_load_test_running=不能修改正在运行的测试
test_not_found=测试不存在:
test_not_running=测试未运行
before_delete_plan=该计划下存在关联测试用例,请先取消关联!
before_delete_plan=该计划下存在关联测试用例,请先取消关联!
user_email_already_exists=用户邮箱已存在
user_name_is_null=用户名不能为空
user_email_is_null=用户邮箱不能为空
password_is_null=密码不能为空
workspace_not_exists=工作空间不存在

View File

@ -5,7 +5,8 @@
stripe
border
style="width: 100%"
:default-sort = "{prop: 'samples', order: 'descending'}"
show-summary
:summary-method="getSummaries"
>
<el-table-column label="Requests" fixed width="450" align="center">
<el-table-column
@ -103,6 +104,54 @@
this.tableData = res.data;
})
},
getSummaries(param) {
const {data} = param;
const sums = []
let allSamples = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.samples);
}, 0);
let failSize = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.ko);
}, 0);
let averageTimeTotal = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.average) * parseFloat(currentValue.samples);
}, 0);
let tp90Total = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.tp90) * parseFloat(currentValue.samples);
}, 0);
let tp95Total = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.tp95) * parseFloat(currentValue.samples);
}, 0);
let tp99Total = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.tp99) * parseFloat(currentValue.samples);
}, 0);
let transactions = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.transactions);
}, 0);
let received = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.received);
}, 0);
let sent = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.sent);
}, 0);
let error = (Math.round(failSize / allSamples * 10000) / 100) + '%';
let averageTime = (averageTimeTotal / allSamples).toFixed(2);
let tp90 = (tp90Total / allSamples).toFixed(2);
let tp95 = (tp95Total / allSamples).toFixed(2);
let tp99 = (tp99Total / allSamples).toFixed(2);
let min = Math.min.apply(Math, data.map(function (o) {
return parseFloat(o.min)
}));
let max = Math.max.apply(Math, data.map(function (o) {
return parseFloat(o.max)
}));
sums.push('Total', allSamples, failSize, error, averageTime, min, max, tp90, tp95, tp99, transactions, received, sent);
return sums;
}
},
watch: {
status() {
@ -111,7 +160,7 @@
}
}
},
props: ['id','status']
props: ['id', 'status']
}
</script>