Bug 62700

Summary: Introduce groovy.init.file to allow calling a groovy script on JMeter startup
Product: JMeter Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement CC: p.mouawad
Priority: P2    
Version: 4.0   
Target Milestone: JMETER_5.0   
Hardware: All   
OS: All   
Attachments: Make init file more generic
Make init file more generic

Description Philippe Mouawad 2018-09-09 12:50:32 UTC
This feature is available currently as Beanshell :

- beanshell.init.file

It has been requested through:

- http://mail-archives.apache.org/mod_mbox/jmeter-dev/201808.mbox/%3CCAH9qxHacKG_Mf-HG%3DcvOnPZ-VY4e2k32HEfP12cWNGbbxEkCqg%40mail.gmail.com%3E
Comment 1 Philippe Mouawad 2018-09-09 13:09:45 UTC
Author: pmouawad
Date: Sun Sep  9 13:09:21 2018
New Revision: 1840406

URL: http://svn.apache.org/viewvc?rev=1840406&view=rev
Log:
Bug 62700 - Introduce groovy.init.file to allow calling a groovy script on JMeter startup
Bugzilla Id: 62700

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml
Comment 2 Felix Schumacher 2018-09-09 13:47:33 UTC
Created attachment 36141 [details]
Make init file more generic

Try to find the correct script engine by looking at the extension of the init file (change the property name to jsr223.init.file at the same time)
Comment 3 UbikLoadPack support 2018-09-09 13:53:13 UTC
(In reply to Felix Schumacher from comment #2)
> Created attachment 36141 [details]
> Make init file more generic
> 
> Try to find the correct script engine by looking at the extension of the
> init file (change the property name to jsr223.init.file at the same time)

Thanks for patch.

What do you think of defaulting to Groovy if engine is not found and logging a warn message saying "We'll interpret your file as groovy ..."
Comment 4 Felix Schumacher 2018-09-09 14:02:05 UTC
(In reply to UbikLoadPack support from comment #3)
> (In reply to Felix Schumacher from comment #2)
> > Created attachment 36141 [details]
> > Make init file more generic
> > 
> > Try to find the correct script engine by looking at the extension of the
> > init file (change the property name to jsr223.init.file at the same time)
> 
> Thanks for patch.
> 
> What do you think of defaulting to Groovy if engine is not found and logging
> a warn message saying "We'll interpret your file as groovy ..."

As groovy interprets quite a lot of java, groovy (and probably a bit of javascript) and it is our favourite scripting language, that might be a good idea.
Comment 5 Felix Schumacher 2018-09-09 14:16:32 UTC
Created attachment 36142 [details]
Make init file more generic

Use Philippe's remark to make the init file setup more robust.
Comment 6 Felix Schumacher 2018-09-13 18:37:42 UTC
Date: Thu Sep 13 18:36:46 2018
New Revision: 1840847

URL: http://svn.apache.org/viewvc?rev=1840847&view=rev
Log:
Allow full JSR-223 for init scripts in JMeter startup

Use jsr223.init.file to allow calling a JSR-223 script on JMeter startup
instead of the envisioned groovy.init.file property.

The engine to use for the init script will be determined by the extension
of the filename. If the filename has no extension or if no engine
can be found for that extension, Groovy will be tried.

Bugzilla Id: 62700

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml