You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by bu...@apache.org on 2009/07/12 05:24:08 UTC

DO NOT REPLY [Bug 47511] New: Jython Sampler Broken

https://issues.apache.org/bugzilla/show_bug.cgi?id=47511

           Summary: Jython Sampler Broken
           Product: JMeter
           Version: 2.3.3
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P1
         Component: Main
        AssignedTo: jmeter-dev@jakarta.apache.org
        ReportedBy: willmcqueen@yahoo.com


JMeter's BSF Sampler is broken when used with Jython.

Steps:
1) Drop the att'd "jython-standalone-2.5.0.jar" file into JMeter's lib dir (or
create one yourself from www.jython.org).
2) Create a new JMeter test plan
3) Add a ThreadGroup
4) Add a BSF Sampler under that ThreadGroup. In the Sampler, choose "Scripting
language: jython". Then in the large text box at the bottom (under "Script to
run"), type:
     print 7
5) Add a View Results Tree listener to the ThreadGroup
6) Run the test plan
7) In the View Results Tree, go to the <Sampler result> tab. Notice the error:
   Sample Count: 1
   Error Count: 1
   Response code: 500
   Response message: org.apache.bsf.BSFException: exception from Jython:
   SyntaxError: ("no viable alternative at input 'print'", ('<string>', 1, 0,
'print 7\n'))
7) Now also add a BSF PreProcessor (to the same ThreadGroup) with "Language:
jython" and the big text box filled with:
     print 8
8) Run the test plan. Notice that although the BSF Sampler failed, running
Jython in the BSF PreProcessor works fine. You'll see "8" printed in stdout.

Versions:
1) JMeter version = 2.3.4 (BugZilla dropdown menu doesn't have option for
2.3.4, so  I had to choose 2.3.3)
2) Jython version = 2.5 (standalone jar)

Please help! :-)

Cheers,
Will

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511


Sebb <se...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #7 from Sebb <se...@apache.org> 2009-08-13 14:49:48 PDT ---
I don't think it's worth adding a work-round to JMeter.
The problem needs to be fixed in Jython.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #5 from Sebb <se...@apache.org>  2009-07-30 01:49:24 PST ---
(In reply to comment #4)
> (In reply to comment #2)
> > I think there are two problems here:
> > 
> > 1) BSF 2.4.0 was coded against Jython 2.1. It seems that some later releases
> > are not compatible.
> 
> Do you plan to support Jython 2.5 (as well as include the latest version of
> BSF) in the next minor release of JMeter? 

Yes, will move to BSF 3.0 for the next release.

BSF 3.0/JSR-223 does not distinguish scripts and expressions; everything is an
expression returning an Object (might be null).

> Or perhaps sooner in some new nightly
> build (based on the priority of other bugs as well, of course)?

That will happen when the code has been added to SVN.

> > 2) Ambiguity over what constitutes an "eval" script in BSF.
> > 
> > If you use Jython 2.1, the sampler will work provided that the script is a
> > Jython expression, such as "5" or "6+7".
> 
> If I create a BSF sampler that's set to use Jython, then being restricted to
> only use a single JPython expression (as opposed to multiple JPython
> statements) is severely limiting. On the surface, it seems that a fix to JMeter
> to enable complete integration with Jython would be low-hanging fruit and
> provide a lot of bang-for-the-buck, bringing the complete richness of Jython to
> JMeter samplers. I'm not familiar with JMeter's code, so I could be totally
> off-base here on how much work is involved to fully support a "true" Jython
> script containing any number of statements (as can be done with a BeanShell
> sampler) rather than just supporting a single Python expression.

The problem is in BSF 2.4/Jython, not JMeter.
Having said that, there is code in JMeter to work-round a similar problem with
BSF 2.4/Jexl.

> I have a thought... So if instead of using a BeanShell Sampler I were to use a
> BSF Sampler that's set to BeanShell, then would I have the same limitation? 

No.

> ie,
> Would this sampler be restricted to a single BeanShell expression instead of
> being able to use multiple BeanShell statements? If that's the case, then maybe
> what's needed is to create a separate JythonSampler (in addition to the
> BeanShellSampler and BSFSampler). 

No.

