Evaluation order of functions and variables in JDBC Request sampler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Evaluation order of functions and variables in JDBC Request sampler

David Balažic
Hi!

What is the evaluation order of functions and variables in a JDBC Request sampler?

What I'm interested in is: are the functions in the query evaluated first and later in the sampler fields like Name and Comments or vice versa?

In an experiment, I discovered that the query is run first, then the Name field.

What I did was to enter in the Query part:

${__setProperty(testabc,aaa)}
prop: ${__P(testabc)}

And in the name of the sampler:   prop in name: ${__P(testabc)}

When run, the sample name was (in the Results Tree) : prop in name: aaa

If I put this as name:  testing ${__setProperty(testxyz,aaa)}
And in the query field: prop: ${__P(testxyz)}

Then the query did not see the property, the resulting text was: prop: 1  # as the property is unset, it evaluates to 1

Is this official? In other words: can I rely on it not changing in future versions?

I used JMeter 5.3 for this test.

Lep pozdrav,
David Balažic


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Evaluation order of functions and variables in JDBC Request sampler

Felix Schumacher

Am 03.06.20 um 18:06 schrieb David Balažic:
> Hi!
>
> What is the evaluation order of functions and variables in a JDBC Request sampler?
>
> What I'm interested in is: are the functions in the query evaluated first and later in the sampler fields like Name and Comments or vice versa?

I would be interested, why would you like to rely on the order of the
initialization of fields in one sampler?


>
> In an experiment, I discovered that the query is run first, then the Name field.
>
> What I did was to enter in the Query part:
>
> ${__setProperty(testabc,aaa)}
> prop: ${__P(testabc)}

Why are you using properties instead of variables?


>
> And in the name of the sampler:   prop in name: ${__P(testabc)}
>
> When run, the sample name was (in the Results Tree) : prop in name: aaa
>
> If I put this as name:  testing ${__setProperty(testxyz,aaa)}
> And in the query field: prop: ${__P(testxyz)}
>
> Then the query did not see the property, the resulting text was: prop: 1  # as the property is unset, it evaluates to 1
>
> Is this official? In other words: can I rely on it not changing in future versions?

I would not rely on this undocumented "feature". I am not aware, that we
guarantee the order of inner field initialization of samplers.

Have you looked at pre-/post-processors to initialize variables before
or after a sampler?

Felix

>
> I used JMeter 5.3 for this test.
>
> Lep pozdrav,
> David Balažic
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Evaluation order of functions and variables in JDBC Request sampler

David Balažic
Felix Schumacher wrote:

> Am 03.06.20 um 18:06 schrieb David Balažic:
> > Hi!
> >
> > What is the evaluation order of functions and variables in a JDBC Request sampler?
> >
> > What I'm interested in is: are the functions in the query evaluated first and later in the sampler fields like Name and Comments or vice versa?
>
> I would be interested, why would you like to rely on the order of the initialization of fields in one sampler?

I set some values (using the __split function) and it must be executed before the results are used.

> > In an experiment, I discovered that the query is run first, then the Name field.
> >
> > What I did was to enter in the Query part:
> >
> > ${__setProperty(testabc,aaa)}
> > prop: ${__P(testabc)}
>
> Why are you using properties instead of variables?

This was just for test, to see the evaluation order.


> > And in the name of the sampler:   prop in name: ${__P(testabc)}
> >
> > When run, the sample name was (in the Results Tree) : prop in name:
> > aaa
> >
> > If I put this as name:  testing ${__setProperty(testxyz,aaa)} And in
> > the query field: prop: ${__P(testxyz)}
> >
> > Then the query did not see the property, the resulting text was: prop:
> > 1  # as the property is unset, it evaluates to 1
> >
> > Is this official? In other words: can I rely on it not changing in future versions?
>
> I would not rely on this undocumented "feature". I am not aware, that we guarantee the order of inner field initialization of samplers.
>
> Have you looked at pre-/post-processors to initialize variables before or after a sampler?

I'll look into it, thanks.

Lp,
David

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]