jmeter icon indicating copy to clipboard operation
jmeter copied to clipboard

feat: allow expressions for TestElement.enabled property

Open vlsi opened this issue 5 months ago • 0 comments

Description

This is a proof-of-concept implementation for conditional TestElement.enabled. The downside is that isEnabled() call would be added for every sampler, listener, pre-processor, pos-processor, and so on which might slow down the execution.

Motivation and Context

See https://github.com/apache/jmeter/issues/6006

How Has This Been Tested?

See EnabledWithVariablesTest

Screenshots (if appropriate):

WIP: debug sampler with expression in enable property

<hashTree>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="false">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
  <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="${__javaScript(false)}">
    <boolProp name="displayJMeterProperties">false</boolProp>
    <boolProp name="displayJMeterVariables">true</boolProp>
    <boolProp name="displaySystemProperties">false</boolProp>
  </DebugSampler>
  <hashTree/>
</hashTree>

Checklist:

  • [ ] UI: select the location and the control style
  • [x] UI: implement saving the plan to jmx
  • [ ] UI: implement loading the plan from jmx
  • [ ] Verify if TestBean-based components work as well
  • [ ] Support ..RequestDefaults. The logic of merge...Element probably needs ignoring disabled elements
  • [ ] Decide if interface JMeterGUIComponent needs to support expressions. Currently there's boolean getEnabled() and setEnabled(boolean)
  • [ ] Add documentation
  • [ ] Analyze if the following is still needed: https://github.com/apache/jmeter/blob/91ed1279438cbc2553121c8ea1afded0605b38e5/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeModel.java#L169-L175

vlsi avatar Jul 22 '25 14:07 vlsi