Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add freestyle naming scheme to proxy samples #595

Closed

Conversation

FSchumacher
Copy link
Contributor

@FSchumacher FSchumacher commented May 31, 2020

Description

This is a slightly different approach to naming samples that are recorded via the proxy that has been proposed in #571.

Motivation and Context

I think as we add another scheme to naming recorded samples, others will want their favourite naming schemes, too. So in this PR I try to anticipate that by adding a format string that can be used to go really wild on your naming preferences. (The newly added suffix-mode can be expressed through the format string, as well as the older modes prefix and transaction)

The PR #571 has one other feature, that is not implemented in this PR. Namely the addition of setting starting numbers for recorded samples. I think that should be added in another feature/PR. It is of course possible to add it later with this approach, too.

How Has This Been Tested?

Currently it has only been tested via GUI. No tests have been added.

Screenshots (if appropriate):

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@vlsi
Copy link
Collaborator

vlsi commented May 31, 2020

Thanks for implementing this. I agree it would be better to make the format configurable rather than implementing a couple of hard-coded formats.

I'm not sure MessageFormat is a proper templating framework though: there are no named parameters, so the template string would be awkward and it would be hard to reason about :-/

@FSchumacher
Copy link
Contributor Author

...

I'm not sure MessageFormat is a proper templating framework though: there are no named parameters, so the template string would be awkward and it would be hard to reason about :-/

Yes, I agree. MessageFormat might be hard to read, but

  • it is better then my first implementation, which used String#format which sucked even more ;)
  • it can use formatting options for numbers, which is handy, as it allows something like {1,number,000}
  • other template languages might look like the JMeter built-in variable replacement syntax or would have to be included (for the former I thought about StringSubstitutor from commons-text)

Do you have a special templating system in mind, that we can/should use?

One idea would be to parse the format string and generate the three placeholders à la #{prefix} #{path} #{count,number,000} -> {0} {1} {2,number,000} via s/#{count\b/{2/, etc.

@FSchumacher FSchumacher force-pushed the freestyle-names-for-proxy-samples branch 2 times, most recently from 0faa0aa to 9da8c0b Compare August 1, 2020 13:39
@FSchumacher FSchumacher force-pushed the freestyle-names-for-proxy-samples branch from 1a1f640 to 457310f Compare August 16, 2020 10:19
@FSchumacher FSchumacher force-pushed the freestyle-names-for-proxy-samples branch from 457310f to 34e9ac6 Compare August 25, 2020 14:44
@FSchumacher
Copy link
Contributor Author

Despite of my initial comment, I have implemented the counter feature from #571 in this PR. Apart from the documentation (which is still missing), it looks complete now.

@FSchumacher FSchumacher force-pushed the freestyle-names-for-proxy-samples branch 6 times, most recently from ef5a4a6 to e52fc8d Compare August 27, 2020 19:44
Names of newly created Samplers by the DefaultSamplerCreator can now be
styled with a freestyle format, that understands the controls for
MessageFormat. Apart from the placeholders {0}, {1} and {2}, that are
hard to guess, for which part they are used, more memorizable placeholders
 #{name}, #{path} and #{counter} can be used.

The counter for the generated samplers can be set to a user specified number.
Add a space between if and the parenthesis
@FSchumacher FSchumacher force-pushed the freestyle-names-for-proxy-samples branch from e52fc8d to f73e15f Compare August 27, 2020 20:01
@pmouawad
Copy link
Contributor

Hello @FSchumacher ,
This PR looks good to me.
Thanks
Regards

@asfgit asfgit closed this in b69ca04 Aug 30, 2020
@vdaburon
Copy link
Contributor

How can i set the format for numbering in the jmeter.propeties or user.properties ?

I don't see a property to set the format.

numbering.format?=#{counter,number,000} #{path}

Regards

@FSchumacher
Copy link
Contributor Author

In the string format, you can use #{counter,number,000} directly. So, if you want to use the counter with three digits then a dash, the path and the transaction name in parenthesis, you would write #{counter,number,000} - #{path} (#{name}) in the text field next to the select field Naming scheme where you selected Use format string.
You don't set any property.

@vdaburon
Copy link
Contributor

How can i set the default format for recording and multi-computers ?

Usually you could set the default value in the jmeter.properties. I don't see this feature.

