-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add variable support for Include Controller #679
base: master
Are you sure you want to change the base?
Conversation
============== - Add variable support for includePath - Add tests for getIncludePathAsFunction()
/** | ||
* return the JMX file path with function support. | ||
* @return the JMX file path with function support | ||
*/ | ||
public String getIncludePathAsFunction() | ||
{ | ||
String jmxfile = this.getPropertyAsString(INCLUDE_PATH); | ||
CompoundVariable masterFunction = new CompoundVariable(); | ||
try{ | ||
log.debug("Trying to evaluate 'Include Path' as an expression: {}", jmxfile); | ||
masterFunction.setParameters(jmxfile); | ||
if(masterFunction.hasFunction()) { | ||
String jmxfileCompile = masterFunction.getFunction().execute(); | ||
log.debug("The value of 'Include Path' is computed as: {}", jmxfileCompile); | ||
return jmxfileCompile; | ||
} | ||
} catch (InvalidVariableException e) | ||
{ | ||
log.warn("Invalid variable in 'Include Path' {}. See log for details", jmxfile); | ||
log.warn("Invalid variable in 'Include Path':", e); | ||
} | ||
|
||
log.debug("The value of 'Include Path' is simple string: {}", jmxfile); | ||
return jmxfile; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong approach to attack the problem. It looks like includePath.setRunningVersion(true)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if apply includePath.setRunningVersion(true)
and set includePath like ${__P(somePropName, 'defaultValue')}
and open JMX File in GUI Mode
then includePath view like value of somePropName
or 'defaultValue'
, but not view as ${__P(somePropName, 'defaultValue')}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function getIncludePathAsFunction()
did not change value of includePath
. Function getIncludePathAsFunction()
used instead of simple this.getPropertyAsString(INCLUDE_PATH)
for variables and functions support without change of value includePath
.
Script developer may open JMX file in GUI mode, press Save button, and JMX file was saved without changes.
If used includePath.setRunningVersion(true)
, then after open JMX script in GUI mode and press Save button - original expression will be replaced with expression value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK setRunningVersions(tue)
should be called just before script execution (like it is called for other elements)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I try tested this
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #679 +/- ##
=========================================
Coverage 55.57% 55.58%
- Complexity 10333 10335 +2
=========================================
Files 1059 1059
Lines 65055 65065 +10
Branches 7403 7400 -3
=========================================
+ Hits 36156 36167 +11
Misses 26349 26349
+ Partials 2550 2549 -1
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Hi, I see this PR is still open. It is from 2021. Is there any reason this didn't make it into master? |
@ClemRz , could you please clarify your use case in more detail? |
@vlsi |
Have these changes been integrated into version 5.6.3? I'm also interested in the possibility of testing 2 different authentication modes. Indeed, JMeter scripts must be used in 2 environments with different authentication modes (migration in progress). At present, I have to duplicate all the scripts to be able to run tests on these 2 environments. With this possibility, we could declare the JMeter authentication module to be used in the script launch parameters. |
+1 for this feature to be implemented, notice Azure Load test doesn't support yet using test fragments, see microsoft/azure-load-testing#77, by this implementation it maybe possible to refer to JMX files directly in Azure using variables. Thanks, Ger |
Description
The IncludePath field has added support for variables.
Motivation and Context
I want to use files in Include Controller whose names are set in variables.
For Example 1.
I want to run the test with loading static resources and without loading static resources.
Static resources - 200 links.
If I use If Controller, then an optional block with static resources will be in the script, it will take up memory.
If I use Include Controller with variable support, then optional block with 200 links may be change for block with 0 links. A block with 0 links will not take up memory.
For Example 2.
I work in a large team. We decided to change the Access Token update block in all scenarios. From the test_fragment_refresh_Access Token_v1.jms option to test_fragment_refresh_Access Token_v2.jmx. 10 scripts.
Instead of 10 changes in the scripts. The function ${__property(text_fragment_refresh_access Token)} or ${__P(text_fragment_refresh_access Token)} will be used. And there will be one change in user.property.
How Has This Been Tested?
I write some tests.
And test via gradle runGui.
For troubleshooting: add debug loggings.
Screenshots (if appropriate):
Fail load:
Ok load, debug logging:
Types of changes
Checklist: