Created
January 25, 2019 14:47
-
-
Save robingustafsson/7eae7a30a438f074de8a1c36cdbaa99b to your computer and use it in GitHub Desktop.
JMeter-to-k6 PR review: Random Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> | |
<RandomController guiclass="RandomControlGui" testclass="RandomController" testname="Random Controller" enabled="true"> | |
<intProp name="InterleaveControl.style">1</intProp> | |
</RandomController> | |
<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"></stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path">/1</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/> | |
<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"></stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path">/2</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/> | |
</hashTree> | |
</hashTree> | |
</hashTree> | |
</hashTree> | |
</jmeterTestPlan> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from "k6/http" | |
const vus = 1 | |
let url, opts, auth, r, regex, match, matches, extract, output | |
let csvPage = {}, csvColumns = {} | |
const constants = {} | |
const vars = {} | |
const files = {} | |
export let options = { | |
stages: [{"target":1,"duration":"1s"}] | |
} | |
export default function (data) { | |
if (__VU >= 1 && __VU <= 1) { | |
{ const index = Math.floor(Math.random()*(1+1)); switch (index) { | |
case 0: | |
url = `${`http`}://${`test.loadimpact.com`}${`/1`}` | |
opts = { | |
redirects: 999 | |
} | |
r = http.request(`GET`, url, '', opts) | |
url = `${`http`}://${`test.loadimpact.com`}${`/2`}` | |
opts = { | |
redirects: 999 | |
} | |
r = http.request(`GET`, url, '', opts) | |
break | |
default: throw new Error('Unexpected random index: ' + index) | |
} } | |
} else throw new Error('Unexpected VU: ' + __VU) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment