On 12 October 2011 16:03, Nico Kruger <nico.kru...@gmail.com> wrote: > Hi there > > I have a small sample test file, with one thread group (one thread), > looped a number of times (10 at the moment). with one BSF group, > configured to run a ruby script. > > Everything surrounding the classpath has been configured, jmeter is > finding the jruby JARs, the jruby libraries and my own java code. > > Now as far as I understand, the JMeterVariables object (which seems to > be exposed as $vars in the jruby environment), is shared between > successive samples inside a thread group.
Yes, all samplers in the thread group have access to the same vars - that's how ${variables} work. > I understand that each > thread group runs in its own copy of the interpetrer, but as far as I > understand successive samples within a thread group share an > interpreter of the chosen language. No, the BSF samples currently each use their own BSF Manager and interpreter - it is not currently shared. Same for JSR223 currently. It's only the BeanShell sampler that re-uses the interpreter. > Thus you can use this object to > share variables between test samples. Now this seems fine for sharing > simple numbers/strings - but what I want to do, is share a socket > instance between successive test samples, and this seems to break > somewhere, or I am misunderstanding. Interpreters are not shared, see above. > Basically, I have the one thread group, looping 10 times. Inside, a > BSF group, running the following jruby script: > > require 'socket' > > if $vars.getObject("s") == nil > s = TCPSocket.open("localhost", 6663) > $vars.putObject("s",s) > end > > begin > socket = $vars.getObject("s") > socket.send([1,2,3,4]) > rescue => e > puts "Error" > puts e.message > end > > I can see it working the first time, but after that, it fails with an > exception: > > Bad file descriptor. > > The output I get is basically this (note, I am running through the > chronos maven plugin here): > [INFO] Success > .... > [INFO] Error > [INFO] Bad file descriptor - Bad file descriptor > .... > [INFO] Error > [INFO] Bad file descriptor - Bad file descriptor > > etc. > > Should I not be using the $vars object to share something like this? > Is the interpreter in fact getting recreated? Yes. > What am I misunderstanding? Just that. > Thanks for any help, enlightenment, etc. Work-rounds: - use BeanShell - create and manage the interpreter yourself - if you use the interpreter to create an interpreter rather than a socket, it may be possible to invoke the saved interpreter. Or perhaps the TCP Sampler would be a more suitable base. > --------------------------------------------------------------------- > To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org > For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org