jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: svn commit: r1840406 - in /jmeter/trunk: bin/jmeter.properties src/core/org/apache/jmeter/JMeter.java xdocs/changes.xml xdocs/usermanual/properties_reference.xml
Date Sun, 09 Sep 2018 14:00:18 GMT
Am Sonntag, den 09.09.2018, 15:51 +0200 schrieb Philippe Mouawad:
> Hello Felix, Sebb,
> 
> The idea for my commit, was that:
> - It was proposed by a user
> - I personally had to use it on a project, and it was weird to see I
> had to
> use Beanshell to do that
> - Since we advise to replace Beanshell by Groovy, we should have all
> existing Beanshell features available as Groovy

+1

> 
> Now regarding your remarks, I agree with you Felix that it would be
> nice.
> But no firm position for me but:
> - The risk I see with extension is that if file is misnamed , what
> shall we
> do ?

Present a nice message explaining that no scripting engine could be
found by that name.

> - Sometimes we tend to be too open , making the software very
> customizable
> , but more complex. This tend to complexify Learning curve and I have
> seen
> this while giving trainings

That is definitely a point, but on the other hand side you force the
user to learn groovy, while she wants to use jython or something
different.

> - IMO, since we advise using Groovy for scripting, it would be
> logical that
> we use it as a default. And since Javascript has bad performances, we
> should avoid users using it, as such not provide opportunity to use
> it
> (never, ever :-) )

The bad performance of JavaScript is only true, if it is in highly
concurrent situation (or gets really worse when going into concurrent
situations). That is probably not true for startup and I don't believe
that init scripts will be big, but then, I have never used one.

> 
> But since I have no objection and might be wrong with my ideas, we
> can
> introduce another property (but it would be one more among tens).
> Note that Milamber was ready to start a release this sunday, so I
> don't
> know if you are ready to provide a commit for it before he builds the
> release

If the release is planned for today, is it advisable to add a feature
in the last moment? Those tend to make trouble.

Regards,
 Felix

