Giter Site home page Giter Site logo

grafana / jmeter-to-k6 Goto Github PK

View Code? Open in Web Editor NEW
65.0 123.0 21.0 761 KB

Converts JMeter .jmx files to k6 JS code

License: Apache License 2.0

JavaScript 99.91% Dockerfile 0.09%
jmeter k6 load-testing performance-testing jmx-files converts-jmeter k6-converter maintainer-wanted

jmeter-to-k6's Introduction

⚠️ This project is no longer maintained.

Development and maintenance of the JMeter-to-k6 converter have been stopped in this repository.

If you are a JMeter user starting with k6, check out how k6 compares to JMeter and learn how to use k6 on the documentation.


Install:

Globally, and preferably using nvm (at least on Unix/Linux systems to avoid filesystem permission issues when using sudo):

npm install -g jmeter-to-k6

Locally, into ./node_modules:

npm install jmeter-to-k6

Note that this will require you to run the converter with node node_modules/jmeter-to-k6/bin/jmeter-to-k6.js ....

Alternatively, you can install the tool from DockerHub:

docker pull loadimpact/jmeter-to-k6

Convert:

Convert JMeter JMX to k6 JS.

jmeter-to-k6 example/full.jmx -o full

This will create a directory ./full/ with a file called test.js and a sub-directory called libs.

One-off execution using npx (avoiding the installation of the tool on your system):

npx jmeter-to-k6 example/full.jmx -o full

Using the Docker image, you execute the tool as follows:

docker run -it -v "/path/to/jmeter-files/:/output/" loadimpact/jmeter-to-k6 /output/MyTest.jmx -o /output/MyTestOutput/

and then execute the k6 test using:

k6 run /path/to/jmeter-files/MyTestOutput/test.js

Run test in k6:

k6 run full/test.js

jmeter-to-k6's People

Contributors

bookmoons avatar dependabot[bot] avatar legander avatar robingustafsson avatar simskij avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmeter-to-k6's Issues

Security vulnerabilities with one of the dependencies - yargs-parserr

npm audit shows the following:
=== npm audit security report ===

┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ yargs-parser │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=13.1.2 <14.0.0 || >=15.0.1 <16.0.0 || >=18.1.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jmeter-to-k6 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ jmeter-to-k6 > yargs > yargs-parser │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1500
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ papaparse │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=5.2.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ jmeter-to-k6 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ jmeter-to-k6 > papaparse │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1515

UnhandledPromiseRejectionWarning: Error: Invalid HTTPSamplerProxy at Object.HTTPSamplerProxy

Error output

