fix: 修复jenkins调用测试计划报告不更新问题

This commit is contained in:
wenyann 2021-03-22 19:10:12 +08:00
parent 254aa4e63d
commit 954b58161e
8 changed files with 97 additions and 62 deletions

View File

@ -109,8 +109,16 @@ public class ApiAutomationController {
return apiAutomationService.run(request); return apiAutomationService.run(request);
} }
@PostMapping(value = "/run/jenkins")
public String runByJenkins(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name());
return apiAutomationService.run(request);
}
@PostMapping(value = "/run/batch") @PostMapping(value = "/run/batch")
public String runBatch(@RequestBody RunScenarioRequest request) { public String runBatcah(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name()); request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name()); request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name()); request.setRunMode(ApiRunMode.SCENARIO.name());

View File

@ -236,7 +236,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name()); testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name());
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e);
} }
} }
sendTask(report, reportUrl, testResult); sendTask(report, reportUrl, testResult);

View File

@ -75,6 +75,7 @@
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.type"/> <property name="object" value="${condition}.type"/>
</include> </include>
test_case_review_users
</if> </if>
<if test="${condition}.updateTime != null"> <if test="${condition}.updateTime != null">
and test_case.update_time and test_case.update_time
@ -368,7 +369,7 @@
</if> </if>
</where> </where>
UNION ALL UNION ALL
SELECT test_plan_api_scenario.id as reportId,test_plan_api_scenario.api_scenario_id as id,"scenario" as SELECT test_plan_api_scenario.api_scenario_id as testId,test_plan_api_scenario.id as id,"scenario" as
type,api_scenario.name,test_plan_api_scenario.status type,api_scenario.name,test_plan_api_scenario.status
from test_plan_api_scenario from test_plan_api_scenario
left join left join

View File

