Merge remote-tracking branch 'origin/master'

This commit is contained in:
wenyann 2021-03-18 13:54:36 +08:00
commit cf5688fc4e
23 changed files with 216 additions and 112 deletions

View File

@ -32,7 +32,7 @@ public class RestControllerExceptionHandler {
@ExceptionHandler(SQLException.class)
public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) {
public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, SQLException e) {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResultHolder.error("SQL error happened, please check logs.");
}

View File

@ -8,4 +8,5 @@ import lombok.Setter;
public class DemandDTO {
private String id;
private String name;
private String platform;
}

View File

@ -102,7 +102,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
*
* @return 其他平台和本地项目绑定的属性值
*/
abstract String getProjectId();
abstract String getProjectId(String projectId);
protected boolean isIntegratedPlatform(String orgId, String platform) {
IntegrationRequest request = new IntegrationRequest();

View File

@ -103,7 +103,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
String auth = EncryptUtils.base64Encoding(account + ":" + password);
String testCaseId = issuesRequest.getTestCaseId();
String jiraKey = getProjectId();
String jiraKey = getProjectId(null);
if (StringUtils.isBlank(jiraKey)) {
@ -200,7 +200,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
}
@Override
String getProjectId() {
String getProjectId(String projectId) {
if (StringUtils.isNotBlank(projectId)) {
return projectService.getProjectById(projectId).getJiraKey();
}
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
Project project = projectService.getProjectById(testCase.getProjectId());
return project.getJiraKey();

View File

@ -66,7 +66,7 @@ public class LocalPlatform extends AbstractIssuePlatform {
}
@Override
String getProjectId() {
String getProjectId(String projectId) {
return null;
}

View File

@ -36,7 +36,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
@Override
public List<Issues> getIssue() {
List<Issues> list = new ArrayList<>();
String tapdId = getProjectId();
String tapdId = getProjectId("");
TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andTestCaseIdEqualTo(testCaseId);
@ -67,18 +67,22 @@ public class TapdPlatform extends AbstractIssuePlatform {
@Override
public List<DemandDTO> getDemandList(String projectId) {
System.out.println(projectId);
List<DemandDTO> demandList = new ArrayList<>();
String url = "https://api.tapd.cn/stories?workspace_id=" + projectId;
try {
String url = "https://api.tapd.cn/stories?workspace_id=" + getProjectId(projectId);
ResultHolder call = call(url);
String listJson = JSON.toJSONString(call.getData());
JSONArray jsonArray = JSON.parseArray(listJson);
System.out.println(jsonArray);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject o = jsonArray.getJSONObject(i);
DemandDTO demand = o.getObject("Story", DemandDTO.class);
demand.setPlatform(IssuesManagePlatform.Tapd.name());
demandList.add(demand);
}
} catch (Exception e) {
LogUtil.error(e.getMessage());
}
return demandList;
}
@ -111,7 +115,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
public void addIssue(IssuesRequest issuesRequest) {
String url = "https://api.tapd.cn/bugs";
String testCaseId = issuesRequest.getTestCaseId();
String tapdId = getProjectId();
String tapdId = getProjectId("");
if (StringUtils.isBlank(tapdId)) {
MSException.throwException("未关联Tapd 项目ID");
@ -172,7 +176,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
@Override
public List<PlatformUser> getPlatformUser() {
List<PlatformUser> users = new ArrayList<>();
String projectId = getProjectId();
String projectId = getProjectId("");
String url = "https://api.tapd.cn/workspaces/users?workspace_id=" + projectId;
ResultHolder call = call(url);
String listJson = JSON.toJSONString(call.getData());
@ -186,7 +190,10 @@ public class TapdPlatform extends AbstractIssuePlatform {
}
@Override
String getProjectId() {
String getProjectId(String projectId) {
if (StringUtils.isNotBlank(projectId)) {
return projectService.getProjectById(projectId).getTapdId();
}
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
Project project = projectService.getProjectById(testCase.getProjectId());
return project.getTapdId();

View File

@ -48,7 +48,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
}
@Override
String getProjectId() {
String getProjectId(String projectId) {
if (StringUtils.isNotBlank(projectId)) {
return projectService.getProjectById(projectId).getZentaoId();
}
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
Project project = projectService.getProjectById(testCase.getProjectId());
return project.getZentaoId();
@ -88,7 +91,39 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
@Override
public List<DemandDTO> getDemandList(String projectId) {
return null;
//getTestStories
List<DemandDTO> list = new ArrayList<>();
try {
String session = login();
String key = getProjectId(projectId);
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(new HttpHeaders());
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-story-getProductStories-productID={key}?zentaosid=" + session,
HttpMethod.POST, requestEntity, String.class, key);
String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("project story" + key + obj);
if (obj != null) {
JSONObject data = obj.getJSONObject("data");
String s = JSON.toJSONString(data);
Map<String, Object> map = JSONArray.parseObject(s, Map.class);
Collection<Object> values = map.values();
values.forEach(v -> {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(v));
DemandDTO demandDTO = new DemandDTO();
demandDTO.setId(jsonObject.getString("id"));
demandDTO.setName(jsonObject.getString("title"));
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
list.add(demandDTO);
});
}
} catch (Exception e) {
LogUtil.error("get zentao bug fail " + e.getMessage());
}
return list;
}
private Issues getZentaoIssues(String bugId) {
@ -135,7 +170,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
public void addIssue(IssuesRequest issuesRequest) {
String session = login();
String projectId = getProjectId();
String projectId = getProjectId(null);
if (StringUtils.isBlank(projectId)) {
MSException.throwException("add zentao bug fail, project zentao id is null");
@ -279,7 +314,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
public List<ZentaoBuild> getBuilds() {
String session = login();
String projectId = getProjectId();
String projectId = getProjectId(null);
HttpHeaders httpHeaders = new HttpHeaders();
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(httpHeaders);
RestTemplate restTemplate = new RestTemplate();

View File

@ -32,9 +32,7 @@ public class DemandService {
public List<DemandDTO> getDemandList(String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
SessionUser user = SessionUtils.getUser();
/*
String orgId = "88aceecf-5764-4094-96a9-f82bd52e77ad";
*/
String orgId = user.getLastOrganizationId();
boolean tapd = issuesService.isIntegratedPlatform(orgId, IssuesManagePlatform.Tapd.toString());
boolean jira = issuesService.isIntegratedPlatform(orgId, IssuesManagePlatform.Jira.toString());
@ -48,7 +46,6 @@ public class DemandService {
if (StringUtils.isNotBlank(tapdId)) {
platforms.add(IssuesManagePlatform.Tapd.name());
}
issueRequest.setProjectId(tapdId);
}
if (jira) {
@ -56,7 +53,6 @@ public class DemandService {
if (StringUtils.isNotBlank(jiraKey)) {
platforms.add(IssuesManagePlatform.Jira.name());
}
issueRequest.setProjectId(jiraKey);
}
if (zentao) {
@ -64,13 +60,14 @@ public class DemandService {
if (StringUtils.isNotBlank(zentaoId)) {
platforms.add(IssuesManagePlatform.Zentao.name());
}
issueRequest.setProjectId(zentaoId);
}
List<AbstractIssuePlatform> platformList = IssueFactory.createPlatforms(platforms, issueRequest);
platformList.forEach(platform -> {
List<DemandDTO> demand = platform.getDemandList(issueRequest.getProjectId());
List<DemandDTO> demand = platform.getDemandList(projectId);
list.addAll(demand);
});
return list;
}
}

View File

@ -731,6 +731,9 @@ public class TestCaseService {
public void minderEdit(TestCaseMinderEditRequest request) {
List<TestCaseWithBLOBs> data = request.getData();
data.forEach(item -> {
if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) {
item.setNodeId("");
}
item.setProjectId(request.getProjectId());
if (StringUtils.isBlank(item.getId()) || item.getId().length() < 20) {
item.setId(UUID.randomUUID().toString());

@ -1 +1 @@
Subproject commit efd6af73b7c5cc53cd4515772000bc1436c49837
Subproject commit adefde265ff12d4ea909353c3f46008f8a8e17e7

View File

@ -1,23 +1,25 @@
<template>
<el-card class="api-component">
<el-card>
<div class="header" @click="active(data)">
<slot name="beforeHeaderLeft">
<div v-if="data.index" class="el-step__icon is-text" style="margin-right: 10px;" :style="{'color': color, 'background-color': backgroundColor}">
<div class="el-step__icon-inner">{{data.index}}</div>
</div>
<el-tag class="ms-left-buttion" size="small" :style="{'color': color, 'background-color': backgroundColor}">{{title}}</el-tag>
<el-tag class="ms-left-btn" size="small" :style="{'color': color, 'background-color': backgroundColor}">{{title}}</el-tag>
<el-tag size="mini" v-if="data.method">{{data.method}}</el-tag>
</slot>
<span @click.stop>
<span>
<slot name="headerLeft">
<i class="icon el-icon-arrow-right" :class="{'is-active': data.active}"
@click="active(data)" v-if="data.type!='scenario' && !isMax "/>
<el-input :draggable="draggable" v-if="isShowInput && isShowNameInput" size="mini" v-model="data.name" class="name-input"
@click="active(data)" v-if="data.type!='scenario' && data.type!='JmeterElement' && !isMax " @click.stop/>
<span @click.stop v-if="isShowInput && isShowNameInput">
<el-input :draggable="draggable" size="mini" v-model="data.name" class="name-input"
@blur="isShowInput = false" :placeholder="$t('commons.input_name')" ref="nameEdit" :disabled="data.disabled"/>
<span v-else>
</span>
<span :class="isMax?'ms-step-name':'scenario-name'" v-else>
{{data.name}}
<i class="el-icon-edit" style="cursor:pointer" @click="editName" v-tester v-if="data.referenced!='REF' && !data.disabled"/>
<i class="el-icon-edit" style="cursor:pointer" @click="editName" v-tester v-if="data.referenced!='REF' && !data.disabled" @click.stop/>
</span>
</slot>
<slot name="behindHeaderLeft" v-if="!isMax"></slot>
@ -159,7 +161,8 @@
margin-right: 5px;
}
.ms-left-buttion {
.ms-left-btn {
font-size: 13px;
margin-right: 15px;
}
@ -173,15 +176,24 @@
margin-right: 10px;
}
.node-title {
.ms-step-name {
display: inline-block;
margin: 0px;
font-size: 13px;
margin: 0 5px;
overflow-x: hidden;
padding-bottom: 0;
text-overflow: ellipsis;
vertical-align: middle;
white-space: nowrap;
width: 100px;
width: 180px;
}
.scenario-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
width: 100%;
}
/deep/ .el-step__icon {

View File

@ -275,7 +275,6 @@
}
}
}
this.request.active = true;
this.loading = true;
this.runData = [];
@ -295,6 +294,7 @@
this.request.requestResult = data;
this.request.result = undefined;
this.loading = false;
this.$emit('refReload',this.request,this.node);
},
reload() {
this.loading = true

View File

@ -130,8 +130,8 @@
suggestClick(node) {
this.$emit('suggestClick', node);
},
refReload() {
this.$emit('refReload');
refReload(data, node) {
this.$emit('refReload', data, node);
}
}
}

View File

@ -5,7 +5,9 @@
<ms-aside-container>
<!-- 场景步骤内容 -->
<div v-loading="loading">
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition"
<el-tree node-key="resourceId"
:props="props"
:data="scenarioDefinition"
:default-expanded-keys="expandedNode"
:expand-on-click-node="false"
highlight-current
@ -14,12 +16,21 @@
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable>
<span class="custom-tree-node father" slot-scope="{ node, data}">
<!-- 步骤组件-->
<ms-component-config :isMax="true" :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario"
:currentEnvironmentId="currentEnvironmentId" :node="node" :project-list="projectList" :env-map="projectEnvMap"
@remove="remove" @copyRow="copyRow" @suggestClick="suggestClick" @refReload="refReload" @openScenario="openScenario"/>
<ms-component-config
:isMax="true"
:type="data.type"
:scenario="data"
:response="response"
:currentScenario="currentScenario"
:currentEnvironmentId="currentEnvironmentId"
:node="node"
:project-list="projectList"
:env-map="projectEnvMap"
@remove="remove" @copyRow="copyRow"
@suggestClick="suggestClick"
@refReload="refReload" @openScenario="openScenario"/>
</span>
</el-tree>
<div @click="fabClick">
<vue-fab id="fab" mainBtnColor="#783887" size="small" :global-options="globalOptions"
:click-auto-close="false">
@ -39,9 +50,10 @@
</div>
</ms-aside-container>
<ms-main-container>
<ms-main-container v-if="!loading">
<!-- 第一层当前节点内容-->
<ms-component-config :isMax="false"
<ms-component-config
:isMax="false"
:showBtn="false"
:type="selectedTreeNode.type"
:scenario="selectedTreeNode"
@ -57,7 +69,8 @@
<!-- 请求下还有的子步骤-->
<div v-if="selectedTreeNode && selectedTreeNode.hashTree && showNode(selectedTreeNode)">
<div v-for="item in selectedTreeNode.hashTree" :key="item.id" class="ms-col-one">
<ms-component-config :showBtn="false"
<ms-component-config
:showBtn="false"
:isMax="false"
:type="item.type"
:scenario="item"
@ -70,10 +83,8 @@
@remove="remove" @copyRow="copyRow" @suggestClick="suggestClick"
@refReload="refReload" @openScenario="openScenario"
v-if="selectedTreeNode && selectedNode"/>
</div>
</div>
</ms-main-container>
</ms-container>
@ -224,6 +235,11 @@
this.operatingElements = ELEMENTS.get("ALL");
this.projectEnvMap = this.envMap;
},
watch: {
envMap() {
this.projectEnvMap = this.envMap;
}
},
directives: {OutsideClick},
computed: {
buttons() {
@ -866,8 +882,7 @@
this.currentScenario.apiScenarioModuleId = this.currentModule.id;
}
this.currentScenario.projectId = this.projectId;
}
,
},
runRefresh() {
this.debugVisible = true;
this.loading = false;
@ -900,7 +915,9 @@
setProjectEnvMap(projectEnvMap) {
this.projectEnvMap = projectEnvMap;
},
refReload() {
refReload(data,node) {
this.selectedTreeNode = data;
this.selectedNode = node;
this.initProjectIds();
this.reload();
},

View File

@ -43,6 +43,14 @@
position: relative;
}
.scenario-aside {
position: relative;
border-radius: 4px;
border: 1px solid #EBEEF5;
box-sizing: border-box;
}
.hiddenBottom i {
margin-left: -2px;
}

View File

@ -96,6 +96,15 @@ export default {
},
parse(root, children) {
root.children = [];
if (root.data.id === 'root') {
// nodeId
let rootChildData = this.dataMap.get("");
if (rootChildData) {
rootChildData.forEach((dataNode) => {
root.children.push(dataNode);
})
}
}
//
let dataNodes = this.dataMap.get(root.data.id);
if (dataNodes) {

View File

@ -93,7 +93,7 @@ import MsTablePagination from "../../common/pagination/TablePagination";
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceReportStatus from "./PerformanceReportStatus";
import {getCurrentProjectID} from "../../../../common/js/utils";
import {getCurrentProjectID} from "@/common/js/utils";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
import {REPORT_CONFIGS} from "../../common/components/search/search-components";
@ -104,7 +104,7 @@ import {_filter, _sort} from "@/common/js/tableUtils";
export default {
name: "PerformanceTestReport",
name: "PerformanceTestReportList",
components: {
MsTableHeader,
ReportTriggerModeItem,
@ -186,10 +186,6 @@ export default {
this.multipleSelection = val;
},
handleEdit(report) {
if (report.status === "Starting") {
this.$info(this.$t('report.being_generated'))
return false
}
this.$router.push({
path: '/performance/report/view/' + report.id
})

View File

@ -46,7 +46,7 @@
</el-form-item>
<br>
<el-form-item :label="$t('load_test.rps_limit')">
<el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/>
<el-switch v-model="threadGroup.rpsLimitEnable" :disabled="true" @change="calculateTotalChart()"/>
&nbsp;
<el-input-number
:disabled="true"
@ -101,7 +101,7 @@
</el-form-item>
<br>
<el-form-item :label="$t('load_test.rps_limit')">
<el-switch v-model="threadGroup.rpsLimitEnable" @change="calculateTotalChart()"/>
<el-switch v-model="threadGroup.rpsLimitEnable" :disabled="true" @change="calculateTotalChart()"/>
&nbsp;
<el-input-number
:disabled="true || !threadGroup.rpsLimitEnable"

View File

@ -4,7 +4,7 @@ const PerformanceTest = () => import('@/business/components/performance/Performa
const PerformanceTestHome = () => import('@/business/components/performance/home/PerformanceTestHome')
const EditPerformanceTest = () => import('@/business/components/performance/test/EditPerformanceTest')
const PerformanceTestList = () => import('@/business/components/performance/test/PerformanceTestList')
const PerformanceTestReport = () => import('@/business/components/performance/report/PerformanceTestReport')
const PerformanceTestReportList = () => import('@/business/components/performance/report/PerformanceTestReportList')
const PerformanceChart = () => import('@/business/components/performance/report/components/PerformanceChart')
const PerformanceReportView = () => import('@/business/components/performance/report/PerformanceReportView')
@ -51,7 +51,7 @@ export default {
{
path: "report/:type",
name: "perReport",
component: PerformanceTestReport
component: PerformanceTestReportList
},
{
path: "chart",

View File

@ -67,7 +67,7 @@
v-model="threadGroup.rpsLimit"
@change="calculateChart(threadGroup)"
:min="1"
:max="500"
:max="99999"
size="mini"/>
</el-form-item>
<br>
@ -112,7 +112,7 @@
:disabled="isReadOnly"
v-model="threadGroup.iterateNum"
:min="1"
:max="10000"
:max="9999999"
@change="calculateChart(threadGroup)"
size="mini"/>
</el-form-item>
@ -124,7 +124,7 @@
:disabled="isReadOnly || !threadGroup.rpsLimitEnable"
v-model="threadGroup.rpsLimit"
:min="1"
:max="500"
:max="99999"
size="mini"/>
</el-form-item>
<br>

View File

@ -136,12 +136,12 @@
<el-row>
<el-col :span="10">
<el-form-item label="关联需求" :label-width="formLabelWidth" prop="demandId">
<el-select filterable :disabled="readOnly" v-model="form.demandId"
<el-select filterable :disabled="readOnly" v-model="form.demandId" @visible-change="visibleChange"
:placeholder="$t('test_track.case.input_type')" class="ms-case-input">
<el-option
v-for="item in demandOptions"
:key="item.id"
:label="item.name"
:label="item.platform + ': '+item.name"
:value="item.id">
</el-option>
</el-select>
@ -761,18 +761,31 @@ export default {
});
}
},
visibleChange(flag) {
if (flag) {
this.getDemandOptions()
}
},
getDemandOptions() {
this.projectId = getCurrentProjectID()
this.result = this.$get("demand/list/" + this.projectId, response => {
this.demandOptions = response.data;
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other')})
});
if (this.demandOptions.length === 0) {
this.projectId = getCurrentProjectID();
this.result = {loading : true};
this.$get("demand/list/" + this.projectId).then(response => {
this.demandOptions = response.data.data;
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other'), platform: 'Other'})
this.result = {loading : false};
}).catch(() => {
this.result = {loading : false};
})
}
},
getSelectOptions() {
this.getModuleOptions();
this.getMaintainerOptions();
this.getTestOptions();
// this.getDemandOptions()
if (this.type === 'edit') {
this.getDemandOptions();
}
},
resetForm() {

View File

@ -47,9 +47,9 @@ name: "TestCaseMinder",
}
},
save(data) {
console.log(this.dataMap);
let saveCases = [];
this.buildSaveCase(data.root, saveCases, undefined);
console.log(saveCases);
let param = {
projectId: this.projectId,
data: saveCases
@ -72,6 +72,9 @@ name: "TestCaseMinder",
},
_buildSaveCase(node, saveCases, parent) {
let data = node.data;
if (!data.text) {
return;
}
let isChange = false;
let testCase = {
id: data.id,
@ -81,7 +84,7 @@ name: "TestCaseMinder",
type: data.type ? data.type : 'functional',
method: data.method ? data.method: 'manual',
maintainer: data.maintainer,
priority: 'P' + data.priority,
priority: 'P' + (data.priority ? data.priority : 0),
};
if (data.changed) isChange = true;
let steps = [];

@ -1 +1 @@
Subproject commit f2781219889c2f993436bcc3ea90038f588fa73e
Subproject commit d3c3ba983502dc9864db88645af392e36004f301