jmeter-to-k6 icon indicating copy to clipboard operation
jmeter-to-k6 copied to clipboard

Error: Undefined variable "X"

Open roma-glushko opened this issue 5 years ago • 3 comments

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

roma-glushko avatar Apr 06 '20 06:04 roma-glushko

@simskij happen to review this one as well? I want to convert performance tests from Magento2 which is one of the top eCommerce platforms out there. That might be useful for LoadImpact as well if Magento2 merchants and agencies are able to use k6 instead of a bit outdated jMeter 😌

roma-glushko avatar Apr 24 '20 07:04 roma-glushko

Terribly sorry for keeping you waiting so long. 😓

simskij avatar Jan 08 '21 15:01 simskij

@sniku you might want to find someone else to review this 👍🏽

simskij avatar Nov 11 '21 13:11 simskij