No need to code a new Sampler - BeanShell has an exec() method.

Unfortunately, the default exec() code does not return the status, but the
code is very simple anyway:

// Sample BSH procedure
int exec( String arg ) 
{
        this.proc = Runtime.getRuntime().exec(arg);
        this.din = new DataInputStream( proc.getInputStream() );
        while( (line=din.readLine()) != null )
                print(line);
        return this.proc.exitValue();
}
// Sample usage:

if (exec("check_logs")!==0){
IsSuccess=false;
}

S.
-----Original Message-----
From: Jordi Salvat i Alabart [mailto:[EMAIL PROTECTED]
Sent: 06 November 2003 22:08
To: JMeter Users List
Subject: Re: Preserving 'logins' accross jmeter sessions


Or write a "CommandSampler" using Runtime.exec to run an arbitrary 
command -- failing if Process.exitValue is non-zero.

-- 
Salut,

Jordi.

BAZLEY, Sebastian wrote:
> OK, I see.
> 
> For some such checks, you might be able to use the new BeanShell sampler -
> this can invoke arbitrary Java code, for example read one or more files,
and
> return whatever it likes to JMeter. [BeanShell is in the CVS version of
> JMeter, not in 1.9.1]
> 
> Or one could run another instance of Tomcat (or even write a simple Java
> http server) that could perform such checks on demand, and use a JMeter
HTTP
> sampler to retrieve the information when required.
> 
> S.
> -----Original Message-----
> From: Karthik Viswanath [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2003 05:09
> To: JMeter Users List
> Subject: Re: Preserving 'logins' accross jmeter sessions
> 
> 
> The reason for using a shell script is that we need to verify whether 
> the UI is actually doing what it is suppose to have done.
> For eg, lets say the UI screen involves restarting tomcat (or any 
> application).  As a verification, I need to check from the logs and find 
> out if it actually restarted tomcat. What the httpd returns would be a 
> response of 200 OK which would not validate the test.
> 
> I will try the jmeter server approach and let you know the results.
> 
> Thanks
> Karthik
> 
> 
> BAZLEY, Sebastian wrote:
> 
> 
>>Likewise, I'm sure it could be done, and I'm not saying it would not be
>>useful.
>>
>>But I question whether it is a good idea to run lots of JMX scripts in
>>separate JMeter invocations.
>>I assume that these scripts are quite short, and if so, there will be a
lot
>>of overhead in starting the JVM and JMeter. That's what I meant by JMeter
>>not being suitable - sorry, I should have been more explicit.
>>
>>However, it's just occurred to me that it might be possible to use JMeter
>>server-client mode to solve that problem. Completely untested, but it
might
>>work for low volume testing:
>>
>>- start a JMeter server instance
>>- use "jmeter -n -r -t testfile" from the shell script to send the script
> 
> to
> 
>>the server
>>
>>I'm not sure what context the JMeter server keeps at the end of s run, so
>>this might be a non-starter without some additional code.
>>
>>==
>>
>>I also should have clarified what I meant about the security of the login
>>process.
>>If the server accepts a login on the basis of a cookie which can be passed
> 
>>from session to session, then it seems to me that there is scope for that
> 
>>cookie to be stolen ...
>>
>>S.
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>Sent: 03 November 2003 15:08
>>To: JMeter Users List
>>Subject: RE: Preserving 'logins' accross jmeter sessions
>>
>>
>>But how hard would it be?  Why couldn't the cookie manager 
>>serialize itself to a file and be reloaded by a different cookie 
>>manager?  If the manager is given a file, then they would all load 
>>state at the start of the test from the file, and at the end, dump their 
>>state.  Synchronize file access and treat the file contents as a 
>>queue/stack of cookie state (when a manager reads state, it also 
>>deletes that entry).  This could allow state to be carried over 
>>between jmeter runs and between threadgroups that are running 
>>serially.  
>>
>>Since this isn't the first time it's been asked for, it seems worthwhile 
>>to do.
>>
>>-Mike
>>
>>On 3 Nov 2003 at 12:46, BAZLEY, Sebastian wrote:
>>
>> 
>>
>>
>>>IMO, JMeter is not really designed for such usage ...
>>>
>>>Can you not use Response Assertions to do the checking instead 
>>>   
>>>
>>
>>of using the
>> 
>>
>>
>>>shell?
>>>
>>>Could you not build up a JMX file to contain all the tests?
>>>It is possible to use functions and variables to parameterise tests 
>>>   
>>>
>>
>>(see my
>> 
>>
>>
>>>posting in the thread RE: Using csv data as input)
>>>
>>>==
>>>
>>>As to avoiding logging in each time, that depends entirely on the
>>>application you are testing, and how it determines whether you 
>>>   
>>>
>>
>>are still
>> 
>>
>>
>>>logged in.
>>>
>>>If it is not very secure, you might be able to extract one or more 
>>>   
>>>
>>
>>tokens
>> 
>>
>>
>>>(e.g. cookies or URLs) from the initial login session, and pass 
>>>   
>>>
>>
>>them to the
>> 
>>
>>
>>>next test.
>>>
>>>S.
>>>-----Original Message-----
>>>From: Karthik Viswanath [mailto:[EMAIL PROTECTED]
>>>Sent: 03 November 2003 07:34
>>>To: [EMAIL PROTECTED]
>>>Subject: Preserving 'logins' accross jmeter sessions
>>>
>>>
>>>Hi,
>>>
>>>I am trying to develop a test suite which involves execution of a 
>>>   
>>>
>>
>>'jmx' 
>> 
>>
>>
>>>script followed by various verification steps for each testcase (in 
>>>   
>>>
>>
>>a 
>> 
>>
>>
>>>shell script) Currently I am using the command line options to 
>>>   
>>>
>>
>>execute 
>> 
>>
>>
>>>the jmx script.
>>>However, when the jmx files are executed in a batch, it takes a 
>>>   
>>>
>>
>>long 
>> 
>>
>>
>>>time to execute since
>>>1. I am invoking jmeter from the command line for every jmx file 
>>>   
>>>
>>
>>being 
>> 
>>
>>
>>>executed
>>>2. I need to login for every testcase execution. (Our UI uses 
>>>   
>>>
>>
>>sockets to 
>> 
>>
>>
>>>detect active users)
>>>A sample batch would look like
>>>
>>>./jmeter -n -t 1.jmx -l log.jtl -H <proxy>  -P 1080
>>>./1.sh
>>>./jmeter -n -t 2.jmx -l log.jtl -H <proxy>  -P 1080
>>>./2.sh
>>>...
>>>
>>>I would also like to know of any way to execute 2.jmx "without 
>>>   
>>>
>>
>>logging 
>> 
>>
>>
>>>in" again.
>>>
>>>Also any suggestions for a better approach than what I am 
>>>   
>>>
>>
>>currently 
>> 
>>
>>
>>>using would be very helpful.
>>>
>>>Thanks
>>>Karthik
>>>
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: jmeter-user-
>>>   
>>>
>>
>>[EMAIL PROTECTED]
>> 
>>
>>
>>>For additional commands, e-mail: jmeter-user-
>>>   
>>>
>>
>>[EMAIL PROTECTED]
>> 
>>
>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: jmeter-user-
>>>   
>>>
>>
>>[EMAIL PROTECTED]
>> 
>>
>>
>>>For additional commands, e-mail: jmeter-user-
>>>   
>>>
>>
>>[EMAIL PROTECTED]
>> 
>>
>>
>>
>>
>>
>>--
>>Michael Stover
>>[EMAIL PROTECTED]
>>Yahoo IM: mstover_ya
>>ICQ: 152975688
>>AIM: mstover777
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to