But I appreciate the new interface with the possibility to choose the numbering format and set the counter value.

Regards.

asfgit pushed a commit that referenced this pull request Aug 31, 2020
Use a default value for the format string, that can be controlled by
a JMeter property.

Bugzilla Id: 64696
Relates to #595
@FSchumacher
Copy link
Contributor Author

I have added a JMeter property (proxy.sampler_format in bin/jmeter.properties), that can be used to choose a default value.

asfgit pushed a commit that referenced this pull request Aug 31, 2020
Don't save the default value for the format string property

Bugzilla Id: 64696
Relates to #595
@vdaburon
Copy link
Contributor

vdaburon commented Sep 1, 2020

I download,the nigthly jmeter (2020-09-01).

When i use the template "Recording", i see the format that i set in the jmeter.properties
proxy.sampler_format=#{counter,number,000} #{path}

but when i don't use a template and add manually a "HTTP(S) Test Script Recorder", i don't see any format from proxy.sampler_format

proxy_recorder_no_format

Regards

asfgit pushed a commit that referenced this pull request Sep 1, 2020
Initialize format string correctly when script recorder is
created by hand instead of with a template.

Bugzilla Id: 64696
Relates to #595
@FSchumacher
Copy link
Contributor Author

Can you try again?

anthonygauthier pushed a commit to anthonygauthier/jmeter that referenced this pull request Sep 1, 2020
Use a default value for the format string, that can be controlled by
a JMeter property.

Bugzilla Id: 64696
Relates to apache#595
anthonygauthier pushed a commit to anthonygauthier/jmeter that referenced this pull request Sep 1, 2020
Don't save the default value for the format string property

Bugzilla Id: 64696
Relates to apache#595
anthonygauthier pushed a commit to anthonygauthier/jmeter that referenced this pull request Sep 1, 2020
Initialize format string correctly when script recorder is
created by hand instead of with a template.

Bugzilla Id: 64696
Relates to apache#595
ham1 pushed a commit to ham1/jmeter that referenced this pull request Sep 13, 2020
Names of newly created Samplers by the DefaultSamplerCreator can now be
styled with a freestyle format, that understands the controls for
MessageFormat. Apart from the placeholders {0}, {1} and {2}, that are
hard to guess, for which part they are used, more memorizable placeholders
 #{name}, #{path} and #{counter} can be used.

The counter for the generated samplers can be set to a user specified number.

Based on a patch by Vincent Daburon

Bugzilla Id: 64696
Closes apache#571
Closes apache#595
ham1 pushed a commit to ham1/jmeter that referenced this pull request Sep 13, 2020
Use a default value for the format string, that can be controlled by
a JMeter property.

Bugzilla Id: 64696
Relates to apache#595
ham1 pushed a commit to ham1/jmeter that referenced this pull request Sep 13, 2020
Don't save the default value for the format string property

Bugzilla Id: 64696
Relates to apache#595
ham1 pushed a commit to ham1/jmeter that referenced this pull request Sep 13, 2020
Initialize format string correctly when script recorder is
created by hand instead of with a template.

Bugzilla Id: 64696
Relates to apache#595
kkalinin pushed a commit to kkalinin/jmeter that referenced this pull request Mar 11, 2021
Names of newly created Samplers by the DefaultSamplerCreator can now be
styled with a freestyle format, that understands the controls for
MessageFormat. Apart from the placeholders {0}, {1} and {2}, that are
hard to guess, for which part they are used, more memorizable placeholders
 #{name}, #{path} and #{counter} can be used.

The counter for the generated samplers can be set to a user specified number.

Based on a patch by Vincent Daburon

Bugzilla Id: 64696
Closes apache#571
Closes apache#595
kkalinin pushed a commit to kkalinin/jmeter that referenced this pull request Mar 11, 2021
Use a default value for the format string, that can be controlled by
a JMeter property.

Bugzilla Id: 64696
Relates to apache#595
kkalinin pushed a commit to kkalinin/jmeter that referenced this pull request Mar 11, 2021
Don't save the default value for the format string property

Bugzilla Id: 64696
Relates to apache#595
kkalinin pushed a commit to kkalinin/jmeter that referenced this pull request Mar 11, 2021
Initialize format string correctly when script recorder is
created by hand instead of with a template.

Bugzilla Id: 64696
Relates to apache#595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants