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
Bug59945_DefaultGroovyEngineToJSR223ElementsV2 #223
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,8 @@ public static ScriptEngineManager getInstance() { | |
} | ||
|
||
private static final long serialVersionUID = 233L; | ||
|
||
private static final Logger log = LoggingManager.getLoggerForClass(); | ||
|
||
/** If not empty then script in ScriptText will be compiled and cached */ | ||
private String cacheKey = ""; | ||
|
@@ -86,11 +88,16 @@ public JSR223TestElement() { | |
} | ||
|
||
protected ScriptEngine getScriptEngine() throws ScriptException { | ||
final String lang = getScriptLanguage(); | ||
String lang = getScriptLanguage(); | ||
|
||
if (lang.isEmpty()) { | ||
lang = defaultScriptLanguage; | ||
log.warn("Script language has not been chosen on the UI, the script will be interpreted as a groovy script"); | ||
} | ||
|
||
ScriptEngine scriptEngine = getInstance().getEngineByName(lang); | ||
if (scriptEngine == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scriptEngine will be never null if groovy become the default language. This (if and exception below) must be changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Milamber, I have keep the exception because I am not sure that getInstance().getEngineByName("groovy") will always return something. Antonio |
||
throw new ScriptException("Cannot find engine named: '"+lang+"', ensure you set language field in JSR223 Test Element:"+getName()); | ||
throw new ScriptException("Cannot find engine named: '"+lang+"', ensure you set language field in JSR223 Test Element: "+getName()); | ||
} | ||
|
||
return scriptEngine; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ public abstract class ScriptingTestElement extends AbstractTestElement { | |
private String script = ""; // script (if file not provided) | ||
|
||
protected String scriptLanguage = ""; // BSF/JSR223 language to use | ||
|
||
protected String defaultScriptLanguage = "groovy"; // if no language is chosen in GUI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch |
||
//-- For TestBean implementations only | ||
|
||
public ScriptingTestElement() { | ||
|
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.
Do you really intend to warn on each and every sampler execution?
This looks awfully broken.
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.
Hi Vladimir,
getScriptEngine method is called for each sampler execution and I am OK with your it's not the best solution for performance.
But you can dynamically change the script language during the execution of the script.
It's why I have made this.
If you have a better solution, please let me know
The other solution will be to don't allow to dynamically modify/change the script language during the execution. But I am not sure it's a good solution.
Antonio
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.
JMeter is meant for performance testing. Why do you break the main use case?
warn
message does not enable user to identify which particular sampler is bad, so it will be impossible to fix large JMeter script. That kind of message is useless.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.
My first idea was to put Groovy as default script language in the GUI but this solution have a lot of impact (like all the modifications of a default value with compatibility)
The best solution will be to add a "Check script" button to verify the script and advice users of their mistakes and best practices to apply to their script (if you know how to implement it, please share it)
For the moment if the user forget to define a script language, he needs to check the errors in log (by GUI or in the file) and I think it's not user friendly
Call each time getScriptEngine method is already not a good solution for performance (need to check if the JIT don't inline it) because I am not sure that modify dynamically the script language during the execution of the script is very useful feature used by someone (but if you have a use case, please share it)
If we don't modify the behavior of JMeter (allow to dynamically change the script language), the better solution I have is to print a better message. If you have a better solution, please let me know.