You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Nirodha Pramod <ni...@wso2.com> on 2012/01/31 21:47:03 UTC

Can we use a beanshell as Once only controller

Hi,

I have used a beanshell as a child of Once only controller. But it doesn't
seem to run the beanshell never. I have put a print statement just to
debug, but it never gets printed. Is it a correct way to use the once in
controller. Can someone give a solution, please.

Thanks,
Nirodha

-- 
*Nirodha Gallage*
Software Engineer, QA.
WSO2 Inc.: http://wso2.com/
Email: nirodha@wso2.com   Mobile: +94716429078

Re: Can we use a beanshell as Once only controller

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
why not just an IF controller around the beanshell sampler?
${__threadNum()} == 1
If your beanshell is inline then you need to use ${__threadNum()}
If your beanshell is a function or a file , then there is a Jmeter object
that you use -
http://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html

Again the setUpThreadGroup was written for such usecases and is cleaner.

regards
deepak

On Wed, Feb 1, 2012 at 1:43 PM, Nirodha Pramod <ni...@wso2.com> wrote:

> On Wed, Feb 1, 2012 at 11:44 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
> > Hi
> > Only Once is per thread - if you want this once for the whole test then
> you
> > should probably be using the Setup ThreadGroup (or you can use an If
> > controller which only executes its children for threadnumber 1)
> >
>
> In that case how can I read the running thread number in side beanshell. I
> found that there's a function called threadNum, but I could not find how to
> call a function inside beanshell PP.
>
> Does it work if I give vars.get("_threadNum");    ??
>
> >
> > regards
> > deepak
> >
> > On Wed, Feb 1, 2012 at 9:34 AM, Nirodha Pramod <ni...@wso2.com> wrote:
> >
> > > Hi,
> > >
> > > I was using a beanshell preprocessor and it was not working because
> there
> > > was no sampler for that. When I added a sampler it worked. But the
> issue
> > it
> > > gets executed the number of times as the number of threads(1000 times
> as
> > my
> > > thread count is 1000), and not only once. What is the issue with that?
> > >
> > > Thanks,
> > > Nirodha
> > >
> > > On Wed, Feb 1, 2012 at 2:29 AM, Deepak Shetty <sh...@gmail.com>
> wrote:
> > >
> > > > Beanshell sampler or preprocessor?
> > > > If sampler then check the logs if there are errors. If pre/post
> > processor
> > > > then these need at least one sampler to run against
> > > >
> > > > regards
> > > > deepak
> > > >
> > > > On Tue, Jan 31, 2012 at 12:47 PM, Nirodha Pramod <ni...@wso2.com>
> > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I have used a beanshell as a child of Once only controller. But it
> > > > doesn't
> > > > > seem to run the beanshell never. I have put a print statement just
> to
> > > > > debug, but it never gets printed. Is it a correct way to use the
> once
> > > in
> > > > > controller. Can someone give a solution, please.
> > > > >
> > > > > Thanks,
> > > > > Nirodha
> > > > >
> > > > > --
> > > > > *Nirodha Gallage*
> > > > > Software Engineer, QA.
> > > > > WSO2 Inc.: http://wso2.com/
> > > > > Email: nirodha@wso2.com   Mobile: +94716429078
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > *Nirodha Gallage*
> > > Software Engineer, QA.
> > > WSO2 Inc.: http://wso2.com/
> > > Email: nirodha@wso2.com   Mobile: +94716429078
> > >
> >
>
>
>
> --
> *Nirodha Gallage*
> Software Engineer, QA.
> WSO2 Inc.: http://wso2.com/
> Email: nirodha@wso2.com   Mobile: +94716429078
>

Re: Can we use a beanshell as Once only controller

Posted by Nirodha Pramod <ni...@wso2.com>.
On Wed, Feb 1, 2012 at 11:44 PM, Deepak Shetty <sh...@gmail.com> wrote:

> Hi
> Only Once is per thread - if you want this once for the whole test then you
> should probably be using the Setup ThreadGroup (or you can use an If
> controller which only executes its children for threadnumber 1)
>

In that case how can I read the running thread number in side beanshell. I
found that there's a function called threadNum, but I could not find how to
call a function inside beanshell PP.

Does it work if I give vars.get("_threadNum");    ??

>
> regards
> deepak
>
> On Wed, Feb 1, 2012 at 9:34 AM, Nirodha Pramod <ni...@wso2.com> wrote:
>
> > Hi,
> >
> > I was using a beanshell preprocessor and it was not working because there
> > was no sampler for that. When I added a sampler it worked. But the issue
> it
> > gets executed the number of times as the number of threads(1000 times as
> my
> > thread count is 1000), and not only once. What is the issue with that?
> >
> > Thanks,
> > Nirodha
> >
> > On Wed, Feb 1, 2012 at 2:29 AM, Deepak Shetty <sh...@gmail.com> wrote:
> >
> > > Beanshell sampler or preprocessor?
> > > If sampler then check the logs if there are errors. If pre/post
> processor
> > > then these need at least one sampler to run against
> > >
> > > regards
> > > deepak
> > >
> > > On Tue, Jan 31, 2012 at 12:47 PM, Nirodha Pramod <ni...@wso2.com>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > I have used a beanshell as a child of Once only controller. But it
> > > doesn't
> > > > seem to run the beanshell never. I have put a print statement just to
> > > > debug, but it never gets printed. Is it a correct way to use the once
> > in
> > > > controller. Can someone give a solution, please.
> > > >
> > > > Thanks,
> > > > Nirodha
> > > >
> > > > --
> > > > *Nirodha Gallage*
> > > > Software Engineer, QA.
> > > > WSO2 Inc.: http://wso2.com/
> > > > Email: nirodha@wso2.com   Mobile: +94716429078
> > > >
> > >
> >
> >
> >
> > --
> > *Nirodha Gallage*
> > Software Engineer, QA.
> > WSO2 Inc.: http://wso2.com/
> > Email: nirodha@wso2.com   Mobile: +94716429078
> >
>



