runner-runtime 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/events/api.js +8 -12
- package/events/index.js +5 -8
- package/libs/2har.js +0 -2
- package/libs/utils.js +6 -5
- package/package.json +1 -1
- package/tmp/request.js +913 -982
package/events/api.js
CHANGED
|
@@ -1554,10 +1554,7 @@ async function convert2EchoResponse(response, history) {
|
|
|
1554
1554
|
}
|
|
1555
1555
|
|
|
1556
1556
|
_.assign(cloneResponse, { mimeType, fitForShow });
|
|
1557
|
-
} catch (e) {
|
|
1558
|
-
|
|
1559
|
-
console.log(e, 1111)
|
|
1560
|
-
}
|
|
1557
|
+
} catch (e) { }
|
|
1561
1558
|
|
|
1562
1559
|
// 响应头对象
|
|
1563
1560
|
const responseHeader = {};
|
|
@@ -1668,7 +1665,6 @@ const preProcessMockExp = (request, requestPara, AllVars, option) => {
|
|
|
1668
1665
|
|
|
1669
1666
|
// 重置 restful
|
|
1670
1667
|
_.forEach(_.get(postmanJSON, 'url.path'), (item, key) => { //variable
|
|
1671
|
-
// console.log(item)
|
|
1672
1668
|
if (_.startsWith(item, ":")) {
|
|
1673
1669
|
const pathVarKey = _.findKey(_.get(postmanJSON, 'url.variable'), (vars) => {
|
|
1674
1670
|
return vars?.key == _.trimStart(item, ':')
|
|
@@ -1786,7 +1782,7 @@ const initRequestJson = (event, option) => {
|
|
|
1786
1782
|
} else {
|
|
1787
1783
|
getParentTargetIDs(option?.collection, _.get(event, `data.target_id`), parentIDs);
|
|
1788
1784
|
}
|
|
1789
|
-
|
|
1785
|
+
|
|
1790
1786
|
if (!_.includes(parentIDs, "0")) {
|
|
1791
1787
|
parentIDs.push("0");
|
|
1792
1788
|
}
|
|
@@ -1800,7 +1796,7 @@ const initRequestJson = (event, option) => {
|
|
|
1800
1796
|
// 目录参数
|
|
1801
1797
|
_.assign(request, _.get(getAPIFromCollection(option?.collection, parent_id), "request"));
|
|
1802
1798
|
}
|
|
1803
|
-
|
|
1799
|
+
|
|
1804
1800
|
if (_.isObject(request) && !_.isEmpty(request)) {
|
|
1805
1801
|
["header", "body", "query", "cookie"].forEach((parameter) => {
|
|
1806
1802
|
let arrPara = _.filter(_.get(request, `${parameter}.parameter`), (item) => { return _.toInteger(item.is_system) > 0 || item.is_checked > 0 });
|
|
@@ -2202,7 +2198,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2202
2198
|
})
|
|
2203
2199
|
}
|
|
2204
2200
|
}
|
|
2205
|
-
|
|
2201
|
+
|
|
2206
2202
|
const requestOptions = convert2EchoRequest(request, requestJson, postmanJSON, history);
|
|
2207
2203
|
_.set(eventRuntimeData, [event?.event_id, "request"], requestOptions);
|
|
2208
2204
|
|
|
@@ -2228,11 +2224,14 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2228
2224
|
},
|
|
2229
2225
|
|
|
2230
2226
|
test(err, cursor, results, item) {
|
|
2227
|
+
console.log(4444444, err)
|
|
2231
2228
|
if (!err) {
|
|
2232
2229
|
if (!_.includes(['get_parsed_request'], scene)) {
|
|
2230
|
+
|
|
2233
2231
|
_.forEach(results, (result) => {
|
|
2234
2232
|
_.forEach(['_variables', 'environment', 'globals'], (varType) => {
|
|
2235
2233
|
const currentVar = _.get(result, `result.${varType}`);
|
|
2234
|
+
|
|
2236
2235
|
try {
|
|
2237
2236
|
_.forEach(currentVar.toObject(), (val, key) => {
|
|
2238
2237
|
let setPath = varType;
|
|
@@ -2258,10 +2257,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2258
2257
|
if (_.isUndefined(_.get(eventRuntimeData, [event?.event_id, "assertions"]))) {
|
|
2259
2258
|
_.set(eventRuntimeData, [event?.event_id, "assertions"], []);
|
|
2260
2259
|
}
|
|
2261
|
-
|
|
2262
2260
|
eventRuntimeData[event?.event_id].assertions = _.unionWith(_.concat(_.get(eventRuntimeData, [event?.event_id, "assertions"]), assertions), _.isEqual);
|
|
2263
|
-
|
|
2264
|
-
// console.log(eventRuntimeData[event?.event_id].assertions,111111)
|
|
2265
2261
|
}
|
|
2266
2262
|
}
|
|
2267
2263
|
},
|
|
@@ -2296,7 +2292,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
|
|
|
2296
2292
|
})
|
|
2297
2293
|
|
|
2298
2294
|
_.set(eventRuntimeData, [event?.event_id, "status"], {
|
|
2299
|
-
assert: [event?.event_id, "assertions"],
|
|
2295
|
+
assert: _.get(eventRuntimeData, [event?.event_id, "assertions"]),
|
|
2300
2296
|
success_assert,
|
|
2301
2297
|
http: _.get(eventRuntimeData, [event?.event_id, 'response', 'status']) || _.get(eventRuntimeData, [event?.event_id, 'error', 'message'])
|
|
2302
2298
|
});
|
package/events/index.js
CHANGED
|
@@ -57,7 +57,6 @@ const events = {
|
|
|
57
57
|
const { iterationData, enable_data } = data;
|
|
58
58
|
|
|
59
59
|
if (_.toInteger(enable_data) > 0) {
|
|
60
|
-
console.log(_.assign(_.cloneDeep(option), { iterationData }), 11111111111111)
|
|
61
60
|
await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationData }), callback, eventRuntimeData, eventResultList)
|
|
62
61
|
} else {
|
|
63
62
|
await iterationEvent(children, option, callback, eventRuntimeData, eventResultList)
|
|
@@ -202,11 +201,11 @@ const events = {
|
|
|
202
201
|
await iterationEvent(events, _.assign(_.cloneDeep(option), { iterationDataArr: iterationData, sleep, startTime, timeout }), callback, eventRuntimeData, eventResultList)
|
|
203
202
|
}
|
|
204
203
|
} else if (_.includes([3], loopType)) {
|
|
205
|
-
const condition = _.get(option, 'condition', _.get(data, 'loop_condition', {}));
|
|
206
|
-
const exp = variableReplace(condition?.var, eventRuntimeData?.variables, option), compare = condition?.compare, value = variableReplace(condition?.value, eventRuntimeData?.variables, option);
|
|
207
|
-
console.log(exp, compare, value, `loopTypeloopTypeloopTypeloopTypeloopTypeloopTypeloopTypeloopType`, !returnBoolean(exp, compare, value))
|
|
208
204
|
while (true) {
|
|
209
|
-
|
|
205
|
+
const condition = _.get(option, 'condition', _.get(data, 'loop_condition', {}));
|
|
206
|
+
const exp = variableReplace(condition?.var, eventRuntimeData?.variables, option), compare = condition?.compare, value = variableReplace(condition?.value, eventRuntimeData?.variables, option);
|
|
207
|
+
|
|
208
|
+
if ((timeout === 0 || (timeout > 0 && startTime + timeout > Date.now())) && !returnBoolean(exp, compare, value)) {
|
|
210
209
|
await iterationEvent(_.cloneDeep(children), _.assign(_.cloneDeep(option), { iterationDataArr: iterationData, sleep, condition, startTime, timeout }), callback, eventRuntimeData, eventResultList);
|
|
211
210
|
} else {
|
|
212
211
|
break;
|
|
@@ -220,7 +219,6 @@ const events = {
|
|
|
220
219
|
current_event_id: event?.event_id
|
|
221
220
|
});
|
|
222
221
|
} catch (e) {
|
|
223
|
-
console.log(e, 1111111)
|
|
224
222
|
return ({
|
|
225
223
|
action: 'stystemError',
|
|
226
224
|
message: String(e),
|
|
@@ -232,9 +230,8 @@ const events = {
|
|
|
232
230
|
|
|
233
231
|
// 调度器核心函数,用于递归执行具体场景步骤
|
|
234
232
|
const executeEvent = (event, option, callback, eventRuntimeData, eventResultList) => {
|
|
235
|
-
_.assign(eventRuntimeData?.variables?.iterationData, _.get(option, 'iterationData'))
|
|
236
|
-
// console.log(option,`optionoptionoptionoptionoptionoptionoptionoption`)
|
|
237
233
|
return new Promise((resolve, reject) => {
|
|
234
|
+
_.assign(eventRuntimeData?.variables?.iterationData, _.get(option, 'iterationData'))
|
|
238
235
|
_.set(eventRuntimeData, [event.event_id, 'iteration_id'], aTools.snowflakeId());
|
|
239
236
|
|
|
240
237
|
const eventCall = _.get(events, `${event?.type}`);
|
package/libs/2har.js
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* @returns {Object} HAR format JSON object.
|
|
19
19
|
*/
|
|
20
20
|
function generateHarFromRequest(options) {
|
|
21
|
-
// console.log(options)
|
|
22
21
|
const {
|
|
23
22
|
url,
|
|
24
23
|
method = 'GET',
|
|
@@ -106,7 +105,6 @@ function processQueryString(queryParams) {
|
|
|
106
105
|
* @returns {Object|undefined} HAR postData object.
|
|
107
106
|
*/
|
|
108
107
|
function processBody(body) {
|
|
109
|
-
// console.log(body)
|
|
110
108
|
const { mode } = body;
|
|
111
109
|
|
|
112
110
|
if (mode === 'none') {
|
package/libs/utils.js
CHANGED
|
@@ -25,7 +25,7 @@ const getParentTargetIDs = function (collection, target_id, parent_ids) {
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
if(_.isString(item.parent_id)){
|
|
28
|
+
if (_.isString(item.parent_id)) {
|
|
29
29
|
parent_ids.push(item.parent_id);
|
|
30
30
|
getParentTargetIDs(collection, item.parent_id, parent_ids);
|
|
31
31
|
}
|
|
@@ -311,13 +311,15 @@ const getCaseInsensitive = (object, keyToFind) => {
|
|
|
311
311
|
|
|
312
312
|
const variableReplace = (str, variables, option) => {
|
|
313
313
|
const AllVars = getInsideVariables();
|
|
314
|
-
["variables", "globals", "environment"].forEach((varName) => {
|
|
314
|
+
["variables", "globals", "_globals", "environment"].forEach((varName) => {
|
|
315
|
+
console.log(11111111,_.get(variables, `${varName}`))
|
|
315
316
|
_.assign(AllVars, _.get(variables, `${varName}`))
|
|
316
317
|
})
|
|
318
|
+
|
|
317
319
|
str = _.replace(str, /\{\{([^}]+)\}\}/g, (match, key) => {
|
|
318
320
|
return _.get(AllVars, key.trim(), match);
|
|
319
321
|
});
|
|
320
|
-
|
|
322
|
+
console.log(2222222, str, _.get(AllVars, 'IF_xunhuan'),_.keys(AllVars))
|
|
321
323
|
const { lang, custom_functions } = option;
|
|
322
324
|
|
|
323
325
|
try {
|
|
@@ -448,7 +450,6 @@ const formatAutotestReportList = (eventResultList) => {
|
|
|
448
450
|
type = 'api';
|
|
449
451
|
}
|
|
450
452
|
|
|
451
|
-
// console.log(item?.response,3333333333)
|
|
452
453
|
list.push(_.assign(
|
|
453
454
|
_.pick(item?.response, ['timings', 'response_time', 'response_at', 'proxy', 'status', 'code', 'response_size']),
|
|
454
455
|
_.pick(item?.request, ['url', 'method', 'name', 'target_id', 'project_id']),
|
|
@@ -490,7 +491,7 @@ const formatAutotestReport = (startTimeAt, eventResultList) => {
|
|
|
490
491
|
|
|
491
492
|
let totalResponseSize = 0, totalResponseTime = 0
|
|
492
493
|
|
|
493
|
-
_.forEach(eventResultList, (item) => {
|
|
494
|
+
_.forEach(_.cloneDeep(eventResultList), (item) => {
|
|
494
495
|
if (_.includes(['api', 'sample'], item?.type)) {
|
|
495
496
|
report.http.total++;
|
|
496
497
|
totalResponseSize = totalResponseSize + _.toInteger(item?.response?.response_size);
|