grafana/postman-to-k6

--seperate results in GoError: The moduleSpecifier "./libs/shim/urijs.js" couldn't be found on local disk.

thim81 opened this issue · 6 comments

When using the --separator like postman-to-k6 postman.json -s -e environment.json -o k6-script.js

A range of folders and files are generated and grouped in the k6-script.js

// Auto-generated by the Load Impact converter

import "./libs/shim/core.js";
import { group } from "k6";
import "./requests/DomainClusters/Get-all-domain-cluster-configurations.js";

export let options = { maxRedirects: 4 };

const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
  options,
  collection: {
    undefined: "https://example.com/api"
  },
  environment: {
    baseUrl: "https://example.com/portal"
  }
});

export default function() {
  group("DomainClusters", function() {
    postman[Request]("Get all domain cluster configurations");
  });
}

In the Get-all-domain-cluster-configurations.js file the following code is present

import "./libs/shim/urijs.js";

postman[Symbol.for("define")]({
  name: "Get all domain cluster configurations",
  id: "cbe7c568-113f-4352-a0cc-bd8326ca9e7d",
  method: "GET",
  address: "{{baseUrl}}/portal/v1/domainclusters"
});

All files are present in the libs/shim folder.

When I run the k6 run --vus 100 --duration 1m k6-script.js, I get the following error.

ERRO[0006] GoError: The moduleSpecifier "./libs/shim/urijs.js" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker. at reflect.methodValueCall (native)

Info: I'm not using the Docker version, but installed k6 via Brew and using the 1.1.0 release of postman-to-k6 (which is the latest release according to NPM)

+1, same issue here

+1, very similar issue here happens for me when I attempt to use any way of running it with docker for script execution, and clearly supply it with folder that contains these libs folders which are being imported (performance-tests contains libs).

ERRO[0031] TypeError: Cannot read property 'graphqlRequestNameFromPostman' of undefined running at executePostrequest (file:///scripts/libs/shim/core.js:1174:203(90)) default at executeRequest (file:///scripts/libs/shim/core.js:968:25(123)) at executeRequest (file:///scripts/libs/shim/core.js:958:5(53)) at file:///scripts/libs/shim/core.js:307:46(35) at file:///scripts/loadTestDebugV2.js:120:23(29) at github.com/loadimpact/k6/js/common.Bind.func1 (native) at file:///scripts/loadTestDebugV2.js:119:19(42) at github.com/loadimpact/k6/js/common.Bind.func1 (native) at file:///scripts/loadTestDebugV2.js:85:17(5) executor=ramping-vus scenario=default source=stacktrace

docker-compose run -v /Users/myUser/documents/github/reponame/performance-tests:/scripts k6 run /scripts/loadTestDebugV2.js

It does not look like it is supported in the first place based on readme referring only command
k6 run script.js and not for example
docker run loadimpact/k6 run - < convertedScript.js

@mikpan @zakievvv Did you find a solution for the libs error? Just curious

Eomm commented

I have replaced this import:

-import './libs/shim/urijs.js'
+import '../../libs/shim/urijs.js'

in the request/ folder only as a workaround

Created a PR for this issue: #84

Thanks @Eomm for the simple solution.

Informational update:
The PR was pushed against the latest master (1.3.0) which is not yet release on NPM. On NPM https://www.npmjs.com/package/postman-to-k6 release 1.12 is still the latest.

Until v1.3.0 and potentially the PR is merged, I provided a separate 1.1.2 branch

  "dependencies": {
    "postman-to-k6": "git://github.com/thim81/postman-to-k6#1.1.2",

I'm not in favour of using PR directly but I'm just sharing in case people want a temporary work-a-round.
Once there is a new release on NPM (with the PR) I'll remove the fork.