Solution for plugins #86
Replies: 5 comments 13 replies
-
Hi, this is one of the next items which I'm going to do but to be honest the plugins are already supported. The mechanism is working and it is used unit tests. The way it is done right now is only used there and was created for that purpose only so it is kind of secret feature :). Nevertheless, you can create the plugin if you follow what is done in the tests:
class LogSampler extends AbstractSampler {
SampleResult sample(Entry e) {
SampleResult res = new SampleResult()
res.sampleLabel = name // element name property
res.sampleStart()
res.dataType = SampleResult.TEXT
res.samplerData = comment // element comment property
res.setResponseOK()
res.sampleEnd()
return res
}
} The you need the LogSamplerFactory to glue the plugin with groovy-jmeter final class LogSamplerFactory extends TestElementNodeFactory {
// Log Sampler name, the default one
LogSamplerFactory(String testElementName) {
super(testElementName, LogSampler, TestBeanGUI, true, keyword('log', KeywordCategory.SAMPLER))
}
} In your script you use it in the following way: start(plugins: [new LogSamplerFactory('Log Sampler)]) {
plan {
group {
log(name: 'custom name', comments: 'custom comments')
}
}
} Both name and comments will be initialized on the SampleResult. So it can be done right now but there so cavities:
The alternative insert-raw. This actually is already in place I think with include keyword. So, the include just includes JMX file to your script. strart {
plan {
include '/path/to/my.jmx'
}
} So any valid jmx can be included and it should work. The only thing you need to remember is to add plugin jars to the classpath. Depending how you write your script you can do it with Grab or in gradle. |
Beta Was this translation helpful? Give feedback.
-
I tried this include alternative as per your suggestion and find it is not what I was asking for. So, let me explain with an concrete example, using the same code from #57 (comment) The
part within <hashTree>
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="c_lt_users" elementType="Argument">
<stringProp name="Argument.name">c_lt_users</stringProp>
<stringProp name="Argument.value">${__P(c_lt_users, 10)}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<stringProp name="Argument.desc">loadtest users</stringProp>
</elementProp>
<elementProp name="c_lt_ramp" elementType="Argument">
<stringProp name="Argument.name">c_lt_ramp</stringProp>
<stringProp name="Argument.value">${__P(c_lt_ramp, 5)}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<stringProp name="Argument.desc">loadtest ramp up in seconds</stringProp>
</elementProp>
</collectionProp>
</Arguments>
<hashTree/>
By above I meant that I'm able to construct the above xml block myself from raw xml pieces. I.e., the following will give me the exact same code as above:
If the $ head example-inc.v?.jmx
==> example-inc.v1.jmx <==
<elementProp name="c_lt_users" elementType="Argument">
<stringProp name="Argument.name">c_lt_users</stringProp>
<stringProp name="Argument.value">${__P(c_lt_users, 10)}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<stringProp name="Argument.desc">loadtest users</stringProp>
</elementProp>
==> example-inc.v2.jmx <==
<elementProp name="c_lt_ramp" elementType="Argument">
<stringProp name="Argument.name">c_lt_ramp</stringProp>
<stringProp name="Argument.value">${__P(c_lt_ramp, 5)}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<stringProp name="Argument.desc">loadtest ramp up in seconds</stringProp>
</elementProp> However, the
Will give a completely different xml: <hashTree>
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</Arguments>
<hashTree>
<IncludeController guiclass="IncludeControllerGui" testclass="IncludeController" testname="example-inc.v1.jmx" enabled="true">
<stringProp name="IncludeController.includepath">example-inc.v1.jmx</stringProp>
</IncludeController>
<hashTree/>
<IncludeController guiclass="IncludeControllerGui" testclass="IncludeController" testname="example-inc.v2.jmx" enabled="true">
<stringProp name="IncludeController.includepath">example-inc.v2.jmx</stringProp>
</IncludeController>
<hashTree/>
</hashTree> |
Beta Was this translation helpful? Give feedback.
-
Hmm... that'll work for controllers but not plugins right? I currently need to add plugins, like the datadog plugin in OP. |
Beta Was this translation helpful? Give feedback.
-
I took a look at #104 which has plugin support before raising #112, because I was trying to follow it and solve the problem myself, but found that the learning curve is way too steep for me, as I'm not a Java programmer, let alone a Groovy DSL programmer. So I want to bring attention back to this proposal again:
With it, the solution would be super simple, even to a none Java programmer, as he only need to put the missing code block from jmx in, something like
And that's it! No need to learn Java programming; no need to learn Groovy DSL programming, and no need to bother you the author for every single exotic plugin on earth. It's less ideal, and not elegant at all, but because of no need to wait for the next version with perfect fix, everyone would be happy... |
Beta Was this translation helpful? Give feedback.
-
Oh, no wonder. |
Beta Was this translation helpful? Give feedback.
-
Collecting general ideas for proper solutions for plugins.
plugins are challenging as there are so many out there and it is nearly impossible to support every one of them. For e.g., I need to used this one:
https://docs.datadoghq.com/integrations/jmeter
which nobody else might be using, including the author.
So we need a generic way for people to use plugins on their own.
One idea come to my mind is that, since groovy-jmeter supports including jmeter fragments directly. Can we use such mechanism to use plugins on our own? A working example appreciated. thx.
Update:
The above is Datadog Backend Listener plugin, which will represent one single block of xml in the jmeter file, which should be doable.
Now the real challenge is, I want to use this as well:
https://jmeter-plugins.org/wiki/InterThreadCommunication/
It can be applicable to every request. So maybe, instead of groovy-jmeter doing the translation for every single plugins, would something like
insert-raw
that insert raw jmeter xml code block be a generic way / solutioin?If so, it can be the solution for #73 as well, as I need the insert mechanism be granular enough so as to be able to add different jmeter code block (from different files) all into a single variable definition.
With that (
insert-raw
or anything alike), the workflow would beinsert-raw
to groovy-jmeter script at where the new codes should be addedSome parameters might need to be passed to the
insert-raw
, but it should be doable.Beta Was this translation helpful? Give feedback.
All reactions