Flexible File Writer - substring(responseMessage)

359 views
Skip to first unread message

PackCat

unread,
Jan 11, 2018, 4:02:13 AM1/11/18
to jmeter-plugins
Greetings,

Is there a way to create/write a Substring such as the last 20 characters of the response message. (incorporate JavaScript?)
This would be useful for capturing Java responses such as "Invalid Method" or "Not Authorized" in REST response.
Otherwise this response can fill up a page for each request. I am mostly interested in the HTTP 500 Error Results.

Thank you.

artem....@blazemeter.com

unread,
Jan 11, 2018, 4:33:00 AM1/11/18
to jmeter-plugins
Hello

You can add BeanSheel PostProcessor to your HTTP Request. 
In this post processor you can get Response message:

String code = prev.getResponseCode(); 
String message = prev.getResponseMessage();
than you can modify it with ${__substring(,,,)}, or ${__javaScript(,)} functions. (See Function Helper in JMeter -> Options -> Function Helper Dialog)

After modification you can put value in JMeterVariables (vars.put("myvar", myvar); ) or JMeterProperties (props.put("myprop", myprop);) or set it in SamplerResult ( prev.setResponseMessage(value);)

(see more https://stackoverflow.com/questions/24999312/jmeter-beanshell-postprocessor?answertab=votes#tab-top )

Thanks


четверг, 11 января 2018 г., 12:02:13 UTC+3 пользователь PackCat написал:

PackCat

unread,
Jan 11, 2018, 11:32:56 AM1/11/18
to jmeter-plugins
On Thursday, January 11, 2018 at 11:33:00 AM UTC+2, artem....@blazemeter.com wrote:

You can add BeanSheel PostProcessor to your HTTP Request. 
In this post processor you can get Response message:
String code = prev.getResponseCode();
String message = prev.getResponseMessage(); 
---

Thanks for the response!

I found a way around it using CSS, but now FFW is skipping 500 errors.
Maybe the strings are too long for it to store in memory?

STYLE>
  .trim-text {
 width: 375px;
 max-width:375px;
 display: inline-block;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: clip;
 direction:rtl;
  }
</STYLE> 

<TD class="trim-text">|responseData|</TD>

artem....@blazemeter.com

unread,
Jan 12, 2018, 5:22:48 AM1/12/18
to jmeter-plugins
Sure

I got BufferOverflowException in FFW when sampler has huge response data. It's easy for reproduce with testplan that I attached in other topic "Flexible File Writer - missing non-2xx ResponseData". Just need add big Response data to error sampler.
I'll try to fix this bug 

Thanks


четверг, 11 января 2018 г., 19:32:56 UTC+3 пользователь PackCat написал:

PackCat

unread,
Jan 12, 2018, 3:33:24 PM1/12/18
to jmeter-plugins
What would be a GREAT help is if FFW allowed at least 1 custom (real time) PP variable, such as |${myVar}|
Then I could rewrite the Response Message. (trim to show just the last 40 chars).
And no one would have to worry about buffer overrun.

Currently, the best it can do is show the initial setup value, not edits during runtime.
I can do magic with the cosmetics through CSS, but again only during initial startup.

Thanks!

PS, I'll work on a sample to show the difference between the 200 and dropping long 500.
Basically they are very long Spring messages.
But all was not lost. It was a windfall to print the 2xx responses only, as this was a security test on a restricted user (no rights) and 2xx was a great list to show items that were security lapses.
It was another suggestion idea of mine to choose which samplers went to output.

PackCat

unread,
Jan 12, 2018, 3:42:30 PM1/12/18
to jmeter-plugins


On Thursday, January 11, 2018 at 11:02:13 AM UTC+2, PackCat wrote:
Greetings,

Is there a way to create/write a Substring such as the last 20 characters of the response message. (incorporate JavaScript?)

Sorry, I meant ResponseData...  but I am sure you figured that out. :)

artem....@blazemeter.com

unread,
Jan 15, 2018, 8:04:10 AM1/15/18
to jmeter-plugins
Hello!

I investigated FFW more detail and found 2 solutions for your cases:

Regarding BufferOverflowException: If you got this exception than you can increase default buffer limit size. For it you should set JMeter property "kg.apc.jmeter.reporters.FFWBufferSize", for example in jmeter.properties file: 
kg.apc.jmeter.reporters.FFWBufferSize=8000000

Regarding write custom variable with FFW:
1) You should set JMeter property "sample_variables" which will be contain additional JMeter variables which are to be saved http://jmeter.apache.org/usermanual/listeners.html#sample_variables .
In your case it'll look like:
sample_variables=myVar
2) In your FFW config add |variable#0
You can read more about it in docs: https://jmeter-plugins.org/wiki/FlexibleFileWriter/#Saving-JMeter-Variables-with-Flexible-File-Writer
I attached my jmx that can write huge error response data and additional variable ${myVar}

I launched JMeter with addition options that I described above: 
./jmeter -Jsample_variables=myVar -Jkg.apc.jmeter.reporters.FFWBufferSize=8000000


Thanks,
Artem
пятница, 12 января 2018 г., 23:42:30 UTC+3 пользователь PackCat написал:
FlexibleFileWriter.jmx

PackCat

unread,
Jan 24, 2018, 7:11:49 AM1/24/18
to jmeter-plugins
unfortunately you are describing a pre-run Constant, and I need a runtime dynamic Var, for example something like:

AF = "Authorization Failed";
RD = ctx.getPreviousResult().getResponseDataAsString();
if (RD.contains(AF)) {
    sample_variables=AF;
}

Do you foresee adding dynamic variables anytime in the near future?
Or just allow the user to write inline javascript in the sample recorder. (Macros?)

How difficult would it be to allow ${myVar} or ${__property(myVar)} capability? (like the rest of Jmeter)

Thank you,
John

-------------------------------------------

PackCat

unread,
Jan 25, 2018, 4:01:09 AM1/25/18
to jmeter-plugins
OK, my summary....

Every answer I see in all the internet avoids the main question!

How does one write dynamic values to the output?


Clearly users want to submit changing values into the output. (csv, etc...)


In my case, I want to submit the equivalent of:

AF = "Authorization Failed";
RD = ctx.getPreviousResult().getResponseDataAsString();
if (RD.contains(AF)) {

    props.put("myResponse", AF);
} else {

    props.put("myResponse", RD);

---


<td>${__property(myResponse)}</td>


---


From every answer I see, the end result is NO, you cannot write changing values to Flexible File Writer!!!


If this had been the intent of the developer, they would had allowed custom ${vars} to be used in the plugin.

EVERYTHING is static output!!!

The only dynamic values are the tiny subset of vars that can be used and cannot be modified.


Sorry to break the hope of all interested parties.

Maybe if everyone chips in $1, the plugin developer will add that capability.


Thank you.


-------------------------------------


On Thursday, January 11, 2018 at 11:02:13 AM UTC+2, PackCat wrote:

Reply all
Reply to author
Forward
0 new messages