Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2020-12-18 11:26:40 +08:00
commit ab5fa68921
23 changed files with 106 additions and 69 deletions

View File

@ -59,8 +59,8 @@ public class ApiAutomationController {
}
@PostMapping("/reduction")
public void reduction(@RequestBody List<String> ids) {
apiAutomationService.reduction(ids);
public void reduction(@RequestBody List<SaveApiScenarioRequest> requests) {
apiAutomationService.reduction(requests);
}
@GetMapping("/getApiScenario/{id}")

View File

@ -63,8 +63,8 @@ public class ApiDefinitionController {
}
@PostMapping("/reduction")
public void reduction(@RequestBody List<String> ids) {
apiDefinitionService.reduction(ids);
public void reduction(@RequestBody List<SaveApiDefinitionRequest> requests) {
apiDefinitionService.reduction(requests);
}
@GetMapping("/get/{id}")

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.protocol.java.sampler.JSR223Sampler;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
@ -32,7 +33,11 @@ public class MsJSR223Processor extends MsTestElement {
}
JSR223Sampler processor = new JSR223Sampler();
processor.setEnabled(true);
processor.setName(this.getName() + "JSR223Processor");
if (StringUtils.isNotEmpty(this.getName())) {
processor.setName(this.getName());
} else {
processor.setName("JSR223Processor");
}
processor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true");

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
@ -33,7 +34,11 @@ public class MsJSR223PostProcessor extends MsTestElement {
}
JSR223PostProcessor processor = new JSR223PostProcessor();
processor.setEnabled(true);
processor.setName(this.getName() + "JSR223PostProcessor");
if (StringUtils.isNotEmpty(this.getName())) {
processor.setName(this.getName());
} else {
processor.setName("JSR223PostProcessor");
}
processor.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true");

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.modifiers.JSR223PreProcessor;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
@ -32,7 +33,11 @@ public class MsJSR223PreProcessor extends MsTestElement {
}
JSR223PreProcessor processor = new JSR223PreProcessor();
processor.setEnabled(true);
processor.setName(this.getName() + "JSR223PreProcessor");
if (StringUtils.isNotEmpty(this.getName())) {
processor.setName(this.getName());
} else {
processor.setName("JSR223PreProcessor");
}
processor.setProperty(TestElement.TEST_CLASS, JSR223PreProcessor.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true");

View File

@ -179,7 +179,12 @@ public class ApiAutomationService {
extApiScenarioMapper.removeToGc(apiIds);
}
public void reduction(List<String> apiIds) {
public void reduction(List<SaveApiScenarioRequest> requests) {
List<String> apiIds = new ArrayList<>();
requests.forEach(item->{
checkNameExist(item);
apiIds.add(item.getId());
});
extApiScenarioMapper.reduction(apiIds);
}

View File

@ -158,7 +158,12 @@ public class ApiDefinitionService {
extApiDefinitionMapper.removeToGc(apiIds);
}
public void reduction(List<String> apiIds) {
public void reduction(List<SaveApiDefinitionRequest> requests) {
List<String> apiIds = new ArrayList<>();
requests.forEach(item -> {
checkNameExist(item);
apiIds.add(item.getId());
});
extApiDefinitionMapper.reduction(apiIds);
}
@ -386,6 +391,7 @@ public class ApiDefinitionService {
/**
* 数据统计-接口类型
*
* @param projectId 项目ID
* @return
*/
@ -395,6 +401,7 @@ public class ApiDefinitionService {
/**
* 统计本周创建的数据总量
*
* @param projectId
* @return
*/
@ -404,10 +411,10 @@ public class ApiDefinitionService {
Date firstTime = startAndEndDateInWeek.get("firstTime");
Date lastTime = startAndEndDateInWeek.get("lastTime");
if(firstTime==null || lastTime == null){
return 0;
}else {
return extApiDefinitionMapper.countByProjectIDAndCreateInThisWeek(projectId,firstTime.getTime(),lastTime.getTime());
if (firstTime == null || lastTime == null) {
return 0;
} else {
return extApiDefinitionMapper.countByProjectIDAndCreateInThisWeek(projectId, firstTime.getTime(), lastTime.getTime());
}
}
}

View File

@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiDefinitionExecResultMapper {
long countByExample(ApiDefinitionExecResultExample example);

@ -1 +1 @@
Subproject commit 61397c16728a63493507679f7e0940d9099f337f
Subproject commit efb49c9b4be136ce48e9550dc9c8a2975d9f4d7f

View File

@ -17,7 +17,7 @@
<el-col :span="5">
<el-tooltip effect="dark" :content="request.responseResult.responseCode" placement="bottom" :open-delay="800">
<div style="color: #5daf34" v-if="request.success">{{ request.responseResult.responseCode }}</div>
<div style="color: #5daf34" v-if="request.responseResult.responseCode==='200'">{{ request.responseResult.responseCode }}</div>
<div style="color: #FE6F71" v-else>{{ request.responseResult.responseCode }}</div>
</el-tooltip>
</el-col>

View File

@ -38,12 +38,13 @@
<script>
import {WORKSPACE_ID} from '@/common/js/constants';
import {getCurrentUser, getUUID,getCurrentProjectID} from "@/common/js/utils";
import {getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import MsTablePagination from "../../../common/pagination/TablePagination";
export default {
name: "MsAddTag",
components: {MsDialogFooter,MsTablePagination},
components: {MsDialogFooter, MsTablePagination},
props: {},
data() {
return {
@ -84,6 +85,7 @@
this.result = this.$post(this.path, this.tagForm, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
this.tagForm = {};
});
} else {
return false;

View File

@ -134,12 +134,29 @@
this.request.requestResult = requestResult;
this.request.id = response.data.id;
this.reload();
this.sort();
} else {
this.request.referenced = "Deleted";
}
})
}
},
recursiveSorting(arr) {
for (let i in arr) {
arr[i].index = Number(i) + 1;
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
}
}
},
sort() {
for (let i in this.request.hashTree) {
this.request.hashTree[i].index = Number(i) + 1;
if (this.request.hashTree[i].hashTree != undefined && this.request.hashTree[i].hashTree.length > 0) {
this.recursiveSorting(this.request.hashTree[i].hashTree);
}
}
},
active(item) {
item.active = !item.active;
this.reload();

View File

@ -219,8 +219,9 @@
this.$emit('edit', row);
},
reductionApi(row) {
let obj = [row.id];
this.$post("/api/automation/reduction", obj, response => {
row.scenarioDefinition = null;
let rows = [row];
this.$post("/api/automation/reduction", rows, response => {
this.$success(this.$t('commons.save_success'));
this.search();
})

View File

@ -100,13 +100,18 @@
name: "MsAddCompleteHttpApi",
components: {MsResponseText, MsApiRequestForm, MsJsr233Processor},
data() {
let validateURL = (rule, value, callback) => {
if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) {
callback(this.$t('api_test.definition.request.path_valid_info'));
}
};
return {
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}, {validator: validateURL, trigger: 'blur'}],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
@ -124,10 +129,6 @@
runTest() {
this.$refs['httpForm'].validate((valid) => {
if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter();
this.$emit('runTest', this.httpForm);
} else {
@ -150,10 +151,6 @@
saveApi() {
this.$refs['httpForm'].validate((valid) => {
if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter();
this.$emit('saveApi', this.httpForm);
}

View File

@ -63,10 +63,20 @@
scenario: Boolean,
},
data() {
let validateURL = (rule, value, callback) => {
try {
new URL(this.debugForm.url);
} catch (e) {
callback(this.$t('api_test.request.url_invalid'));
}
};
return {
rules: {
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
url: [{required: true, message: this.$t('api_test.definition.request.path_all_info'), trigger: 'blur'}],
url: [
{max: 500, required: true, message: this.$t('commons.input_limit', [1, 500]), trigger: 'blur'},
{validator: validateURL, trigger: 'blur'}
],
},
debugForm: {method: REQ_METHOD[0].id, environmentId: ""},
options: [],

View File

@ -19,6 +19,7 @@ export default class JSR223PostProcessor extends PostProcessor {
this.parameters = [];
this.filename = undefined;
this.cacheKey = true;
this.enable = true;
this.script = undefined;
}
}

View File

@ -19,6 +19,7 @@ export default class JSR223PreProcessor extends PostProcessor {
this.parameters = [];
this.filename = undefined;
this.cacheKey = undefined;
this.enable = true;
this.script = undefined;
}
}

View File

@ -6,10 +6,10 @@
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" v-model="condition.name"/>
<el-table v-loading="result.loading"
border
:data="tableData" row-key="id" class="test-content adjust-table"
@select-all="handleSelectAll"
@select="handleSelect" :height="screenHeight">
border
:data="tableData" row-key="id" class="test-content adjust-table"
@select-all="handleSelectAll"
@select="handleSelect" :height="screenHeight">
<el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope">
@ -268,8 +268,10 @@
this.$emit('editApi', row);
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/definition/reduction/', ids, () => {
row.request = null;
row.response = null;
let rows = [row];
this.$post('/api/definition/reduction/', rows, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});

View File

@ -1,6 +1,6 @@
<template>
<div v-loading="result.loading">
<el-input placeholder="搜索项目"
<el-input :placeholder="$t('project.search_by_name')"
prefix-icon="el-icon-search"
v-model="searchString"
clearable
@ -8,7 +8,7 @@
size="small"/>
<div v-if="items.length === 0" style="text-align: center; margin: 15px 0">
<span style="font-size: 15px; color: #8a8b8d;">
无数据
{{ $t('project.no_data') }}
</span>
</div>
<div v-else style="height: 150px;overflow: auto">
@ -114,7 +114,7 @@ export default {
this.$emit("update:currentProject", project[0].name);
}
} else {
this.$emit("update:currentProject", '选择项目');
this.$emit("update:currentProject", this.$t('project.select'));
}
}
}

View File

@ -5,7 +5,7 @@
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" @create="create"
:create-tip="btnTips" :title="$t('commons.project')"/>
</template>
<el-table border class="adjust-table" @row-click="link" :data="items" style="width: 100%" @sort-change="sort">
<el-table border class="adjust-table" :data="items" style="width: 100%" @sort-change="sort">
<el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip/>
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip>
<template v-slot:default="scope">
@ -95,7 +95,6 @@ import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ApiEnvironmentConfig from "../../api/test/components/ApiEnvironmentConfig";
import TemplateComponent from "../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
import {ApiEvent, LIST_CHANGE, PerformanceEvent, TrackEvent} from "@/business/components/common/head/ListEvent";
import {PROJECT_ID} from "@/common/js/constants";
export default {
@ -223,10 +222,6 @@ export default {
}
Message.success(this.$t('commons.delete_success'));
this.list();
// 广 head
ApiEvent.$emit(LIST_CHANGE);
TrackEvent.$emit(LIST_CHANGE);
PerformanceEvent.$emit(LIST_CHANGE);
});
}).catch(() => {
this.$message({
@ -253,22 +248,6 @@ export default {
this.total = data.itemCount;
})
},
link(row) {
// performance_test project link
if (this.$route.name === 'perProject') {
this.$router.push({
path: '/performance/test/' + row.id,
})
} else if (this.$route.name === 'fucProject') {
this.$router.push({
path: '/api/test/list/' + row.id
})
} else if (this.$route.name === 'trackProject') {
this.$router.push({
path: '/track/case/' + row.id
})
}
},
sort(column) {
_sort(column, this.condition);
this.list();
@ -292,11 +271,6 @@ export default {
</script>
<style scoped>
.el-table {
cursor: pointer;
}
pre {
margin: 0 0;
}

View File

@ -304,6 +304,8 @@ export default {
jira_key: 'JIRA Project key',
zentao_id: 'Zentao Project ID',
manager: 'Manager',
no_data: 'No Data',
select: 'Select'
},
member: {
create: 'Create',
@ -543,7 +545,7 @@ export default {
create_info: 'Create',
update_info: 'Update',
batch_edit: "Batch edit",
path_valid_info: "The request address cannot contain spaces",
path_valid_info: "The request path is invalid",
}
},
automation: {

View File

@ -301,6 +301,8 @@ export default {
jira_key: 'JIRA项目key',
zentao_id: 'Zentao项目ID',
manager: '项目管理',
no_data: '无数据',
select: '选择项目'
},
member: {
create: '添加成员',
@ -542,7 +544,7 @@ export default {
create_info: '创建',
update_info: '更新',
batch_edit: "批量编辑",
path_valid_info: "请求地址不能包含空格",
path_valid_info: "请求路径无效",
}
},
automation: {

View File

@ -301,6 +301,8 @@ export default {
jira_key: 'JIRA項目key',
zentao_id: 'Zentao項目ID',
manager: '項目管理',
no_data: '無數據',
select: '選擇項目'
},
member: {
create: '添加成員',
@ -542,7 +544,7 @@ export default {
create_info: '創建',
update_info: '更新',
batch_edit: "批量編輯",
path_valid_info: "請求地址不能包含空格",
path_valid_info: "請求路径无效",
}
},
automation: {