# Conflicts:
#	backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
#	backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java
This commit is contained in:
fit2-zhao 2021-03-30 11:50:34 +08:00
commit 4f4aa6f5d2
13 changed files with 52 additions and 163 deletions

View File

@ -276,18 +276,11 @@
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<!-- swagger2 解析 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>1.0.51</version>
</dependency>
<!-- swagger3 解析 最新版本会有swagger-core版本冲突 -->
<!-- swagger 解析 -->
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.18</version>
<version>2.0.22</version>
</dependency>
<!-- 执行 js 代码依赖 -->
@ -674,4 +667,4 @@
</plugins>
</build>
</project>
</project>

View File

@ -89,7 +89,6 @@ public class MsScenario extends MsTestElement {
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
});
OldVersionUtil.transferHashTree(hashTree);
// 场景变量
if (StringUtils.isNotEmpty(element.getString("variables"))) {
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),

View File

@ -163,7 +163,6 @@ public abstract class MsTestElement {
element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {
});
hashTree.add(element);
OldVersionUtil.transferHashTree(hashTree);
}
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -361,7 +361,8 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
requestResult.addPassAssertions();
}
//xpath 提取错误会添加断言错误
if (StringUtils.isBlank(responseAssertionResult.getMessage()) || !responseAssertionResult.getName().endsWith("XPath2Extractor")) {
if (StringUtils.isBlank(responseAssertionResult.getMessage()) ||
(StringUtils.isNotBlank(responseAssertionResult.getName()) && !responseAssertionResult.getName().endsWith("XPath2Extractor"))) {
responseResult.getAssertions().add(responseAssertionResult);
}
}

View File