(node:91086) UnhandledPromiseRejectionWarning: Error: Invalid HTTPSamplerProxy
    at Object.HTTPSamplerProxy (/usr/local/lib/node_modules/jmeter-to-k6/src/element/HTTPSamplerProxy.js:32:11)
    at element (/usr/local/lib/node_modules/jmeter-to-k6/src/element.js:66:36)
    at module.exports (/usr/local/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/local/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports (/usr/local/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.hashTree (/usr/local/lib/node_modules/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/usr/local/lib/node_modules/jmeter-to-k6/src/element.js:66:36)
    at module.exports (/usr/local/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/local/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports (/usr/local/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:91086) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91086) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce

  • Run jmeter-to-k6 test.jmx -o test-k6.js

System configuration

node --version
v14.14.0
npm --version
6.14.8
jmeter-to-k6 --version
1.0.0
Operating System
macOS Catalina 10.15.7

JMX input file

https://drive.google.com/file/d/1qTGD69JeK5Y7w44Ml4G2dPC-HqZ0nZr5/view?usp=sharing

Response assertion comparing response status as string with ===

The following JMX:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.domain">test.loadimpact.com</stringProp>
          <stringProp name="HTTPSampler.port"></stringProp>
          <stringProp name="HTTPSampler.protocol">https</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/</stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
          <stringProp name="HTTPSampler.response_timeout"></stringProp>
        </HTTPSamplerProxy>
        <hashTree>
          <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Status code is 200" enabled="true">
            <collectionProp name="Asserion.test_strings">
              <stringProp name="49586">200</stringProp>
            </collectionProp>
            <stringProp name="Assertion.custom_message"></stringProp>
            <stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
            <boolProp name="Assertion.assume_success">false</boolProp>
            <intProp name="Assertion.test_type">8</intProp>
          </ResponseAssertion>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

Converts to this JS:

import http from "k6/http";
import { check } from "k6";

let url, opts, r;

export let options = {
  stages: [{ target: 1, duration: "1s" }]
};

export default function(data) {
  if (__VU >= 1 && __VU <= 1) {
    if (__ITER < 1) {
      url = "https://test.loadimpact.com/";
      opts = {
        redirects: 999
      };
      r = http.request("GET", url, "", opts);

      check(r, {
        "Status code is 200": r => {
          return r.status === "200";
        }
      });
    }
  }
}

As the check is using equality without type coercion we either need to make sure the response status entered by user in JMeter is converted to an integer when code is generated or that the check is == with type coercion, or the Status code is 200 check will fail. I think the former would be preferred, but maybe not possible.

Unable to convert .jmx file to k6 using jmeter-to-k6, when using CSV dataset config element in my jmeter

Hello All,
I'm getting below error when I'm trying to convert my jmx file to k6. Its says Cannot find module 'tinyify'
I'm not sure why this issue is occuring. Please get it resolved soon. Using Jmeter version 5.0

(node:8518) UnhandledPromiseRejectionWarning: Error: Cannot find module 'tinyify' from '/Users/ashadrahman'
at Function.module.exports [as sync] (/Users/ashadrahman/jmeter-to-k6/node_modules/resolve/lib/sync.js:71:15)
at Browserify.plugin (/Users/ashadrahman/jmeter-to-k6/node_modules/browserify/index.js:388:29)
at Promise (/Users/ashadrahman/jmeter-to-k6/src/build.js:83:13)
at new Promise ()
at bundle (/Users/ashadrahman/jmeter-to-k6/src/build.js:81:10)
at buildCompat (/Users/ashadrahman/jmeter-to-k6/src/build.js:15:12)
(node:8518) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:8518) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Docker image

Having this as a docker image will IMO be much better user experience than installing it with npm

Error: Unrecognized element: CacheManager

Running in docker , i get this error:

/home/node/jmeter-to-k6/src/element.js:50
  if (!route[name]) throw new Error('Unrecognized element: ' + name)
                    ^

Error: Unrecognized element: CacheManager
    at element (/home/node/jmeter-to-k6/src/element.js:50:27)
    at module.exports.args (/home/node/jmeter-to-k6/src/element.js:1:40)
    at elements (/home/node/jmeter-to-k6/src/elements.js:17:43)
    at module.exports.args (/home/node/jmeter-to-k6/src/elements.js:1:40)
    at Object.hashTree (/home/node/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/home/node/jmeter-to-k6/src/element.js:53:36)
    at module.exports.args (/home/node/jmeter-to-k6/src/element.js:1:40)
    at elements (/home/node/jmeter-to-k6/src/elements.js:17:43)
    at module.exports.args (/home/node/jmeter-to-k6/src/elements.js:1:40)
    at Object.TestPlan (/home/node/jmeter-to-k6/src/element/TestPlan.js:14:17)

Is this version support for jMeter 5.1.1?

I've tried to convert my JMX file to k6. First, I got an error for CacheManager. Fortunately CacheManager not being useful for my script, so I remove the CacheManager and I got another error. There is an error when I create user-defined variables.

In simple, these are the errors I faced:

  1. Error CacheManager element
  2. User Defined Variable error

Do not fail a convert for "Unrecognized element"

Is your feature request related to a problem?

As jmeter-to-k6 will not be able to work on all JMeter files, I think it is a good idea not to fail a convert for "Unrecognized element", for e.g., #49.

Describe the solution you'd like

Turn those unrecognized elements into comments.
For e.g., #49, just add a comment line /* TODO: JDBCSampler */, where the JDBCSampler step should be and move on. Maybe that's the only 1% failure of the script and the rest of 99% is fine.

Another example:

(node:8140) UnhandledPromiseRejectionWarning: Error: Unrecognized element: kg.apc.jmeter.samplers.DummySampler
    at element (/usr/lib/node_modules/jmeter-to-k6/src/element.js:61:11)

Describe alternatives you've considered

There might be alternatives, but the point is, for the case of only 1% the script failed the rest of 99% fine part, not failing a convert process might be the cheapest choice, among all alternative cases.

Error: Unrecognized element: ResultCollector

The tool is throwing an error on meeting ResultCollector element in jmx file:

(node:53160) UnhandledPromiseRejectionWarning: Error: Unrecognized element: ResultCollector
    at element (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element.js:50:27)
    at module.exports (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element.js:1:40)
    at elements (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/elements.js:17:43)
    at module.exports (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/elements.js:1:40)
    at Object.hashTree (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element.js:53:36)
    at module.exports (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element.js:1:40)
    at elements (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/elements.js:17:43)
    at module.exports (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/elements.js:1:40)
    at Object.TestPlan (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/element/TestPlan.js:14:17)
(node:53160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:53160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Example of the snippet:

<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregate Report" enabled="false">
        <boolProp name="ResultCollector.error_logging">false</boolProp>
        <objProp>
          <name>saveConfig</name>
          <value class="SampleSaveConfiguration">
            <time>true</time>
            <latency>true</latency>
            <timestamp>true</timestamp>
            <success>true</success>
            <label>true</label>
            <code>true</code>
            <message>true</message>
            <threadName>true</threadName>
            <dataType>true</dataType>
            <encoding>false</encoding>
            <assertions>true</assertions>
            <subresults>true</subresults>
            <responseData>false</responseData>
            <samplerData>false</samplerData>
            <xml>false</xml>
            <fieldNames>true</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>false</responseDataOnError>
            <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
            <bytes>true</bytes>
            <threadCounts>true</threadCounts>
            <idleTime>true</idleTime>
          </value>
        </objProp>
        <stringProp name="filename">/tmp/aggregate-jmeter-results.jtl</stringProp>
      <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/aggregate_report.jmx</stringProp></ResultCollector>

Unable to convert JMeter file to K6, getting error (node:8216) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated

I'm trying to convert the file attached, but I'm getting the error below:

C:\jmeter>jmeter-to-k6 TestOPSWAT.jmx -o full
(node:8216) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
at func (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\render.js:25:42)
at evaluate (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\render.js:18:12)
at replace (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\render.js:7:10)
at C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\render.js:52:40
at Array.map ()
at render (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\render.js:52:25)
at runtimeString (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\run.js:12:21)
at property (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HTTPSamplerProxy.js:208:24)
at Object.HTTPSamplerProxy (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HTTPSamplerProxy.js:27:5)
at element (C:\Users\malaw\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:66:36)
(Use node --trace-warnings ... to show where the warning was created)
(node:8216) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8216) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

TestOPSWAT.zip

TypeError when converting a JMeter file with only a CSV Data Set config element

When trying to convert the following JMX:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
        <stringProp name="delimiter">,</stringProp>
        <stringProp name="fileEncoding">UTF-8</stringProp>
        <stringProp name="filename">/Users/robin/Projects/loadimpact/jmeter-to-k6/example/file.csv</stringProp>
        <boolProp name="ignoreFirstLine">false</boolProp>
        <boolProp name="quotedData">false</boolProp>
        <boolProp name="recycle">true</boolProp>
        <stringProp name="shareMode">shareMode.all</stringProp>
        <boolProp name="stopThread">false</boolProp>
        <stringProp name="variableNames"></stringProp>
      </CSVDataSet>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

I get this:

/<path-to-repo>/src/strip.js:2
  const start = string.search(/[^\n]/)
                       ^
TypeError: Cannot read property 'search' of undefined
    at strip (/<path-to-repo>/src/strip.js:2:24)
    at renderLogic (/<path-to-repo>/src/render.js:207:5)
    at render (/<path-to-repo>/src/render.js:26:5)
    at convert (/<path-to-repo>/src/convert.js:5:10)
    at Object.<anonymous> (/<path-to-repo>/bin/jmeter-to-k6.js:39:20)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)