@ -3,6 +3,7 @@ package io.metersphere.track.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.automation.*;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
@ -55,6 +56,14 @@ public class TestPlanScenarioCaseController {
return testPlanScenarioCaseService.run(request); return testPlanScenarioCaseService.run(request);
} }
@PostMapping(value = "/jenkins/run")
public String runByRun(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name());
return testPlanScenarioCaseService.run(request);
}
@PostMapping("/batch/update/env") @PostMapping("/batch/update/env")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) { public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) {

View File

@ -52,21 +52,27 @@ create table test_case_review_load
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4; DEFAULT CHARSET = utf8mb4;
-- test_resource_pool add column -- test_resource_pool add column
ALTER TABLE test_resource_pool ADD heap VARCHAR(200) NULL; ALTER TABLE test_resource_pool
ALTER TABLE test_resource_pool ADD gc_algo VARCHAR(200) NULL; ADD heap VARCHAR(200) NULL;
ALTER TABLE test_resource_pool
ADD gc_algo VARCHAR(200) NULL;
-- create tale api_document_share -- create tale api_document_share
CREATE TABLE IF NOT EXISTS `api_document_share` ( CREATE TABLE IF NOT EXISTS `api_document_share`
`id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Api Document Share Info ID', (
`create_time` BIGINT ( 13 ) NOT NULL COMMENT 'Create timestamp', `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Api Document Share Info ID',
`create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `create_time` BIGINT(13) NOT NULL COMMENT 'Create timestamp',
`update_time` BIGINT ( 13 ) NOT NULL COMMENT 'last visit timestamp', `create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`share_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'single or batch', `update_time` BIGINT(13) NOT NULL COMMENT 'last visit timestamp',
`share_api_id` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'APiDefinition.id (JSONArray format. Order by TreeSet)', `share_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'single or batch',
PRIMARY KEY (`id`) USING BTREE, `share_api_id` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'APiDefinition.id (JSONArray format. Order by TreeSet)',
INDEX `share_type`(`share_type`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `share_api_id`(`share_api_id`(125)) USING BTREE INDEX `share_type` (`share_type`) USING BTREE,
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; INDEX `share_api_id` (`share_api_id`(125)) USING BTREE
) ENGINE = InnoDB
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_general_ci
ROW_FORMAT = Dynamic;
-- swagger_url_project -- swagger_url_project
alter table swagger_url_project alter table swagger_url_project
@ -91,61 +97,70 @@ alter table test_plan_api_scenario
change environment_id environment longtext null comment 'Relevance environment'; change environment_id environment longtext null comment 'Relevance environment';
-- add Original state -- add Original state
alter table api_definition add original_state varchar(64); alter table api_definition
alter table api_scenario add original_state varchar(64); add original_state varchar(64);
update api_definition set original_state='Underway'; alter table api_scenario
update api_scenario set original_state='Underway'; add original_state varchar(64);
update api_definition
set original_state='Underway';
update api_scenario
set original_state='Underway';
-- alter test_case_review_scenario -- alter test_case_review_scenario
alter table test_case_review_scenario modify environment longtext null; alter table test_case_review_scenario
modify environment longtext null;
-- schedule table add project_id column -- schedule table add project_id column
alter table schedule add project_id varchar(50) NULL; alter table schedule
add project_id varchar(50) NULL;
-- set values for new colums of exitsting data -- set values for new colums of exitsting data
update schedule sch inner join test_plan testPlan on update schedule sch inner join test_plan testPlan on
testPlan.id = sch.resource_id testPlan.id = sch.resource_id
set sch.project_id = testPlan.project_id where set sch.project_id = testPlan.project_id
sch.resource_id = testPlan.id; where sch.resource_id = testPlan.id;
update schedule sch inner join swagger_url_project sup on update schedule sch inner join swagger_url_project sup on
sup.id = sch.resource_id sup.id = sch.resource_id
set sch.project_id = sup.project_id where set sch.project_id = sup.project_id
sch.resource_id = sup.id; where sch.resource_id = sup.id;
update schedule sch inner join api_scenario apiScene on update schedule sch inner join api_scenario apiScene on
apiScene.id = sch.resource_id apiScene.id = sch.resource_id
set sch.project_id = apiScene.project_id where set sch.project_id = apiScene.project_id
sch.resource_id = apiScene.id; where sch.resource_id = apiScene.id;
update schedule sch inner join load_test ldt on update schedule sch inner join load_test ldt on
ldt.id = sch.resource_id ldt.id = sch.resource_id
set sch.project_id = ldt.project_id where set sch.project_id = ldt.project_id
sch.resource_id = ldt.id; where sch.resource_id = ldt.id;
update schedule sch inner join api_test apiTest on update schedule sch inner join api_test apiTest on
apiTest.id = sch.resource_id apiTest.id = sch.resource_id
set sch.project_id = apiTest.project_id where set sch.project_id = apiTest.project_id
sch.resource_id = apiTest.id; where sch.resource_id = apiTest.id;
-- schedule table add name column -- schedule table add name column
alter table schedule add name varchar(100) NULL; alter table schedule
add name varchar(100) NULL;
-- set values for new colums of exitsting data -- set values for new colums of exitsting data
update schedule sch inner join api_scenario apiScene on update schedule sch inner join api_scenario apiScene on
apiScene.id = sch.resource_id apiScene.id = sch.resource_id
set sch.name = apiScene.name; set sch.name = apiScene.name;
update schedule sch inner join test_plan testPlan on update schedule sch inner join test_plan testPlan on
testPlan.id = sch.resource_id testPlan.id = sch.resource_id
set sch.name = testPlan.name; set sch.name = testPlan.name;
update schedule sch inner join load_test ldt on update schedule sch inner join load_test ldt on
ldt.id = sch.resource_id ldt.id = sch.resource_id
set sch.name = ldt.name; set sch.name = ldt.name;
update schedule sch inner join api_test apiTest on update schedule sch inner join api_test apiTest on
apiTest.id = sch.resource_id apiTest.id = sch.resource_id
set sch.name = apiTest.name; set sch.name = apiTest.name;
update schedule sch inner join swagger_url_project sup on update schedule sch inner join swagger_url_project sup on
sup.id = sch.resource_id sup.id = sch.resource_id
set sch.name = LEFT(SUBSTRING_INDEX(sup.swagger_url, '/', 3), 100); set sch.name = LEFT(SUBSTRING_INDEX(sup.swagger_url, '/', 3), 100);
-- delete an unused colum -- delete an unused colum
alter table schedule drop column custom_data; alter table schedule
drop column custom_data;
-- add sort column -- add sort column
alter table load_test_file add sort int default 0; alter table load_test_file
add sort int default 0;
alter table file_metadata alter table file_metadata
add project_id VARCHAR(50) null; add project_id VARCHAR(50) null;
@ -179,15 +194,14 @@ alter table test_plan
alter table test_case alter table test_case
modify method varchar(15) null comment 'Test case method type'; modify method varchar(15) null comment 'Test case method type';
-- add test_case_test -- add test_case_test
create table test_case_test CREATE TABLE IF NOT EXISTS test_case_test
( (
id varchar(70) null, test_case_id varchar(50) null,
test_case_id varchar(70) null, test_id varchar(50) null,
test_id varchar(70) null, test_type varchar(50) null,
test_type varchar(70) null, UNIQUE KEY test_case_test_unique_key (test_case_id, test_id)
constraint test_case_test_pk
primary key (id)
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4; DEFAULT CHARSET = utf8mb4 COMMENT ='测试用例和关联用例的关系表';
alter table test_case alter table test_case
modify test_id varchar(2000) null; modify test_id varchar(2000) null;

View File

@ -73,7 +73,6 @@ export const API_STATUS = [
] ]
export const TEST = [ export const TEST = [
{id: 'performance', name: '性能测试'}, {id: 'performance', name: '性能测试'},
{id: 'api', name: '接口测试'},
{id: 'testcase', name: '测试用例'}, {id: 'testcase', name: '测试用例'},
{id: 'automation', name: '场景测试'} {id: 'automation', name: '场景测试'}
] ]

View File

@ -377,7 +377,7 @@ export default {
desc: '', desc: '',
result: '' result: ''
}], }],
selected:[], selected: [],
remark: '', remark: '',
tags: [], tags: [],
demandId: '', demandId: '',
@ -497,6 +497,8 @@ export default {
this.$nextTick(() => (this.isStepTableAlive = true)); this.$nextTick(() => (this.isStepTableAlive = true));
}, },
open(testCase) { open(testCase) {
console.log("测试用例")
console.log(testCase)
this.projectId = getCurrentProjectID(); this.projectId = getCurrentProjectID();
if (window.history && window.history.pushState) { if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL); history.pushState(null, null, document.URL);
@ -580,7 +582,8 @@ export default {
} }
Object.assign(this.form, tmp); Object.assign(this.form, tmp);
this.form.module = testCase.nodeId; this.form.module = testCase.nodeId;
this.form.testId=testCase.testId this.form.testId=testCase.selected
console.log(this.form.testId)
this.getFileMetaData(testCase); this.getFileMetaData(testCase);
}, },
setTestCaseExtInfo(testCase) { setTestCaseExtInfo(testCase) {

View File

@ -274,7 +274,7 @@ export default {
execute(row) { execute(row) {
this.infoDb = false; this.infoDb = false;
let param = this.buildExecuteParam(row); let param = this.buildExecuteParam(row);
console.log(param)
if (this.planId) { if (this.planId) {
this.$post("/test/plan/scenario/case/run", param, response => { this.$post("/test/plan/scenario/case/run", param, response => {
this.runVisible = true; this.runVisible = true;
@ -293,6 +293,7 @@ export default {
// param.id = row.id; // param.id = row.id;
param.id = getUUID(); param.id = getUUID();
param.planScenarioId = row.id; param.planScenarioId = row.id;
console.log(row.id)
param.projectId = row.projectId; param.projectId = row.projectId;
param.planCaseIds = []; param.planCaseIds = [];
param.planCaseIds.push(row.id); param.planCaseIds.push(row.id);