You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Seth Ladd <se...@ehawaii.gov> on 2005/05/20 00:32:29 UTC
way to get current date into a variable?
Hello,
I searched the FAQs and manual, but couldn't find this answer.
Is there a way to get the current date into reference name? I need to
set some input fields to "today".
Thanks very much!
Seth
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by Seth Ladd <se...@ehawaii.gov>.
> I then have a 'today' parameter name, and I really only need to specify
> it once. I defined the value for user 1 only. It appears that for
> users 2 - 10, when I try to dereference it, the value of 'today' is blank.
>
> I'm wondering if JMeter won't reuse values from parameters if multiple
> users are defined in the user parameters. I'll try to setup a special
> user parameters with only the 'today' parameter.
Update: If you have have some user parameters that are set for each
user, and some user parameters that are shared among all users, you need
to create two sets of User Parameters.
This way, JMeter will reuse the shared parameters for all users.
Thanks,
Seth
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by Seth Ladd <se...@ehawaii.gov>.
Thanks sebb,
> BTW, no need to provide entries for more than 1 user - JMeter will
> keep using User_1 if necessary.
This doesn't seem to be the case if you have specified values for more
than one user in a single User Parameters.
For instance, I have 10 users. I have specified a username and a
password parameter names, and each user has their own values.
I then have a 'today' parameter name, and I really only need to specify
it once. I defined the value for user 1 only. It appears that for
users 2 - 10, when I try to dereference it, the value of 'today' is blank.
I'm wondering if JMeter won't reuse values from parameters if multiple
users are defined in the user parameters. I'll try to setup a special
user parameters with only the 'today' parameter.
Thanks!
Seth
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by Michael Stover <ms...@apache.org>.
User-Defined Variables
User Parameters
One is static, one is a pre-processor - does anyone but me have a hard
time keeping these straight? Maybe we could come up with some better
names for them. There's also an old HTTP User Parameters or something
like that. Ugh.
-Mike
On Fri, 2005-05-20 at 22:30 +0100, sebb wrote:
> On 5/20/05, Seth Ladd <se...@ehawaii.gov> wrote:
> > Seth Ladd wrote:
> > > Hello,
> > >
> > > Thanks very much for the quick and helpful reply.
> > >
> > > I tried this technique in a User Defined Variable:
> > >
> > > Name Value
> > > today ${__javaScript(new Date(),Dummy)}
> > > bizName ${today} ${counter}
> > >
> > > (note that counter is a counter setup in the thread group)
> > >
> > > When I try to reference the ${bizName} variable, it resolves to the
> > > literal string '${today} ${counter}'
> > >
> > > Are variables not dereferenced in the value of a User Defined Variable?
> >
> > Sorry about that... I just saw in the reference documentation that User
> > Defined Variables have to be static.
> >
> > What is the recommended way to construct a variable from the value of
> > two different variables?
> >
>
> No need, one can use them all in a field, e.g. the HTTP Path field
> could contain:
>
> /${dir1}/${dir2}/${file}?${p1}&${p2}
>
> Of course, this does get a bit messy, so you can use the User
> Parameters Pre-Processor instead of UDV. This does support
> variables/functions.
>
> BTW, no need to provide entries for more than 1 user - JMeter will
> keep using User_1 if necessary.
>
> S.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by sebb <se...@gmail.com>.
On 5/20/05, Seth Ladd <se...@ehawaii.gov> wrote:
> Seth Ladd wrote:
> > Hello,
> >
> > Thanks very much for the quick and helpful reply.
> >
> > I tried this technique in a User Defined Variable:
> >
> > Name Value
> > today ${__javaScript(new Date(),Dummy)}
> > bizName ${today} ${counter}
> >
> > (note that counter is a counter setup in the thread group)
> >
> > When I try to reference the ${bizName} variable, it resolves to the
> > literal string '${today} ${counter}'
> >
> > Are variables not dereferenced in the value of a User Defined Variable?
>
> Sorry about that... I just saw in the reference documentation that User
> Defined Variables have to be static.
>
> What is the recommended way to construct a variable from the value of
> two different variables?
>
No need, one can use them all in a field, e.g. the HTTP Path field
could contain:
/${dir1}/${dir2}/${file}?${p1}&${p2}
Of course, this does get a bit messy, so you can use the User
Parameters Pre-Processor instead of UDV. This does support
variables/functions.
BTW, no need to provide entries for more than 1 user - JMeter will
keep using User_1 if necessary.
S.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by Seth Ladd <se...@ehawaii.gov>.
Seth Ladd wrote:
> Hello,
>
> Thanks very much for the quick and helpful reply.
>
> I tried this technique in a User Defined Variable:
>
> Name Value
> today ${__javaScript(new Date(),Dummy)}
> bizName ${today} ${counter}
>
> (note that counter is a counter setup in the thread group)
>
> When I try to reference the ${bizName} variable, it resolves to the
> literal string '${today} ${counter}'
>
> Are variables not dereferenced in the value of a User Defined Variable?
Sorry about that... I just saw in the reference documentation that User
Defined Variables have to be static.
What is the recommended way to construct a variable from the value of
two different variables?
Thanks again!
Seth
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by Seth Ladd <se...@ehawaii.gov>.
Hello,
Thanks very much for the quick and helpful reply.
I tried this technique in a User Defined Variable:
Name Value
today ${__javaScript(new Date(),Dummy)}
bizName ${today} ${counter}
(note that counter is a counter setup in the thread group)
When I try to reference the ${bizName} variable, it resolves to the
literal string '${today} ${counter}'
Are variables not dereferenced in the value of a User Defined Variable?
I am using JMeter 2.0.3
Thanks very much for your help!
Seth
> Yes, several methods. All rely on functions.
>
> 1) Get the date from the OS, and set a property on the command line
> with the value, then use one of the property functions to retrieve it.
> E.g.
> jmeter -Dtoday="`date`"
> Then refer to it as ${today}
>
> 2) Use the JavaScript function to create a suitable date string, e.g.
> ${__javaScript(new Date(),Dummy)}
>
> 3) Use the BeanShell function to create a suitable date string e.g.
> ${__BeanShell(new java.util.Date())}
>
> You'll need to adjust the format.
>
> S.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: way to get current date into a variable?
Posted by sebb <se...@gmail.com>.
On 5/19/05, Seth Ladd <se...@ehawaii.gov> wrote:
> Hello,
>
> I searched the FAQs and manual, but couldn't find this answer.
>
> Is there a way to get the current date into reference name? I need to
> set some input fields to "today".
>
Yes, several methods. All rely on functions.
1) Get the date from the OS, and set a property on the command line
with the value, then use one of the property functions to retrieve it.
E.g.
jmeter -Dtoday="`date`"
Then refer to it as ${today}
2) Use the JavaScript function to create a suitable date string, e.g.
${__javaScript(new Date(),Dummy)}
3) Use the BeanShell function to create a suitable date string e.g.
${__BeanShell(new java.util.Date())}
You'll need to adjust the format.
S.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org