Undefined variable when it's being converted

I has problem in the following place:

const makeContext = require('../context')
const text = require('../text')

/**
 * Convert variable
 *
 * @param {object} node - Parsed variable node.
 *
 * @return {ConvertResult}
 */
function variable (node, context = makeContext()) {
  const properties = node.children.filter(item => item.name === 'stringProp')
  const nameNode = properties.find(item => {
    return item.attributes.name.split('.').pop() === 'name'
  })
  if (!nameNode) throw new Error('Variable missing name')
  const valueNode = properties.find(item => {
    return item.attributes.name.split('.').pop() === 'value'
  })
  if (!valueNode) throw new Error('Variable missing value')
  const description = properties.find(item => {
    return item.attributes.name.split('.').pop() === 'desc'
  })
  const result = { vars: new Map() }
  const spec = { value: text(valueNode.children) }
  if (description) spec.comment = text(description.children)
  const name = text(nameNode.children)
  result.vars.set(name, spec)
  context.vars.set(name, spec.value)
  return result
}

module.exports = variable

The following objects have empty maps at the end of execution:

 result.vars.set(name, spec)
 context.vars.set(name, spec.value)

Local variables are defined, and in general the functionality works properly, except for the lines I mentioned, I tried changing the new Map () to {}, and it works, but there are a lot of dependent places that use the context with vars.map.

 UnhandledPromiseRejectionWarning: Error: Undefined variable: front_url
    at variable (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\interpolate.js:43:38)
    at evaluate (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\interpolate.js:30:15)
    at replace (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\interpolate.js:20:10)
    at C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\interpolate.js:10:38
    at Array.map (<anonymous>)
    at interpolate (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\interpolate.js:10:25)
    at string (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\string\convert.js:7:41)
    at value (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\value.js:5:10)
    at extractValue (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\common\property.js:20:19)
    at property (C:\Users\username\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\common\property.js:11:25)