> Given that "The Grinder 3" load testing tool
> uses Jython, I think that having a new JythonSampler sampler in JMeter would
> make it easier to migrate Jython scripts between the JMeter and The Grinder,
> esp when the dev group uses The Grinder but the QA group uses JMeter.
> 
> Thoughts?
> 
> Cheers,
> Will

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #2 from Sebb <se...@apache.org>  2009-07-27 10:17:26 PST ---
I think there are two problems here:

1) BSF 2.4.0 was coded against Jython 2.1. It seems that some later releases
are not compatible.

2) Ambiguity over what constitutes an "eval" script in BSF.

If you use Jython 2.1, the sampler will work provided that the script is a
Jython expression, such as "5" or "6+7".

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #3 from Sebb <se...@apache.org>  2009-07-27 10:21:51 PST ---
Note: If you want to test using BSF and Jython (outside JMeter) you can use a
command-line of the form:


java -cp bsf-2.4.0.jar;commons-logging-1.1.1.jar;jython.jar org.apache.bsf.Main
-lang jython -mode <mode>  [-in fileName] default: <STDIN>

where mode =
exec - corresponds to what JMeter BSF Pre/Post-Processors do
eval - corresponds to what the JMeter BSF sampler does

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #6 from Sebb <se...@apache.org>  2009-07-31 13:38:10 PST ---
I think the problem is actually with Jython - as far as I can tell, it does not
allow a script to return a value.

One can either call eval(), and provide a single expression, or call exec() and
provide one or more statements; however exec() does not return a value.

The only reference I could find to JSR-223 and Jython is the following:

http://www.jython.org/archive/22/userguide.html#using-jsr-223

which clearly shows that each eval() call is a single statement.

Looks like the only work-round at present would be to write an engine that
reads the script line by line and calls eval() for each one. Or one could
process all but the last line using exec() and then use eval() for the last
line. This would require a lot of storage if the script is long, and both
solutions only work if each statement is on a separate line.

Rather messy.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #4 from Will McQueen <wi...@yahoo.com>  2009-07-29 16:50:54 PST ---
(In reply to comment #2)
> I think there are two problems here:
> 
> 1) BSF 2.4.0 was coded against Jython 2.1. It seems that some later releases
> are not compatible.

Do you plan to support Jython 2.5 (as well as include the latest version of
BSF) in the next minor release of JMeter? Or perhaps sooner in some new nightly
build (based on the priority of other bugs as well, of course)?

> 2) Ambiguity over what constitutes an "eval" script in BSF.
> 
> If you use Jython 2.1, the sampler will work provided that the script is a
> Jython expression, such as "5" or "6+7".

If I create a BSF sampler that's set to use Jython, then being restricted to
only use a single JPython expression (as opposed to multiple JPython
statements) is severely limiting. On the surface, it seems that a fix to JMeter
to enable complete integration with Jython would be low-hanging fruit and
provide a lot of bang-for-the-buck, bringing the complete richness of Jython to
JMeter samplers. I'm not familiar with JMeter's code, so I could be totally
off-base here on how much work is involved to fully support a "true" Jython
script containing any number of statements (as can be done with a BeanShell
sampler) rather than just supporting a single Python expression.

I have a thought... So if instead of using a BeanShell Sampler I were to use a
BSF Sampler that's set to BeanShell, then would I have the same limitation? ie,
Would this sampler be restricted to a single BeanShell expression instead of
being able to use multiple BeanShell statements? If that's the case, then maybe
what's needed is to create a separate JythonSampler (in addition to the
BeanShellSampler and BSFSampler). Given that "The Grinder 3" load testing tool
uses Jython, I think that having a new JythonSampler sampler in JMeter would
make it easier to migrate Jython scripts between the JMeter and The Grinder,
esp when the dev group uses The Grinder but the QA group uses JMeter.

Thoughts?

Cheers,
Will

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 47511] Jython Sampler Broken

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47511





--- Comment #1 from Will McQueen <wi...@yahoo.com>  2009-07-11 20:28:40 PST ---
Created an attachment (id=23960)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23960)
Reproduces the Jython Sampler Failure. You'll need to drop a standalone Jython
2.5 jar into JMeter's lib dir.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org