You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by GitBox <gi...@apache.org> on 2020/05/31 14:15:00 UTC
[GitHub] [jmeter] FSchumacher opened a new pull request #595: Add freestyle naming scheme to proxy samples
FSchumacher opened a new pull request #595:
URL: https://github.com/apache/jmeter/pull/595
## 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?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->
Currently it has only been tested via GUI. No tests have been added.
## Screenshots (if appropriate):
## Types of changes
<!--- What types of changes does your code introduce? Delete as appropriate -->
- New feature (non-breaking change which adds functionality)
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [x] My code follows the [code style][style-guide] of this project.
- [ ] I have updated the documentation accordingly.
[style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] vdaburon commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
vdaburon commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-683705854
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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-683698110
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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] asfgit closed pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #595:
URL: https://github.com/apache/jmeter/pull/595
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on a change in pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on a change in pull request #595:
URL: https://github.com/apache/jmeter/pull/595#discussion_r450249739
##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java
##########
@@ -285,33 +288,49 @@ public boolean isErrorDetected() {
*/
protected void computeSamplerName(HTTPSamplerBase sampler,
HttpRequestHdr request) {
- String prefix = request.getPrefix();
+ String prefix = StringUtils.defaultString(request.getPrefix(), "");
int httpSampleNameMode = request.getHttpSampleNameMode();
+ String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
- if(StringUtils.isNotEmpty(prefix)) {
- if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
- sampler.setName(prefix + sampler.getPath()+ "-" + incrementRequestNumberAndGet());
- } else if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
- sampler.setName(prefix + "-" + incrementRequestNumberAndGet());
- } else {
- log.debug("Sampler name naming mode not recognized");
- }
- } else {
- sampler.setName(sampler.getPath()+"-"+incrementRequestNumberAndGet());
- }
+ sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
} else {
- if(StringUtils.isNotEmpty(prefix)) {
- if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
- sampler.setName(prefix + sampler.getPath());
- } else if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
- sampler.setName(prefix);
- } else {
- log.debug("Sampler name naming mode not recognized");
- }
- } else {
- sampler.setName(sampler.getPath());
- }
+ sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+ }
+ }
+
+ private String getFormat(int httpSampleNameMode, String format) {
+ if (isNumberRequests()) {
+ return getNumberedFormat(httpSampleNameMode, format);
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
+ return "{0}{1}";
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
+ return "{0}";
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_SUFFIX) {
+ return "{0} {1}";
Review comment:
This is the not-numbered path, so yes, I believe this is correct.
I took the numbered formats (`{0}{1}-{2}`, `{0}-{2}` and `{0}-{2} {1}`) and *subtracted* `-{2}` from those. That way you get `{0}{1}`, `{0}` and `{0} {1}`. N'est-ce pas?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] vdaburon commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
vdaburon commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-684534515
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

Regards
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-637596512
...
> 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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] vdaburon commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
vdaburon commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-683695416
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
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-684837107
Can you try again?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] pmouawad commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
pmouawad commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-683333255
Hello @FSchumacher ,
This PR looks good to me.
Thanks
Regards
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] pmouawad commented on a change in pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
pmouawad commented on a change in pull request #595:
URL: https://github.com/apache/jmeter/pull/595#discussion_r450162256
##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/DefaultSamplerCreator.java
##########
@@ -285,33 +288,49 @@ public boolean isErrorDetected() {
*/
protected void computeSamplerName(HTTPSamplerBase sampler,
HttpRequestHdr request) {
- String prefix = request.getPrefix();
+ String prefix = StringUtils.defaultString(request.getPrefix(), "");
int httpSampleNameMode = request.getHttpSampleNameMode();
+ String format = getFormat(httpSampleNameMode, request.getHttpSampleNameFormat());
if (!HTTPConstants.CONNECT.equals(request.getMethod()) && isNumberRequests()) {
- if(StringUtils.isNotEmpty(prefix)) {
- if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
- sampler.setName(prefix + sampler.getPath()+ "-" + incrementRequestNumberAndGet());
- } else if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
- sampler.setName(prefix + "-" + incrementRequestNumberAndGet());
- } else {
- log.debug("Sampler name naming mode not recognized");
- }
- } else {
- sampler.setName(sampler.getPath()+"-"+incrementRequestNumberAndGet());
- }
+ sampler.setName(MessageFormat.format(format, prefix, sampler.getPath(), incrementRequestNumberAndGet()));
} else {
- if(StringUtils.isNotEmpty(prefix)) {
- if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
- sampler.setName(prefix + sampler.getPath());
- } else if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
- sampler.setName(prefix);
- } else {
- log.debug("Sampler name naming mode not recognized");
- }
- } else {
- sampler.setName(sampler.getPath());
- }
+ sampler.setName(MessageFormat.format(format, prefix, sampler.getPath()));
+ }
+ }
+
+ private String getFormat(int httpSampleNameMode, String format) {
+ if (isNumberRequests()) {
+ return getNumberedFormat(httpSampleNameMode, format);
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_PREFIX) {
+ return "{0}{1}";
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_COMPLETE) {
+ return "{0}";
+ }
+ if (httpSampleNameMode == SAMPLER_NAME_NAMING_MODE_SUFFIX) {
+ return "{0} {1}";
Review comment:
Is it regular that PREFIX and SUFFIX only vary by space ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-680240138
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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] FSchumacher commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
FSchumacher commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-683890998
I have added a JMeter property (`proxy.sampler_format` in `bin/jmeter.properties`), that can be used to choose a default value.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [jmeter] vlsi commented on pull request #595: Add freestyle naming scheme to proxy samples
Posted by GitBox <gi...@apache.org>.
vlsi commented on pull request #595:
URL: https://github.com/apache/jmeter/pull/595#issuecomment-636490589
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 :-/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org