-- 
*Nirodha Gallage*
Software Engineer, QA.
WSO2 Inc.: http://wso2.com/
Email: nirodha@wso2.com   Mobile: +94716429078

Re: Can we use a beanshell as Once only controller

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
Only Once is per thread - if you want this once for the whole test then you
should probably be using the Setup ThreadGroup (or you can use an If
controller which only executes its children for threadnumber 1)

regards
deepak

On Wed, Feb 1, 2012 at 9:34 AM, Nirodha Pramod <ni...@wso2.com> wrote:

> Hi,
>
> I was using a beanshell preprocessor and it was not working because there
> was no sampler for that. When I added a sampler it worked. But the issue it
> gets executed the number of times as the number of threads(1000 times as my
> thread count is 1000), and not only once. What is the issue with that?
>
> Thanks,
> Nirodha
>
> On Wed, Feb 1, 2012 at 2:29 AM, Deepak Shetty <sh...@gmail.com> wrote:
>
> > Beanshell sampler or preprocessor?
> > If sampler then check the logs if there are errors. If pre/post processor
> > then these need at least one sampler to run against
> >
> > regards
> > deepak
> >
> > On Tue, Jan 31, 2012 at 12:47 PM, Nirodha Pramod <ni...@wso2.com>
> wrote:
> >
> > > Hi,
> > >
> > > I have used a beanshell as a child of Once only controller. But it
> > doesn't
> > > seem to run the beanshell never. I have put a print statement just to
> > > debug, but it never gets printed. Is it a correct way to use the once
> in
> > > controller. Can someone give a solution, please.
> > >
> > > Thanks,
> > > Nirodha
> > >
> > > --
> > > *Nirodha Gallage*
> > > Software Engineer, QA.
> > > WSO2 Inc.: http://wso2.com/
> > > Email: nirodha@wso2.com   Mobile: +94716429078
> > >
> >
>
>
>
> --
> *Nirodha Gallage*
> Software Engineer, QA.
> WSO2 Inc.: http://wso2.com/
> Email: nirodha@wso2.com   Mobile: +94716429078
>

Re: Can we use a beanshell as Once only controller

Posted by Nirodha Pramod <ni...@wso2.com>.
Hi,

I was using a beanshell preprocessor and it was not working because there
was no sampler for that. When I added a sampler it worked. But the issue it
gets executed the number of times as the number of threads(1000 times as my
thread count is 1000), and not only once. What is the issue with that?

Thanks,
Nirodha

On Wed, Feb 1, 2012 at 2:29 AM, Deepak Shetty <sh...@gmail.com> wrote:

> Beanshell sampler or preprocessor?
> If sampler then check the logs if there are errors. If pre/post processor
> then these need at least one sampler to run against
>
> regards
> deepak
>
> On Tue, Jan 31, 2012 at 12:47 PM, Nirodha Pramod <ni...@wso2.com> wrote:
>
> > Hi,
> >
> > I have used a beanshell as a child of Once only controller. But it
> doesn't
> > seem to run the beanshell never. I have put a print statement just to
> > debug, but it never gets printed. Is it a correct way to use the once in
> > controller. Can someone give a solution, please.
> >
> > Thanks,
> > Nirodha
> >
> > --
> > *Nirodha Gallage*
> > Software Engineer, QA.
> > WSO2 Inc.: http://wso2.com/
> > Email: nirodha@wso2.com   Mobile: +94716429078
> >
>



-- 
*Nirodha Gallage*
Software Engineer, QA.
WSO2 Inc.: http://wso2.com/
Email: nirodha@wso2.com   Mobile: +94716429078

Re: Can we use a beanshell as Once only controller

Posted by Deepak Shetty <sh...@gmail.com>.
Beanshell sampler or preprocessor?
If sampler then check the logs if there are errors. If pre/post processor
then these need at least one sampler to run against

regards
deepak

On Tue, Jan 31, 2012 at 12:47 PM, Nirodha Pramod <ni...@wso2.com> wrote:

> Hi,
>
> I have used a beanshell as a child of Once only controller. But it doesn't
> seem to run the beanshell never. I have put a print statement just to
> debug, but it never gets printed. Is it a correct way to use the once in
> controller. Can someone give a solution, please.
>
> Thanks,
> Nirodha
>
> --
> *Nirodha Gallage*
> Software Engineer, QA.
> WSO2 Inc.: http://wso2.com/
> Email: nirodha@wso2.com   Mobile: +94716429078
>