Bug 65269 - JSON Extractor and JSON JMESPath Extractor Apply to doesn't work as expected
Summary: JSON Extractor and JSON JMESPath Extractor Apply to doesn't work as expected
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: Nightly (Please specify date)
Hardware: All All
: P2 major (vote)
Target Milestone: JMETER_5.5
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2021-04-27 14:41 UTC by eR@SeR
Modified: 2021-06-09 16:18 UTC (History)
0 users



Attachments
extractor wrong behavior (106.33 KB, application/x-zip-compressed)
2021-04-27 14:41 UTC, eR@SeR
Details
Add handling of sub-samples to the JSON Extractors (9.92 KB, patch)
2021-05-30 18:44 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description eR@SeR 2021-04-27 14:41:27 UTC
Created attachment 37834 [details]
extractor wrong behavior

Hello,

In the attached test plan, there are Boundary Extractor, JSON Extractor and JSON JMESPath Extractor. Apply to options "MainSampleAndSubSamples", "MainSampleOnly" and "SubSamplesOnly" are used and extraction is done on "JSR223 Sampler - create JSON response" and its subsample that is created using JSR223 PP. The First 3 extractors of every kind are extracting values from "JSR223 Sampler - create JSON response" and another 3 from its subsample. The behavior of Boundary Extractor, JSON Extractor and JSON JMESPath Extractor is not the same. Please run the test and check Debug Sampler in VRT. Boundary Extractor works as expected but JSON Extractor and JSON JMESPath Extractor don't. Please refer to the attached image to see what is correct and what is wrong behavior.

P.S. Boundary extractor throws WARN message in logs if there is no match between boundaries.

WARN o.a.j.e.BoundaryExtractor: Boundary Extractor - BEcategoryFieldSubSamplesOnly: Error while generating result. java.lang.IllegalArgumentException: bound must be positive
WARN o.a.j.e.BoundaryExtractor: Boundary Extractor - BEticker_langMainSampleOnly: Error while generating result. java.lang.IllegalArgumentException: bound must be positive

Is this expected? IMO, it should be hidden like for other extractors.

Jmeter 5.5 08c3c59
Microsoft Windows 10 Enterprise 64-bit
java version "15.0.1" 2020-10-20
Comment 1 Felix Schumacher 2021-05-30 18:44:23 UTC
Created attachment 37884 [details]
Add handling of sub-samples to the JSON Extractors

As the UI suggests, the extractors should handle the selection of sub-samples.
Comment 2 Felix Schumacher 2021-06-03 09:27:14 UTC
@Nikola, could you test next nightly or build from trunk and report back, if it fixes your problem?

Note, I haven't changed Boundary Extractor.

commit 0c97fd659f24960a89ff3344b7f71be9e70f1d28
AuthorDate: Sun May 30 20:39:18 2021 +0200

    JSON Extractor and JSON JMESPath Extractor ignore sub-samples
    
    The UI for those elements suggest, that the extractors would
    look into sub-samples for matches (or even could be configured
    to use only values from the sub-samples). Adapt the implementation
    to make that assumption true.
    
    Bugzilla Id: 65269
---
 .../extractor/json/jmespath/JMESPathExtractor.java | 48 +++++++-----
 .../extractor/json/jsonpath/JSONPostProcessor.java | 27 ++++---
 .../jmeter/extractor/TestJSONPostProcessor.java    | 88 +++++++++++++++++++---
 .../json/jmespath/TestJMESPathExtractor.java       | 73 ++++++++++++++++++
 xdocs/changes.xml                                  |  1 +
 xdocs/usermanual/component_reference.xml           | 21 ++++--
 6 files changed, 213 insertions(+), 45 deletions(-)
Comment 3 eR@SeR 2021-06-03 10:45:28 UTC
(In reply to Felix Schumacher from comment #2)
> @Nikola, could you test next nightly or build from trunk and report back, if
> it fixes your problem?
Hi Felix,

I checked using provided example and real test plan using JSON path and it is fixed. Works as expected. Thank you.

> Note, I haven't changed Boundary Extractor.
OK. Will it be changed maybe?

Jmeter 5.5 0c97fd6
Microsoft Windows 10 Enterprise 64-bit
java version "15.0.1" 2020-10-20
Comment 4 Felix Schumacher 2021-06-03 16:00:16 UTC
Thanks for confirming the fix.

The boundary extractor will get its own bug report :)
Comment 5 Felix Schumacher 2021-06-03 16:09:17 UTC
The bug id for the boundary extractor is https://bz.apache.org/bugzilla/show_bug.cgi?id=65352
Comment 6 Felix Schumacher 2021-06-09 16:18:19 UTC
commit 75375c0f163894bffb2bd70e62632694acdf4110
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Wed Jun 9 18:09:20 2021 +0200

    Skip empty extracted results on JSON Extractor and JSON JMESPath Extractor
    
    With the addition of more than one result for sub-samples, the extracted
    results can be empty. Those empty results have to be filtered away, or
    we get warnings in the logs.
    
    Part of Bugzilla Id: 65269
---
 .../extractor/json/jmespath/JMESPathExtractor.java |  1 +
 .../extractor/json/jsonpath/JSONPostProcessor.java |  2 ++
 .../jmeter/extractor/TestJSONPostProcessor.java    | 22 ++++++++++++++++++++++
 .../json/jmespath/TestJMESPathExtractor.java       | 14 ++++++++++++++
 4 files changed, 39 insertions(+)
Comment 7 The ASF infrastructure team 2022-09-24 20:38:22 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5525