This commit is contained in:
chenjianxing 2020-07-24 18:22:46 +08:00
commit 3841ff55d8
16 changed files with 1672 additions and 45 deletions

View File

@ -122,12 +122,14 @@
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and api_test.${key} in
and api_test.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
</foreach>
</if>
</where>

View File

@ -89,10 +89,20 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and r.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='status'">
and r.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and r.trigger_mode in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>

View File

@ -51,7 +51,8 @@
</if>
</sql>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testplan.QueryTestPlanRequest">
<select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testplan.QueryTestPlanRequest">
select load_test.*, project.name as project_name, user.name as user_name
from load_test
left join project on load_test.project_id = project.id
@ -83,7 +84,7 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and load_test.${key} in
and load_test.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>

View File

@ -3,12 +3,12 @@
<mapper namespace="io.metersphere.base.mapper.ext.ExtLoadTestReportMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.LoadTestReport">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="test_id" jdbcType="VARCHAR" property="testId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
</resultMap>
<sql id="Base_Column_List">
@ -95,10 +95,21 @@
<if test="reportRequest.filters != null and reportRequest.filters.size() > 0">
<foreach collection="reportRequest.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and ltr.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='status'">
and ltr.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and ltr.trigger_mode in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>

View File

@ -16,7 +16,7 @@ public interface ExtTestCaseMapper {
List<TestCaseDTO> listByMethod(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> listBytestCaseIds(@Param("request") TestCaseBatchRequest request);
List<TestCaseDTO> listByTestCaseIds(@Param("request") TestCaseBatchRequest request);
TestCase getMaxNumByProjectId(@Param("projectId") String projectId);

View File

@ -128,10 +128,20 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and test_case.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
@ -168,10 +178,26 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and test_case.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='type'">
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
@ -198,7 +224,7 @@
</if>
</where>
</select>
<select id="listBytestCaseIds" resultType="io.metersphere.track.dto.TestCaseDTO">
<select id="listByTestCaseIds" resultType="io.metersphere.track.dto.TestCaseDTO">
select test_case.*,api_test.name as apiName,load_test.name AS performName from test_case left join api_test on
test_case.test_id=api_test.id left join load_test on test_case.test_id=load_test.id
<where>

View File

@ -95,7 +95,8 @@
</if>
</sql>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
<select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
select test_plan.*, project.name as project_name
from test_plan
left join project on test_plan.project_id = project.id
@ -126,10 +127,21 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and ${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='stage'">
and test_plan.stage in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_plan.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
@ -149,7 +161,7 @@
where test_plan.workspace_id = #{request.workspaceId}
and (test_plan.principal = #{request.principal}
<if test="request.planIds != null and request.planIds.size() > 0">
or test_plan.id in
or test_plan.id in
<foreach collection="request.planIds" item="planId" open="(" close=")" separator=",">
#{planId}
</foreach>

View File

@ -157,10 +157,26 @@
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and ${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='type'">
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>

View File

@ -44,7 +44,7 @@ public class TestCaseController {
return testCaseService.listTestCase(request);
}
/*项目下自动测试*/
@GetMapping("/list/method/{projectId}")
public List<TestCaseDTO> listByMethod(@PathVariable String projectId) {
QueryTestCaseRequest request = new QueryTestCaseRequest();

View File

@ -32,6 +32,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -98,17 +99,45 @@ public class TestCaseService {
}
private void checkTestCaseExist(TestCaseWithBLOBs testCase) {
if (testCase.getName() != null) {
// 全部字段值相同才判断为用例存在
if (testCase != null) {
TestCaseExample example = new TestCaseExample();
TestCaseExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(testCase.getName())
.andProjectIdEqualTo(testCase.getProjectId());
.andProjectIdEqualTo(testCase.getProjectId())
.andNodeIdEqualTo(testCase.getNodeId())
.andNodePathEqualTo(testCase.getNodePath())
.andTypeEqualTo(testCase.getType())
.andMaintainerEqualTo(testCase.getMaintainer())
.andPriorityEqualTo(testCase.getPriority())
.andMethodEqualTo(testCase.getMethod());
if (StringUtils.isNotBlank(testCase.getTestId())) {
criteria.andTestIdEqualTo(testCase.getTestId());
}
if (StringUtils.isNotBlank(testCase.getPrerequisite())) {
criteria.andPrerequisiteEqualTo(testCase.getPrerequisite());
}
if (StringUtils.isNotBlank(testCase.getId())) {
criteria.andIdNotEqualTo(testCase.getId());
}
if (testCaseMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("test_case_already_exists"));
List<TestCaseWithBLOBs> caseList = testCaseMapper.selectByExampleWithBLOBs(example);
// 如果上边字段全部相同去检查 steps remark
if (!CollectionUtils.isEmpty(caseList)) {
caseList.forEach(tc -> {
String steps = tc.getSteps();
String remark = tc.getRemark();
if (StringUtils.equals(steps, testCase.getSteps()) && StringUtils.equals(remark, testCase.getRemark())) {
MSException.throwException(Translator.get("test_case_already_exists"));
}
});
}
}
}
@ -324,7 +353,7 @@ public class TestCaseService {
}
private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) {
List<TestCaseDTO> TestCaseList = extTestCaseMapper.listBytestCaseIds(request);
List<TestCaseDTO> TestCaseList = extTestCaseMapper.listByTestCaseIds(request);
List<TestCaseExcelData> list = new ArrayList<>();
SessionUser user = SessionUtils.getUser();
StringBuilder step = new StringBuilder("");

View File

@ -0,0 +1,37 @@
FROM alpine:latest
LABEL maintainer="support@fit2cloud.com"
ENV JMETER_VERSION "5.2.1"
#定义时区参数
ENV TZ=Asia/Shanghai
RUN apk update && \
apk upgrade && \
apk add --update openjdk8-jre wget tar bash && \
wget https://mirrors.tuna.tsinghua.edu.cn/apache/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz && \
wget https://jmeter-plugins.org/files/packages/jpgc-casutg-2.9.zip && \
wget https://jmeter-plugins.org/files/packages/jpgc-tst-2.5.zip && \
wget https://github.com/metersphere/jmeter-backend-listener-kafka/releases/download/v1.0.2/jmeter.backendlistener.kafka-1.0.2.jar && \
wget https://github.com/metersphere/jmeter-plugins-for-apache-dubbo/releases/download/2.7.7/jmeter-plugins-dubbo-2.7.7-jar-with-dependencies.jar && \
mkdir -p /opt/jmeter && \
tar -zxf apache-jmeter-${JMETER_VERSION}.tgz -C /opt/jmeter/ --strip-components=1 && \
unzip -o jpgc-casutg-2.9.zip -d /tmp/ && mv /tmp/lib/ext/jmeter-plugins-casutg-2.9.jar /opt/jmeter/lib/ext && \
unzip -o jpgc-tst-2.5.zip -d /tmp/ && mv /tmp/lib/ext/jmeter-plugins-tst-2.5.jar /opt/jmeter/lib/ext && \
mv jmeter.backendlistener.kafka-1.0.2.jar /opt/jmeter/lib/ext && \
mv jmeter-plugins-dubbo-2.7.7-jar-with-dependencies.jar /opt/jmeter/lib/ext && \
rm -rf apache-jmeter-${JMETER_VERSION}.tgz && \
rm -rf jpgc-casutg-2.9.zip && \
rm -rf jpgc-tst-2.5.zip && \
rm -rf jmeter.backendlistener.kafka-1.0.2.jar && \
rm -rf jmeter-plugins-dubbo-2.7.7-jar-with-dependencies.jar && \
rm -rf /var/cache/apk/* && \
wget -O /usr/bin/tpl https://github.com/schneidexe/tpl/releases/download/v0.5.0/tpl-linux-amd64 && \
chmod +x /usr/bin/tpl && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone
ENV JMETER_HOME /opt/jmeter
ENV PATH $PATH:$JMETER_HOME/bin
ADD log4j2.xml $JMETER_HOME/bin/log4j2.xml
ADD jmeter.properties $JMETER_HOME/bin/jmeter.properties

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Configuration status="WARN" packages="org.apache.jmeter.gui.logging">
<Appenders>
<File name="jmeter-log" fileName="${sys:jmeter.logfile:-jmeter.log}" append="false">
<PatternLayout>
<pattern>%d %p %c{1.}: %m%n</pattern>
</PatternLayout>
</File>
<GuiLogEvent name="gui-log-event">
<PatternLayout>
<pattern>%d %p %c{1.}: %m%n</pattern>
</PatternLayout>
</GuiLogEvent>
<Kafka name="Kafka" topic="${env:LOG_TOPIC}">
<PatternLayout pattern="${env:REPORT_ID} ${env:RESOURCE_ID} %date %message"/>
<Property name="bootstrap.servers">${env:BOOTSTRAP_SERVERS}</Property>
</Kafka>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="jmeter-log" />
<AppenderRef ref="gui-log-event" />
<AppenderRef ref="Kafka" />
</Root>
<Logger name="org.apache.jmeter.junit" level="debug" />
<!--
<Logger name="org.apache.jmeter.control" level="debug" />
<Logger name="org.apache.jmeter.testbeans" level="debug" />
<Logger name="org.apache.jmeter.engine" level="debug" />
<Logger name="org.apache.jmeter.threads" level="debug" />
<Logger name="org.apache.jmeter.gui" level="warn" />
<Logger name="org.apache.jmeter.testelement" level="debug" />
<Logger name="org.apache.jmeter.util" level="warn" />
<Logger name="org.apache.jmeter.protocol.http" level="debug" />
-->
<!-- # For CookieManager, AuthManager etc: -->
<!--
<Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
<Logger name="org.apache.jmeter.protocol.ftp" level="warn" />
<Logger name="org.apache.jmeter.protocol.jdbc" level="debug" />
<Logger name="org.apache.jmeter.protocol.java" level="warn" />
<Logger name="org.apache.jmeter.testelements.property" level="debug" />
-->
<Logger name="org.apache.jorphan" level="info" />
<!--
# Apache HttpClient logging examples
-->
<!-- # Enable header wire + context logging - Best for Debugging -->
<!--
<Logger name="org.apache.http" level="debug" />
<Logger name="org.apache.http.wire" level="error" />
-->
<!-- # Enable full wire + context logging -->
<!-- <Logger name="org.apache.http" level="debug" /> -->
<!-- # Enable context logging for connection management -->
<!-- <Logger name="org.apache.http.impl.conn" level="debug" /> -->
<!-- # Enable context logging for connection management / request execution -->
<!--
<Logger name="org.apache.http.impl.conn" level="debug" />
<Logger name="org.apache.http.impl.client" level="debug" />
<Logger name="org.apache.http.client" level="debug" />
-->
<!--
# Reporting logging configuration examples
-->
<!-- # If you want to debug reporting, uncomment this line -->
<!-- <Logger name="org.apache.jmeter.report" level="debug" /> -->
<!--
# More user specific logging configuration examples.
-->
<!-- <Logger name="org.apache.jorphan.reflect" level="debug" /> -->
<!--
# Warning: Enabling the next debug line causes javax.net.ssl.SSLException: Received fatal alert: unexpected_message
for certain sites when used with the default HTTP Sampler
-->
<!--
<Logger name="org.apache.jmeter.util.HttpSSLProtocolSocketFactory" level="debug" />
<Logger name="org.apache.jmeter.util.JsseSSLManager" level="debug" />
-->
<!--
# Enable Proxy request debug
-->
<!-- <Logger name="org.apache.jmeter.protocol.http.proxy.HttpRequestHdr" level="debug" /> -->
</Loggers>
</Configuration>

View File

@ -0,0 +1,14 @@
FROM registry.fit2cloud.com/metersphere/jmeter-base:latest
LABEL maintainer="support@fit2cloud.com"
EXPOSE 60000
ENV SSL_DISABLED true
ENV TESTS_DIR /test
ADD run-test.sh /run-test.sh
RUN chmod +x /run-test.sh \
&& mkdir /test \
&& mkdir /jmeter-log
WORKDIR /jmeter-log/
ENTRYPOINT /run-test.sh

View File

@ -0,0 +1,4 @@
for file in ${TESTS_DIR}/*.jmx; do
echo "one shot run."
jmeter -n -t ${file} -Jserver.rmi.ssl.disable=${SSL_DISABLED}
done

View File

@ -25,7 +25,7 @@
<el-table-column
prop="ko"
label="KO%"
label="KO"
align="center"
/>
@ -109,7 +109,7 @@
},
getSummaries(param) {
const {data} = param;
const sums = []
const sums = [];
let allSamples = data.reduce(function (total, currentValue) {
return total + parseFloat(currentValue.samples);
}, 0);