Re: Need help with User Defined Variables

2022-07-04 Thread Nikola Aleksic
Hi Robin,

There was a discussion in this thread
https://bz.apache.org/bugzilla/show_bug.cgi?id=65072 about the mentioned
problem. Workaround is to use the Groovy function instead. If the function
works then there must be a way to evaluate the regular ${variable}. Thread
is still open, so it might get fixed in future.

Nikola

On Fri, 1 Jul 2022 at 16:46, Robin D. Wilson  wrote:

> Thank you all. I am following your advice, and it is working for me.
>
> --
> Robin D. Wilson
> CELL: 512-426-3929
> rwils...@gmail.com
>
>
> On Fri, Jul 1, 2022 at 1:29 AM Dmitri T  wrote:
>
> > As per documentation
> > <
> >
> https://jmeter.apache.org/usermanual/component_reference.html#User_Defined_Variables
> > >:
> >
> > Also, the variables are not available for use until after the element
> > has been processed, so *you cannot reference variables that are defined
> > in the same element*. You can reference variables defined in earlier
> > UDVs or on the Test Plan.
> >
> > and
> >
> > UDVs are processed in the order they appear in the Plan, *from top to
> > bottom*.
> >
> > so if you want to reference an already defined variable you need to add
> > another UDV element below the "initial" one and it should start working.
> >
> > More information: Using User Defined Variables
> > <
> >
> https://guide.blazemeter.com/hc/en-us/articles/207421395-Using-User-Defined-Variables
> > >
> >
> >
> > On 6/30/2022 6:58 PM, Robin D. Wilson wrote:
> > > I'm trying to setup a test with User Defined Variables.
> > >
> > > I want to define a variable "ENV" that specifies whether the test will
> > run
> > > in the 'dev' environment, or not. (Basically, if set it will modify all
> > of
> > > the 'hosts' I hit with '-dev' on their hostnames.)
> > >
> > > So I want to setup the following type of variables:
> > >
> > > ENV = "-dev"
> > > HOSTNAME = "myhost${ENV}"
> > >
> > > Then when the test runs, if "ENV" = "-dev", the HOSTNAME would be
> > > "myhost-dev", but if I change "ENV" to "" (null), the HOSTNAME would be
> > > "myhost".
> > >
> > > But the User Defined Variables apparently don't use previously set
> > > variables in the config? Because what I am getting for "HOSTNAME" is
> > > "myhost${ENV}"...
> > >
> > > --
> > > Robin D. Wilson
> > > CELL: 512-426-3929
> > > rwils...@gmail.com
> > >
>


Re: Need help with User Defined Variables

2022-07-01 Thread Robin D. Wilson
Thank you all. I am following your advice, and it is working for me.

--
Robin D. Wilson
CELL: 512-426-3929
rwils...@gmail.com


On Fri, Jul 1, 2022 at 1:29 AM Dmitri T  wrote:

> As per documentation
> <
> https://jmeter.apache.org/usermanual/component_reference.html#User_Defined_Variables
> >:
>
> Also, the variables are not available for use until after the element
> has been processed, so *you cannot reference variables that are defined
> in the same element*. You can reference variables defined in earlier
> UDVs or on the Test Plan.
>
> and
>
> UDVs are processed in the order they appear in the Plan, *from top to
> bottom*.
>
> so if you want to reference an already defined variable you need to add
> another UDV element below the "initial" one and it should start working.
>
> More information: Using User Defined Variables
> <
> https://guide.blazemeter.com/hc/en-us/articles/207421395-Using-User-Defined-Variables
> >
>
>
> On 6/30/2022 6:58 PM, Robin D. Wilson wrote:
> > I'm trying to setup a test with User Defined Variables.
> >
> > I want to define a variable "ENV" that specifies whether the test will
> run
> > in the 'dev' environment, or not. (Basically, if set it will modify all
> of
> > the 'hosts' I hit with '-dev' on their hostnames.)
> >
> > So I want to setup the following type of variables:
> >
> > ENV = "-dev"
> > HOSTNAME = "myhost${ENV}"
> >
> > Then when the test runs, if "ENV" = "-dev", the HOSTNAME would be
> > "myhost-dev", but if I change "ENV" to "" (null), the HOSTNAME would be
> > "myhost".
> >
> > But the User Defined Variables apparently don't use previously set
> > variables in the config? Because what I am getting for "HOSTNAME" is
> > "myhost${ENV}"...
> >
> > --
> > Robin D. Wilson
> > CELL: 512-426-3929
> > rwils...@gmail.com
> >


Re: Need help with User Defined Variables

2022-07-01 Thread Dmitri T
As per documentation 
:


Also, the variables are not available for use until after the element 
has been processed, so *you cannot reference variables that are defined 
in the same element*. You can reference variables defined in earlier 
UDVs or on the Test Plan.


and

UDVs are processed in the order they appear in the Plan, *from top to 
bottom*.


so if you want to reference an already defined variable you need to add 
another UDV element below the "initial" one and it should start working.


More information: Using User Defined Variables 




On 6/30/2022 6:58 PM, Robin D. Wilson wrote:

I'm trying to setup a test with User Defined Variables.

I want to define a variable "ENV" that specifies whether the test will run
in the 'dev' environment, or not. (Basically, if set it will modify all of
the 'hosts' I hit with '-dev' on their hostnames.)

So I want to setup the following type of variables:

ENV = "-dev"
HOSTNAME = "myhost${ENV}"

Then when the test runs, if "ENV" = "-dev", the HOSTNAME would be
"myhost-dev", but if I change "ENV" to "" (null), the HOSTNAME would be
"myhost".

But the User Defined Variables apparently don't use previously set
variables in the config? Because what I am getting for "HOSTNAME" is
"myhost${ENV}"...

--
Robin D. Wilson
CELL: 512-426-3929
rwils...@gmail.com


Re: Need help with User Defined Variables

2022-06-30 Thread Scott Dean
Greetings Robin,

Are you defining both variables in the same User Defined Variable (UDV)
component?  I have found that if you define a variable in a UDV component,
you cannot use it as part of the value of a different variable in that
component.  It appears that variables are not resolvable until the whole
UDV component has been processed

Try adding a second User Defined Variable component and move the definition
of HOSTNAME to that UDV component.

Hope that helps!

-- Scott Dean
   OIT/Shared Services/AIS
   NC State University
   Raleigh, NCUSA



On Thu, Jun 30, 2022 at 12:58 PM Robin D. Wilson  wrote:

> I'm trying to setup a test with User Defined Variables.
>
> I want to define a variable "ENV" that specifies whether the test will run
> in the 'dev' environment, or not. (Basically, if set it will modify all of
> the 'hosts' I hit with '-dev' on their hostnames.)
>
> So I want to setup the following type of variables:
>
> ENV = "-dev"
> HOSTNAME = "myhost${ENV}"
>
> Then when the test runs, if "ENV" = "-dev", the HOSTNAME would be
> "myhost-dev", but if I change "ENV" to "" (null), the HOSTNAME would be
> "myhost".
>
> But the User Defined Variables apparently don't use previously set
> variables in the config? Because what I am getting for "HOSTNAME" is
> "myhost${ENV}"...
>
> --
> Robin D. Wilson
> CELL: 512-426-3929
> rwils...@gmail.com
>