(node:4740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (reject
ion id: 1)
(node:4740) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node: v12.13.1

Create this tool [bounty: $2200]

Converting JMeter JMX files to k6 JS

View on BountySource

The goal of this project is to write a separate tool from k6 (similar to the existing Postman converter) that can convert JMeter .jmx files to k6 JS. The aim is to cover as many of the most common features in JMeter as possible to make the tool a great aid when migrating from JMeter to k6.

Requirements

The tool must be written in either JS or Go, which are the two languages used by k6.

The tool must support the following JMX/XML tags unless it turns out to be infeasible after discussion in this issue (the Component Reference will be very helpful here).:

Config

  • hashTree
  • jmeterTestPlan
  • TestPlan
  • ConfigTestElement
  • kg.apc.jmeter.threads.SteppingThreadGroup
    • This should be converted to the equivalent stages option in k6 JS. Each step should be a { target: X, duration: Y } entry.
  • ThreadGroup
    • This should be converted to the equivalent stages option in k6 JS ("Number of Threads" = number of VUs, aka the "target" in the stages option, "Ramp-up Period" = the "duration" of the ramp-up in the stages option). If more than one ThreadGroup has been defined they should be merged into one stages option (potentially with several { target: X, duration: Y } entries) and the correct distribution of VUs should be handled in the export default function using __VU and if/else JS statements.
    • The special case of a setUp ThreadGroup should be converted to a corresponding export function setup() in k6 JS.
    • The special case of a tearDown ThreadGroup should be converted to a corresponding export function teardown() in k6 JS.

Managers

Assertions (should be converted to k6 checks)

Logic controllers

  • ForeachController
    • This should be converted to the equivalent JS for statement (or Array.forEach(function(...) { ... }); statement).
  • GenericController
  • IfController
    • This should be converted to the equivalent JS if statement using the specified condition, to control whether to run the child controllers or not.
  • InterleaveControl
    • This should be converted to use something like a JS switch statement: switch (__ITER % NUM_OF_SUB_CONTOLLERS) { case 1: ... case 2: ... etc. } to alternative between the child controllers.
  • LoopController
    • This should be converted into the equivalent JS for loop in k6 JS.
  • OnceOnlyController
    • This should be converted to if (__ITER === 1) { ... } in k6 JS. If in a looping container it should also be restricted to only run on the first iteration.
  • WhileController
    • This should be converted to the equivalent JS while statement using the specified condition.
  • RunTimeController
    • This should be converted to use a global timestamp var, something like const TEST_START_TIME = Date().now();, and then in the script an if check like if (RUNTIME_CONTROLLER_SECS * 1000 > Date.now() - TEST_START_TIME) { ...execute child controllers... }.
  • TransactionController
  • SimpleController
  • RandomController
    • This should be converted to pick a child controller at random every execution using something like let rndIndex = Math.floor(Math.random() * (NUM_OF_SUB_CONTOLLERS + 1)).

Timers

  • ConstantTimer
    • This should be converted to the equivalent sleep(...) call in k6 JS.

Data

  • CSVDataSet (might need to be removed as we don’t have any native CSV APIs yet, maybe if CSV streaming PR is included we could have this?)
  • Arguments

Post-processors

For the following tags it’s enough to dump the code contents as a comment into the JS output:

  • JSR223PreProcessor
  • JSR223PostProcessor
  • BeanShellPreProcessor
  • BeanShellPostProcessor

A completed bounty must include a test suite to make sure the converter can properly handle the required tags specified above. It should also include instructions on how to download, build and run the converter in the README.

Resources

HTMLExtractor converted code can't use array indexing on Selector object

The following JMeter JMX:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.domain">httpbin.test.loadimpact.com</stringProp>
          <stringProp name="HTTPSampler.port"></stringProp>
          <stringProp name="HTTPSampler.protocol">https</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/html</stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
          <stringProp name="HTTPSampler.response_timeout"></stringProp>
        </HTTPSamplerProxy>
        <hashTree/>
        <HtmlExtractor guiclass="HtmlExtractorGui" testclass="HtmlExtractor" testname="CSS Selector Extractor" enabled="true">
          <stringProp name="HtmlExtractor.refname">pageTitle</stringProp>
          <stringProp name="HtmlExtractor.expr">body h1</stringProp>
          <stringProp name="HtmlExtractor.attribute"></stringProp>
          <stringProp name="HtmlExtractor.default">Default Title</stringProp>
          <boolProp name="HtmlExtractor.default_empty_value">false</boolProp>
          <stringProp name="HtmlExtractor.match_number">0</stringProp>
          <stringProp name="HtmlExtractor.extractor_impl"></stringProp>
        </HtmlExtractor>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

results in the following JS code:

import html from "k6/html";
import http from "k6/http";
import { check } from "k6";

const vars = {};

let output, matches, match, extract, url, opts, r;

export let options = {
  stages: [{ target: 1, duration: "1s" }]
};

export default function(data) {
  if (__VU >= 1 && __VU <= 1) {
    if (__ITER < 1) {
      url = "https://httpbin.test.loadimpact.com/html";
      opts = {
        redirects: 999
      };
      r = http.request("GET", url, "", opts);

      {
        output = "pageTitle";
        const doc = html.parseHTML(r.body);
        matches = doc.find("body h1");
        match =
          matches.size() === 0
            ? null
            : matches[Math.floor(Math.random() * matches.size())];
        extract = match ? match.text() : null;
        vars[output] = extract || "Default Title";
      }
    }
  }
}

The problem with this code is that the Selector object returned by doc.find() is not a JS Array but an Object. The correct code would instead use the Selector.eq() method:

match = matches.size() === 0 ? null : matches.eq(Math.floor(Math.random() * matches.size()));

(node:65847) UnhandledPromiseRejectionWarning: Error: Unrecognized element: kg.apc.jmeter.vizualizers.CorrectedResultCollector

I get the following information when run jmeter-to-k6 DEC.jmx -o full

(node:65847) UnhandledPromiseRejectionWarning: Error: Unrecognized element: kg.apc.jmeter.vizualizers.CorrectedResultCollector
    at element (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element.js:61:11)
    at module.exports.args (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports.args (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.hashTree (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element.js:66:36)
    at module.exports.args (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports.args (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.TestPlan (/Users/zc/.nvm/versions/node/v10.19.0/lib/node_modules/jmeter-to-k6/src/element/TestPlan.js:18:17)
(node:65847) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:65847) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Error: Undefined variable "X"

The tool seems to strugle to find variables defines this way:

  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Benchmark" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments">
          <elementProp name="host" elementType="Argument">
            <stringProp name="Argument.name">host</stringProp>
            <stringProp name="Argument.value">${__P(host,localhost)}</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
      </collectionProp>
      </elementProp>
    </TestPlan>
</hashTree>

I have got this error:

(node:55861) UnhandledPromiseRejectionWarning: Error: Undefined variable: host
    at variable (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/interpolate.js:40:38)
    at evaluate (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/interpolate.js:27:15)
    at replace (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/interpolate.js:20:10)
    at /Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/interpolate.js:10:38
    at Array.map (<anonymous>)
    at interpolate (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/interpolate.js:10:25)
    at string (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/string/convert.js:7:41)
    at value (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/value.js:5:10)
    at extractValue (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/common/property.js:20:19)
    at property (/Users/glushko/.nvm/versions/node/v12.14.1/lib/node_modules/jmeter-to-k6/src/common/property.js:11:25)
(node:55861) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:55861) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

console.log(context.vars) returns Map {} in the variable() method:

function variable (name, context) {
  console.log(context.vars)
  if (!context.vars.has(name)) throw new Error('Undefined variable: ' + name)
  return context.vars.get(name)
}

Here is a link to the full JMX file - https://raw.githubusercontent.com/magento/magento2/2.4-develop/setup/performance-toolkit/benchmark.jmx

Unhandled promise rejection for the full.jmx example

Describe the bug

Using jmeter-to-k6 on the full.jmx example from
https://github.com/grafana/jmeter-to-k6/blob/master/example/full.jmx
will yield "Unhandled promise rejection." error.

To Reproduce
Steps to reproduce the behavior:

  1. jmeter-to-k6 -o k6 full.jmx

Expected behavior

JMeter to k6 JS converted successful.

See the below Logs for details.

Environment

Logs
$ jmeter-to-k6 -o k6 full.jmx 
(node:8057) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8057) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

$ jmeter-to-k6 -o k6 full.jmx --unhandled-rejections=strict
(node:8080) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8080) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

$ find k6/
k6/
# should have some files generated
$ node -v; npm -v;
v14.16.1
6.14.12

$ apt-cache policy nodejs
nodejs:
  Installed: 14.16.1-1nodesource1
  Candidate: 14.17.0-1nodesource1
  Version table:
     14.17.0-1nodesource1 500
        500 https://deb.nodesource.com/node_14.x buster/main amd64 Packages
 *** 14.16.1-1nodesource1 100
        100 /var/lib/dpkg/status
     12.21.0~dfsg-4 80
         80 http://deb.debian.org/debian bullseye/main amd64 Packages
     10.24.0~dfsg-1~deb10u1 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        500 http://security.debian.org/debian-security buster/updates/main amd64 Packages

$ uname -rm
4.4.0-19041-Microsoft x86_64

Additional context

N.A.

RandomController index calculation can go out of range

The index calculation at https://github.com/loadimpact/jmeter-to-k6/blob/master/src/element/RandomController.js#L82 can go 1 above the max index. It generates the following code for a random controller with 3 sub-elements, which can generate an index value of 3:

const index = Math.floor(Math.random() * (3 + 1));
switch (index) {
  case 0:
    ...
    break;
  case 1:
    ...
    break;
  case 2:
    ...
    break;
  default:
    throw new Error("Unexpected random index: " + index);
}

Facing Error while converting JMX which has SMTP sampler to send emails

I have JMX script which is needs to be converted into k6 project, but facing below issue

[root@vpc-centos7-bin]# jmeter-to-k6 smtpPROD.jmx -o k6script
(node:30105) UnhandledPromiseRejectionWarning: Error: Unrecognized element: SmtpSampler
    at element (/usr/lib/node_modules/jmeter-to-k6/src/element.js:61:11)
    at module.exports.args (/usr/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports.args (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.hashTree (/usr/lib/node_modules/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/usr/lib/node_modules/jmeter-to-k6/src/element.js:66:36)
    at module.exports.args (/usr/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports.args (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.ThreadGroup (/usr/lib/node_modules/jmeter-to-k6/src/element/ThreadGroup.js:28:19)
(node:30105) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:30105) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[email protected] postinstall - Error: Cannot find module './dict'

Dear All,

Very excited to learn k6. I installed on my windows machine and initiated .jmx conversion to k6 scripts. In the process as defined at https://github.com/loadimpact/jmeter-to-k6, I started the command execution and command stopped after informing this..

> [email protected] postinstall C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6
> node scripts/bundle.js

Vendor built successfully!
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module './dict' from 'C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6\node_modules\jsonpath'
    at C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6\node_modules\browser-resolve\node_modules\resolve\lib\async.js:55:21
    at load (C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6\node_modules\browser-resolve\node_modules\resolve\lib\async.js:69:43)
    at onex (C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6\node_modules\browser-resolve\node_modules\resolve\lib\async.js:92:31)
    at C:\Users\sgarg\AppData\Roaming\npm\node_modules\jmeter-to-k6\node_modules\browser-resolve\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:152:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sgarg\AppData\Roaming\npm-cache\_logs\2019-06-03T07_49_47_573Z-debug.log

Log file and CMD data is attached for your reference.
2019-06-03T07_49_47_573Z-debug.log
CMD_Print.txt

Thanks for your attention, help and directions as early as possible

(node:6304) UnhandledPromiseRejectionWarning: Error: Invalid header entry

I'm trying to convert the file attached, but I'm getting the error below:

C:\WINDOWS\system32>jmeter-to-k6 c:\login.jmx -o full
(node:6304) UnhandledPromiseRejectionWarning: Error: Invalid header entry
    at header (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HeaderManager.js:64:11)
    at headers (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HeaderManager.js:54:5)
    at property (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HeaderManager.js:44:7)
    at Object.HeaderManager (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HeaderManager.js:17:5)
    at extractDefaults (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\common\defaults.js:33:44)
    at element (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:65:22)
    at module.exports (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:3:10)
    at elements (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:20:19)
    at module.exports (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:2:10)
    at Object.hashTree (C:\Users\JOAO SILVA\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\hashTree.js:4:10)
(node:6304) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6304) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Data driven script example please (Unrecognized element: JDBCSampler)

Is your feature request related to a problem? Please describe.

I'm new to k6, and tried to convert my data driven jmeter script to k6, but I'm getting
Unrecognized element: JDBCSampler

$ jmeter-to-k6 -o k6 TestPlan_JDBC_DB_Example.jmx 
(node:8151) UnhandledPromiseRejectionWarning: Error: Unrecognized element: JDBCSampler
    at element (/usr/lib/node_modules/jmeter-to-k6/src/element.js:61:11)
    at module.exports (/usr/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.hashTree (/usr/lib/node_modules/jmeter-to-k6/src/element/hashTree.js:4:10)
    at element (/usr/lib/node_modules/jmeter-to-k6/src/element.js:66:36)
    at module.exports (/usr/lib/node_modules/jmeter-to-k6/src/element.js:3:10)
    at elements (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:20:19)
    at module.exports (/usr/lib/node_modules/jmeter-to-k6/src/elements.js:2:10)
    at Object.SetupThreadGroup (/usr/lib/node_modules/jmeter-to-k6/src/element/SetupThreadGroup.js:26:26)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8151) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The TestPlan_JDBC_DB_Example.jmx is available here.

Describe the solution you'd like

data driven jmeter scripts can be converted to k6.

Describe alternatives you've considered

Provide data driven k6 scripts as official k6 examples.

Dynamically create a lib.js bundle if external browserified node libraries are required

To make the experience smoother when installing this tool from NPM (not yet published as of Feb 7th 2018) we should improve how browserified node libraries are used.

Today one needs to run ./bundle, after cloning the repo and installing the node dependencies, to download and browserify the necessary node libs to bridge the gap between feature sets in JMeter and k6. The generated k6 JS code then refers to these browserified libraries via import libName from "./build/libName.js".

I propose we instead bundle browserified versions of the possible dependant node libraries and then use browserify or webpack as part of the conversion process to create a jmeter-compat.js file that we output to the CWD where the jmeter-to-k6 <input> > <output> is run.

The lib.js file would then be used like this: import { papaparse, jsonpath } from "./jmeter-compat.js"

I propose we also add a -o filename flag to the CLI to support specifying where the generated JS script should be saved, and thus also the jmeter-compat.js file.

UnhandledPromiseRejectionWarning: Error: Unrecognized element: kg.apc.jmeter.threads.UltimateThreadGroup

I get the following error when I try to convert a jmx file to k6.

(node:23544) UnhandledPromiseRejectionWarning: Error: Unrecognized element: kg.apc.jmeter.threads.UltimateThreadGroup
    at element (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:50:27)
    at module.exports.args (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:1:102)
    at elements (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:17:43)
    at module.exports.args (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:1:102)
    at Object.hashTree (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\hashTree.js:4:10)
    at element (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:53:36)
    at module.exports.args (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:1:102)
    at elements (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:17:43)
    at module.exports.args (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:1:102)
    at Object.TestPlan (C:\Users\SFernando\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\TestPlan.js:14:17)
(node:23544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm using Jmeter version 5.1.1 and k6 version v0.25.0

UnhandledPromiseRejectionWarning: Error: Unrecognized HTTPSamplerProxy property: monitor

im getting this error while converting jmx to k6

C:\WINDOWS\system32>jmeter-to-k6 C:\Users\Vishnu's\OneDrive\Desktop\Workup\goenterquiz\SkyQuiz.jmx -o skyquizz
(node:9728) UnhandledPromiseRejectionWarning: Error: Unrecognized HTTPSamplerProxy property: monitor
    at property (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HTTPSamplerProxy.js:292:13)
    at Object.HTTPSamplerProxy (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\HTTPSamplerProxy.js:27:5)
    at element (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:66:36)
    at module.exports (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:3:10)
    at elements (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:20:19)
    at module.exports (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:2:10)
    at Object.hashTree (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element\hashTree.js:4:10)
    at element (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:66:36)
    at module.exports (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\element.js:3:10)
    at elements (C:\Users\Vishnu's\AppData\Roaming\npm\node_modules\jmeter-to-k6\src\elements.js:20:19)
(node:9728) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9728) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.