-
Notifications
You must be signed in to change notification settings - Fork 21
Create this tool [bounty: $2200] #1
Comments
This is really well specified.
There's a simple example. It produces a script with scaffolding. Empty logic at the moment. node bin/jmeter-to-k6 example/minimal.xml <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
<hashTree>
<TestPlan testname="Search page test">
<ThreadGroup>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">2</stringProp>
</ThreadGroup>
</TestPlan>
</hashTree>
</jmeterTestPlan> // Search page test
export let options = {
stages: [{"target":1,"duration":"2s"}]
}
export default function (data) {
switch (__VU) {
case 1:
break
default: throw new Error('Unexpected VU: ' + __VU)
}
} |
This seems to be more than $1,000 of work. Would the team consider an increased bounty? |
Added handling of defaults from There's also a .. TestPlanAttribute
Property
.. |
@bookmoons Sorry for the late reply. You seems to have a good structure of the project going, nice 👏! Thanks also for the updates, that's great! Yes, the bounty could possibly be increased. We've increased bounties in the passed. That said, it's been a judgement on the quality of the solution and time put into it. Is there any specific part of the specification above that you think will be more time consuming? Also, there's a channel in k6 slack (#jmeter-to-k6) where there's been some more discussion on this project/specification with another person that has started an implementation. |
Thanks @robingustafsson. Going to do a few more elements and come up with something to propose. The latest has these elements converting: |
OK, I have a couple of the logic controllers converting. The main time is in dealing with the XML. Finding the structure, determining how values are encoded. Based on time so far $2,200 would make it possible for me. Will set that as a target on Bountysource. Thank you for considering. There's a larger example with some control structures in // Search page test
const constants = {}
const vars = {}
vars["INIT"] = "1" /* Run initialization */
vars["CONTINUE"] = "true"
vars["CHECK"] = "true"
export let options = {
[{"target":1,"duration":"2s"}]
}
export function setup () {
/* Open resources */
}
export default function (data) {
if (__VU >= 1 && __VU <= 1) {
if (eval(`${vars["INIT"]} > 0`)) {
// There's currently no XPath API in k6 so a pure JS solution has to be used.
// Try https://github.com/google/wicked-good-xpath.
}
while (`${vars["CONTINUE"]}` !== "false") {
if (eval(`${vars["CHECK"]}`)) {
// There's currently no XPath API in k6 so a pure JS solution has to be used.
// Try https://github.com/google/wicked-good-xpath.
}
}
} else throw new Error('Unexpected VU: ' + __VU)
}
export function teardown (data) {
/* Close resources */
} |
@bookmoons Great! We've talked internally regarding the bounty $ amount and as I said we're happy to consider raising bounties if we feel it's warranted. In this case we think it is, but I'd like to ask you what you think we'd have to cut to get it down to $1800? |
Thanks guys. OK, these categories are done:
These pieces are pending:
The processors seem like a good chunk of work. I think if they were dropped it would work. Or alternatively the remaining controllers, they're simpler but there are more of them. The |
@bookmoons Thanks for that, we've decided to go ahead with the full bounty for $2,200. So, please continue the great work you've done so far! 😃 |
Understood, thank you. Continuing on. |
I've been poking around with I'm not sure if there's a way to duplicate this in k6. Is there any way to achieve cross-VU communication? |
No, unfortunately there's no way to share data between VUs at the moment. I suggest you just convert the // See https://support.loadimpact.com/4.0/test-scripting/examples/#reading-parameterization-data-from-a-csv-file
import papaparse from "./papaparse.js";
// NOTE: In JMeter all Virtual Users (aka Threads) can read from the same CSVDataSet.
// In k6 there's no data sharing between VUs. Instead you can use the __VU global variable
// to help partition the data (if running in the Load Impact cloud you'll also have to
// use LI_INSTANCE_ID).
const csvData = papaparse.parse(open('/path/to/data.csv'), {header: true}); // "header" will depend on the CSVDataSet.ignoreFirstLine setting
export default function() {
// Use the CSV data in whatever way necessary
let randomUser = csvData.data[Math.floor(Math.random() * csvData.data.length)];
} |
Copy that. |
Have submitted a functional tool. All elements on the list are converting.
node bin/jmeter-to-k6.js example/full.xml Some logic looks convoluted, with a lot of template literals. Those pieces are handling runtime evaluation of JMeter variables, which is supposed to be available in nearly all fields. |
I see the |
Switched it to |
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
stages
option in k6 JS. Each step should be a{ target: X, duration: Y }
entry.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 onestages
option (potentially with several{ target: X, duration: Y }
entries) and the correct distribution of VUs should be handled in theexport default function
using__VU
and if/else JS statements.export function setup()
in k6 JS.export function teardown()
in k6 JS.Managers
hosts
option in k6 JS.http.get/post/put/patch/del/options/batch/request
call in k6 JS.auth
request parameter option forbasic
,digest
andntlm
in k6 JS (setting the username and password in the URL itself).Assertions (should be converted to k6 checks)
check()
entry looking atres.timings.duration
.check()
entry looking atres.body
andres.headers
.Logic controllers
Array.forEach(function(...) { ... });
statement).switch (__ITER % NUM_OF_SUB_CONTOLLERS) { case 1: ... case 2: ... etc. }
to alternative between the child controllers.for
loop in k6 JS.if (__ITER === 1) { ... }
in k6 JS. If in a looping container it should also be restricted to only run on the first iteration.const TEST_START_TIME = Date().now();
, and then in the script an if check likeif (RUNTIME_CONTROLLER_SECS * 1000 > Date.now() - TEST_START_TIME) { ...execute child controllers... }
.group("TRANSACTION_CONTROLLER_NAME", function() { ... })
call in k6 JS. The group duration will be the same as the equivalent generated transaction sample in JMeter.group("SIMPLE_CONTROLLER_NAME", function() { ... })
call in k6 JS.let rndIndex = Math.floor(Math.random() * (NUM_OF_SUB_CONTOLLERS + 1))
.Timers
sleep(...)
call in k6 JS.Data
Post-processors
HTTPResponse.json(selector)
)fail()
API to stop the test, something like:if (res.status < 299 and res.status < 400) { fail(); }
For the following tags it’s enough to dump the code contents as a comment into the JS output:
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
The text was updated successfully, but these errors were encountered: