When I am executing scenarios.js using below command, I am getting this error:
ERRO[0002] json: unsupported type: func(goja.FunctionCall) goja.Value
I have attached scenarios,js and other file orderListDownload.js which I have imported in scenarios.js below.
I have been able to execute orderListDownload.js directly using k6 run command easily without any issues. But as we have multiple such files, want to create a separate js file with just scenarios and want to import the different functions(exec value from different files).
Please suggest how can we achieve this.
Fyi, we have more than 100 js files already in place and we do not use scenarios instead use bash to run performance test load. But to simplify things and get rid of bash file want to make use of scenarios and executors. Please suggest how can we import the different files in scenarios.js and run entire suite. Also we should be able to run the different files(to be imported in scenarios.js, example orderListDownload.js below) separately using k6 run command.
scenarios.js:
import http from 'k6/http';
import { orderListDownload } from './orderListDownload.js';
export let options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'shared-iterations',
vus: 5,
iterations: 3,
maxDuration: '30s',
exec: orderListDownload,
},
},
};
orderListDownload.js
import http from "k6/http";
import { Trend } from "k6/metrics";
import * as common from "../../commonUtils/common.js";
import { getorderListDownload } from "../../scripts/pgp/orderListDownload.js";
//headers for http request
let headers = { headers: { "Content-Type": "application/json" }, tags: { name: "I02_01_orderListDownload" } };
//Opening config files
const commonConfig = common.commonConfigObj();
const datafilesConfig = common.datafilesConfigObj();
const endPoints = common.endPointsObj();
var dataSet, url, MID, MIDs,endTime,startTime;
let payload, response;
var accessUrl = common.getAccessUrl();
if (__ENV.testEnv == "perf") {
dataSet = common.perfDataObj();
}
else if (__ENV.testEnv == "shadow") {
dataSet = common.shadowDataObj();
}
else if (__ENV.testEnv == "mock") {
dataSet = common.mockDataObj();
}
//To get api stats for two metric separately.
let myTrend = new Trend("I02_01_orderListDownload");
export function orderListDownload() {
//MIDs = common.getFromCacheDuplicateValuesAllowed(__ENV.domain + "_" + __ENV.testEnv + "_" + datafilesConfig.MIDs);
//MID = MIDs.split(",")[0];
//MID = "216820000271071338410"; //IRCTC
//MID = "216820000262640130669"; //Normal
//endTime = "2020-05-22T20:50:00+05:30";
//startTime = "2020-04-23T00:00:00+05:30";
//http request for getGVtemplateSummaryList
payload = getorderListDownload(MID,endTime,startTime);
payload = common.appendSHA256_Signature(payload);
url = accessUrl + endPoints.pgp_orderListDownload;
response = http.post(url, payload, headers);
myTrend.add(response.timings.duration, { name: "I02_01_orderListDownload" });
common.responseCheck(url, payload, response, "SUCCESS", "orderListDownload");
}