@ -82,11 +82,6 @@ public class HistoricalDataUpgradeService {
scenario.setName(oldScenario.getName());
scenario.setEnableCookieShare(oldScenario.isEnableCookieShare());
scenario.setEnvironmentId(oldScenario.getEnvironmentId());
if (StringUtils.isNotEmpty(oldScenario.getEnvironmentId())) {
HashMap<String, String> envMap = new HashMap<>();
envMap.put(projectId, oldScenario.getEnvironmentId());
scenario.setEnvironmentMap(envMap);
}
scenario.setReferenced("Upgrade");
scenario.setId(oldScenario.getId());
scenario.setResourceId(UUID.randomUUID().toString());
@ -431,9 +426,6 @@ public class HistoricalDataUpgradeService {
num++;
scenarioTest.setHashTree(listSteps);
if (StringUtils.isNotEmpty(envId)) {
HashMap<String, String> envMap = new HashMap<>();
envMap.put(saveHistoricalDataUpgrade.getProjectId(), envId);
scenarioTest.setEnvironmentMap(envMap);
scenarioTest.setEnvironmentId(envId);
}

View File

@ -409,7 +409,7 @@ public class TestPlanService {
|| StringUtils.equals(res, "success")
|| StringUtils.equals(res, ScenarioStatus.Success.name())) {
passNum++;
} else if (res == null) {
} else if (res == null || StringUtils.equals(TestPlanStatus.Prepare.name(), res)) {
prepareNum++;
} else {
failNum++;

View File

@ -114,9 +114,7 @@
</el-col>
<el-col :span="6">
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
:project-list="projectList" ref="envPopover"
:disabled="scenarioDefinition.length < 1"
:is-read-only="scenarioDefinition.length < 1"/>
:project-list="projectList" ref="envPopover"/>
</el-col>
<el-col :span="3">
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
@ -202,10 +200,7 @@
</template>
<maximize-scenario :scenario-definition="scenarioDefinition" :envMap="projectEnvMap" :moduleOptions="moduleOptions"
:currentScenario="currentScenario" :type="type" ref="maximizeScenario" @openScenario="openScenario"
:isHaveExec.sync="isHaveExec" :isExecWithOutEnv.sync="isExecWithOutEnv" :projectList="projectList"
:projectIds.sync="projectIds"
/>
:currentScenario="currentScenario" :type="type" ref="maximizeScenario" @openScenario="openScenario"/>
</ms-drawer>
</div>
@ -320,8 +315,6 @@
projectList: [],
debugResult: new Map,
drawer: false,
isHaveExec: false,
isExecWithOutEnv: true
}
},
created() {
@ -596,25 +589,9 @@
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
arr[i].countController.proceed = true;
}
let type = arr[i].type;
const canExec = this.checkCanExec(type);
if (!this.isHaveExec) {
//
this.isHaveExec = canExec;
}
if (canExec) {
const execWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
if (!execWithOutEnv) {
if (!arr[i].projectId) {
// IDIDIDID
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
}
this.projectIds.add(arr[i].projectId);
}
}
if (this.isExecWithOutEnv) {
this.isExecWithOutEnv = this.canExecWithOutEnv(type, arr[i].url)
if (!arr[i].projectId) {
// IDIDIDID
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
@ -626,24 +603,7 @@
}
}
},
canExecWithOutEnv(type, path) {
if (type === ELEMENT_TYPE.HTTPSamplerProxy) {
return this.isHTTPFullPath(path);
}
return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type);
},
isHTTPFullPath(path) {
return path ? path.startsWith("http://") || path.startsWith("https://") : false;
},
checkCanExec(type) {
const allCanExecType = ELEMENTS.get("AllCanExecType");
const index = allCanExecType.indexOf(type);
return index !== -1;
},
sort() {
this.projectIds.clear();
this.isHaveExec = false;
this.isExecWithOutEnv = true;
for (let i in this.scenarioDefinition) {
//
this.scenarioDefinition[i].index = Number(i) + 1;
@ -657,22 +617,6 @@
this.scenarioDefinition[i].projectId = this.projectId;
}
let type = this.scenarioDefinition[i].type;
const canExec = this.checkCanExec(type);
if (!this.isHaveExec) {
//
this.isHaveExec = canExec;
}
if (canExec) {
const execWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
if (!execWithOutEnv) {
this.projectIds.add(this.scenarioDefinition[i].projectId);
}
}
if (this.isExecWithOutEnv) {
this.isExecWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url)
}
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
}
@ -693,6 +637,7 @@
this.customizeRequest = {};
this.sort();
this.reload();
this.initProjectIds();
},
addScenario(arr) {
if (arr && arr.length > 0) {
@ -715,6 +660,7 @@
this.isBtnHide = false;
this.sort();
this.reload();
this.initProjectIds();
},
setApiParameter(item, refType, referenced) {
let request = {};
@ -756,6 +702,7 @@
this.isBtnHide = false;
this.sort();
this.reload();
this.initProjectIds();
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
@ -782,6 +729,7 @@
hashTree.splice(index, 1);
this.sort();
this.reload();
this.initProjectIds();
}
}
});
@ -812,19 +760,11 @@
},
runDebug() {
/*触发执行操作*/
if (!this.isHaveExec) {
this.$warning("无可执行步骤!");
let sign = this.$refs.envPopover.checkEnv();
if (!sign) {
return;
}
//
if (!this.isExecWithOutEnv) {
let sign = this.$refs.envPopover.checkEnv();
if (!sign) {
return;
}
}
this.$refs['currentScenario'].validate((valid) => {
if (valid) {
Promise.all([
@ -1063,6 +1003,7 @@
}
}
this.sort();
this.initProjectIds();
// this.getEnvironments();
})
}
@ -1132,8 +1073,19 @@
})
},
refReload() {
this.initProjectIds();
this.reload();
},
initProjectIds() {
//
this.$nextTick(() => {
this.projectIds.clear();
this.scenarioDefinition.forEach(data => {
let arr = jsonPath.query(data, "$..projectId");
arr.forEach(a => this.projectIds.add(a));
})
})
},
detailRefresh(result) {
//
this.debugResult = result;

View File

@ -164,7 +164,6 @@
type: String,
scenarioDefinition: Array,
envMap: Map,
projectList: Array
},
components: {
MsVariableList,
@ -225,10 +224,8 @@
response: {},
projectIds: new Set,
projectEnvMap: new Map,
// projectList: [],
projectList: [],
debugResult: new Map,
isHaveExec: false,
isExecWithOutEnv: true
}
},
created() {
@ -502,27 +499,8 @@
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
arr[i].countController.proceed = true;
}
let type = arr[i].type;
const canExec = this.checkCanExec(type);
if (!this.isHaveExec) {
//
this.isHaveExec = canExec;
this.$emit("update:isHaveExec", canExec);
}
if (canExec) {
const execWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
if (!execWithOutEnv) {
if (!arr[i].projectId) {
// IDIDIDID
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
}
this.projectIds.add(arr[i].projectId);
this.$emit('update:projectIds', this.projectIds);
}
}
if (this.isExecWithOutEnv) {
this.isExecWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
this.$emit('update:isExecWithOutEnv', this.canExecWithOutEnv(type, arr[i].url))
if (!arr[i].projectId) {
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree, arr[i].projectId);
@ -533,27 +511,7 @@
}
}
},
canExecWithOutEnv(type, path) {
if (type === ELEMENT_TYPE.HTTPSamplerProxy) {
return this.isHTTPFullPath(path);
}
return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type);
},
isHTTPFullPath(path) {
return path ? path.startsWith("http://") || path.startsWith("https://") : false;
},
checkCanExec(type) {
const allCanExecType = ELEMENTS.get("AllCanExecType");
const index = allCanExecType.indexOf(type);
return index !== -1;
},
sort() {
this.projectIds.clear();
this.$emit('update:projectIds', this.projectIds);
this.isHaveExec = false;
this.isExecWithOutEnv = true;
this.$emit('update:isHaveExec', false);
this.$emit('update:isExecWithOutEnv', true);
for (let i in this.scenarioDefinition) {
//
this.scenarioDefinition[i].index = Number(i) + 1;
@ -567,25 +525,6 @@
this.scenarioDefinition[i].projectId = this.projectId;
}
let type = this.scenarioDefinition[i].type;
const canExec = this.checkCanExec(type);
if (!this.isHaveExec) {
//
this.isHaveExec = canExec;
this.$emit('update:isHaveExec', canExec);
}
if (canExec) {
const execWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
if (!execWithOutEnv) {
this.projectIds.add(this.scenarioDefinition[i].projectId);
this.$emit('update:projectIds', this.projectIds);
}
}
if (this.isExecWithOutEnv) {
this.isExecWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
this.$emit('update:isExecWithOutEnv', this.canExecWithOutEnv(type, this.scenarioDefinition[i].url));
}
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
}
@ -606,6 +545,7 @@
this.customizeRequest = {};
this.sort();
this.reload();
this.initProjectIds();
},
addScenario(arr) {
if (arr && arr.length > 0) {
@ -623,6 +563,7 @@
}
this.sort();
this.reload();
this.initProjectIds();
this.scenarioVisible = false;
},
setApiParameter(item, refType, referenced) {
@ -664,6 +605,7 @@
});
this.sort();
this.reload();
this.initProjectIds();
},
openTagConfig() {
if (!this.projectId) {
@ -684,6 +626,7 @@
hashTree.splice(index, 1);
this.sort();
this.reload();
this.initProjectIds();
}
}
});
@ -980,8 +923,19 @@
refReload(data, node) {
this.selectedTreeNode = data;
this.selectedNode = node;
this.initProjectIds();
this.reload();
},
initProjectIds() {
//
this.$nextTick(() => {
this.projectIds.clear();
this.scenarioDefinition.forEach(data => {
let arr = jsonPath.query(data, "$..projectId");
arr.forEach(a => this.projectIds.add(a));
})
})
},
detailRefresh(result) {
//
this.debugResult = result;

View File

@ -19,8 +19,6 @@
<el-checkbox v-model="cookieShare" @change="setCookieShare" style="margin-right: 20px">共享cookie</el-checkbox>
<env-popover :env-map="envMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
:disabled="scenarioDefinition.length < 1"
:is-read-only="scenarioDefinition.length < 1"
:project-list="projectList" ref="envPopover" class="ms-right"/>
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>

View File

@ -157,7 +157,7 @@ export default {
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
if (this.tableData.filter(f => f.name === row.name).length > 0) {
this.$error(this.$t('load_test.delete_file'));
this.$error(this.$t('load_test.delete_file') + ', name: ' + row.name);
this.selectIds.clear();
return;
}
@ -216,7 +216,7 @@ export default {
}
if (this.tableData.filter(f => f.name === file.name).length > 0) {
this.$error(this.$t('load_test.delete_file'));
this.$error(this.$t('load_test.delete_file') + ', name: ' + file.name);
return false;
}
},

View File

@ -121,7 +121,7 @@ export default {
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
if (this.tableData.filter(f => f.name === row.name + ".jmx").length > 0) {
this.$error(this.$t('load_test.delete_file'));
this.$error(this.$t('load_test.delete_file') + ', name: ' + row.name);
return;
}
}

View File

@ -118,6 +118,7 @@
<el-input-number
:disabled="isReadOnly"
:min="1"
:max="threadGroup.duration"
v-model="threadGroup.rampUpTime"
@change="calculateTotalChart(threadGroup)"
size="mini"/>

View File

@ -923,7 +923,7 @@ export default {
}
if (this.tableData.filter(f => f.name === file.name).length > 0) {
this.$error(this.$t('load_test.delete_file'));
this.$error(this.$t('load_test.delete_file') + ', name: ' + file.name);
return false;
}