> 
> Regards
> 
> On Sun, Sep 9, 2018 at 3:19 PM Felix Schumacher <
> felix.schumacher@internetallee.de> wrote:
> 
> > While I like groovy, it might be that other users have other JSR223
> > languages as their favourites.
> > 
> > Should we make the init script mechanism a little bit more flexible
> > by
> > using the files ending to determine the language/engine? That way a
> > user
> > could setup a jsr223.init.file=my_suberb_init.js and JMeter would
> > try to
> > get a JSR 223 engine for "js", or jsr223.init.file=some_python.py
> > to run
> > it with an engine for "py".
> > 
> > What do you think?
> > 
> > Felix
> > 
> > 
> > Am 09.09.2018 um 15:09 schrieb pmouawad@apache.org:
> > > 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
> > > 
> > > Modified: jmeter/trunk/bin/jmeter.properties
> > > URL:
> > 
> > http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev
> > =1840406&r1=1840405&r2=1840406&view=diff
> > > 
> > 
> > ===================================================================
> > ===========
> > > --- jmeter/trunk/bin/jmeter.properties (original)
> > > +++ jmeter/trunk/bin/jmeter.properties Sun Sep  9 13:09:21 2018
> > > @@ -919,6 +919,13 @@ beanshell.server.file=../extras/startup.
> > >   # Groovy function
> > > 
> > 
> >  #-----------------------------------------------------------------
> > ----------
> > > 
> > > +# Path to Groovy file containing script to call on JMeter
> > > startup
> > > +# This script can use pre-defined variables:
> > > +# log : Logger to log any message
> > > +# props : JMeter Property
> > > +# OUT : System.OUT
> > > +#groovy.init.file=
> > > +
> > >   #Path to Groovy file containing utility functions to make
> > > available to
> > 
> > __groovy function
> > >   #groovy.utilities=
> > > 
> > > 
> > > Modified: jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
> > > URL:
> > 
> > http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmete
> > r/JMeter.java?rev=1840406&r1=1840405&r2=1840406&view=diff
> > > 
> > 
> > ===================================================================
> > ===========
> > > --- jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
> > > (original)
> > > +++ jmeter/trunk/src/core/org/apache/jmeter/JMeter.java Sun
> > > Sep  9
> > 
> > 13:09:21 2018
> > > @@ -22,6 +22,7 @@ import java.awt.event.ActionEvent;
> > >   import java.io.File;
> > >   import java.io.FileInputStream;
> > >   import java.io.FileNotFoundException;
> > > +import java.io.FileReader;
> > >   import java.io.IOException;
> > >   import java.io.InputStream;
> > >   import java.net.Authenticator;
> > > @@ -44,6 +45,10 @@ import java.util.StringTokenizer;
> > >   import java.util.concurrent.TimeUnit;
> > >   import java.util.concurrent.atomic.AtomicInteger;
> > > 
> > > +import javax.script.Bindings;
> > > +import javax.script.ScriptEngine;
> > > +import javax.script.ScriptEngineManager;
> > > +import javax.script.ScriptException;
> > >   import javax.swing.JTree;
> > >   import javax.swing.UIManager;
> > >   import javax.swing.tree.TreePath;
> > > @@ -634,23 +639,7 @@ public class JMeter implements JMeterPlu
> > >               t.run(); // NOSONAR we just evaluate some code here
> > >           }
> > > 
> > > -        // Should we run a beanshell script on startup?
> > > -        String bshinit =
> > 
> > JMeterUtils.getProperty("beanshell.init.file");// $NON-NLS-1$
> > > -        if (bshinit != null){
> > > -            log.info("Run Beanshell on file: {}", bshinit);
> > > -            try {
> > > -                BeanShellInterpreter bsi = new
> > > BeanShellInterpreter();
> > > -                bsi.source(bshinit);
> > > -            } catch (ClassNotFoundException e) {
> > > -                if (log.isWarnEnabled()) {
> > > -                    log.warn("Could not start Beanshell: {}",
> > 
> > e.getLocalizedMessage());
> > > -                }
> > > -            } catch (JMeterException e) {
> > > -                if (log.isWarnEnabled()) {
> > > -                    log.warn("Could not process Beanshell file:
> > > {}",
> > 
> > e.getLocalizedMessage());
> > > -                }
> > > -            }
> > > -        }
> > > +        runInitScripts();
> > > 
> > >           int
> > 
> > mirrorPort=JMeterUtils.getPropDefault("mirror.server.port", 0);//
> > $NON-NLS-1$
> > >           if (mirrorPort > 0){
> > > @@ -665,6 +654,51 @@ public class JMeter implements JMeterPlu
> > >               }
> > >           }
> > >       }
> > > +
> > > +
> > > +    /**
> > > +     * Runs user configured init scripts
> > > +     */
> > > +    void runInitScripts() {
> > > +        // Should we run a beanshell script on startup?
> > > +        String bshinit =
> > 
> > JMeterUtils.getProperty("beanshell.init.file");// $NON-NLS-1$
> > > +        if (bshinit != null){
> > > +            log.info("Running Beanshell on file: {}", bshinit);
> > > +            try {
> > > +                BeanShellInterpreter bsi = new
> > > BeanShellInterpreter();
> > > +                bsi.source(bshinit);
> > > +            } catch (ClassNotFoundException|JMeterException e) {
> > > +                if (log.isWarnEnabled()) {
> > > +                    log.warn("Could not process Beanshell file:
> > > {}",
> > 
> > e.getMessage());
> > > +                }
> > > +            }
> > > +        }
> > > +
> > > +        // Should we run a Groovy script on startup?
> > > +        String jsr223Init =
> > 
> > JMeterUtils.getProperty("groovy.init.file");// $NON-NLS-1$
> > > +        if (jsr223Init != null){
> > > +            log.info("Running Groovy init script in file: {}",
> > 
> > jsr223Init);
> > > +            File file = new File(jsr223Init);
> > > +            if(file.exists() && file.canRead()) {
> > > +                try (FileReader reader = new FileReader(file)) {
> > > +                    ScriptEngineManager scriptEngineManager =
> > > new
> > 
> > ScriptEngineManager();
> > > +                    ScriptEngine engine =
> > 
> > scriptEngineManager.getEngineByName("Groovy");
> > > +                    Bindings bindings = engine.createBindings();
> > > +                    final Logger logger =
> > 
> > LoggerFactory.getLogger("groovy.init.file");
> > > +                    bindings.put("log", logger); // $NON-NLS-1$
> > > (this
> > 
> > name is fixed)
> > > +                    Properties props =
> > 
> > JMeterUtils.getJMeterProperties();
> > > +                    bindings.put("props", props); // $NON-NLS-1$ 
> > > (this
> > 
> > name is fixed)
> > > +                    // For use in debugging:
> > > +                    bindings.put("OUT", System.out); // NOSONAR
> > 
> > $NON-NLS-1$ (this name is fixed)
> > > +                    engine.eval(reader, bindings);
> > > +                } catch (IOException | ScriptException ex) {
> > > +                    log.error("Error running init script
> > > referenced by
> > 
> > property {}", jsr223Init, ex);
> > > +                }
> > > +            } else {
> > > +                log.error("Script {}Â referenced by property {}Â
> > > is not
> > 
> > readable or does not exists", file.getAbsolutePath(), jsr223Init);
> > > +            }
> > > +        }
> > > +    }
> > > 
> > >       /**
> > >        * Sets a proxy server for the JVM if the command line
> > > arguments
> > 
> > are
> > > 
> > > Modified: jmeter/trunk/xdocs/changes.xml
> > > URL:
> > 
> > http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=184
> > 0406&r1=1840405&r2=1840406&view=diff
> > > 
> > 
> > ===================================================================
> > ===========
> > > --- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
> > > +++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Sep  9 13:09:21
> > > 2018
> > > @@ -160,6 +160,7 @@ this behaviour, set <code>httpclient.res
> > >     <li><bug>62470</bug>CSV Output : Enable logging of sub
> > > results when
> > 
> > <code>jmeter.save.saveservice.subresults=true</code>. Contributed
> > by Ubik
> > Load Pack (support at ubikloadpack.com)</li>
> > >     <li><bug>62473</bug>Setting
> > > "<code>saveservice_properties</code>"
> > 
> > has counter intuitive behaviour</li>
> > >     <li><bug>62354</bug>Correct calculation and usage of
units
> > > for
> > 
> > second per user (reported by jffagot05 at gmail.com)</li>
> > > +  <li><bug>62700</bug>Introduce groovy.init.file to allow
> > > calling a
> > 
> > groovy script on JMeter startup</li>
> > >     <li><bug>62128</bug>Try to guess <code>JMETER_HOME</code>
> > > correctly,
> > 
> > when <code>jmeter.bat</code> is called from a batch file in another
> > directory. Contributed by logox01 (logox01 at gmx.at)</li>
> > >     <li><pr>386</pr>Add parameter support for RMI keystore
> > > creation
> > 
> > scripts. Contributed by Logan Mauzaize (t524467 at
> > airfrance.fr)</li>
> > >     <li><bug>62065</bug>Use Maven artifact for JAF Module
instead
> > > of
> > 
> > embedded module</li>
> > > 
> > > Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
> > > URL:
> > 
> > http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properti
> > es_reference.xml?rev=1840406&r1=1840405&r2=1840406&view=diff
> > > 
> > 
> > ===================================================================
> > ===========
> > > --- jmeter/trunk/xdocs/usermanual/properties_reference.xml
> > > (original)
> > > +++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sun
> > > Sep  9
> > 
> > 13:09:21 2018
> > > @@ -1873,6 +1873,26 @@ JMETER-SERVER</source>
> > >       </property>
> > >   </properties>
> > >   </section>
> > > +
> > > +<section name="&sect-num;.43 Advanced Groovy Scripting
> > > configuration"
> > 
> > anchor="groovy">
> > > +<description>Advanced properties for configuration of scripting
> > > in
> > 
> > Grooyv</description>
> > > +<properties>
> > > +    <property name="groovy.init.file">
> > > +    Path to Groovy file containing script to call on JMeter
> > > startup.
> > 
> > <br/>
> > > +    This script can use pre-defined variables:
> > > +    <ul>
> > > +        <li><code>log</code>: Logger to log any message,
uses
> > > SLF4J
> > 
> > library</li>
> > > +        <li><code>props</code>: JMeter Properties</li>
> > > +        <li><code>OUT</code>: System.OUT, useful to write
in the
> > 
> > console</li>
> > > +    </ul>
> > > +    No script is defined by default.
> > > +    </property>
> > > +    <property name="groovy.utilities">
> > > +    Path to Groovy file containing utility functions to make
> > > available
> > 
> > to __groovy function. <br/>
> > > +    Defaults to <code>bin/utility.groovy</code>
> > > +    </property>
> > > +</properties>
> > > +</section>
> > >   <!--
> > >   <section name="&sect-num;.10 Reports" anchor="Reports">
> > >   <description>
> > > 
> > > 
> > 
> > 
> 
> 

Mime
View raw message