jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [jmeter] woonsan opened a new pull request #660: bz65108: escape/unescape jmeter variable references
Date Tue, 13 Apr 2021 11:15:06 GMT

woonsan opened a new pull request #660:

   ## Description
   In GraphQL query/mutation variables, JMeter variables can be referenced.
   A JSON String value with a JMeter variable reference (e.g, `{ "var1":"${jm.var1}"}`) has
no problem as they are replaced at runtime without breaking any JSON spec, but a non-String
value with JMeter variable reference (e.g, `{ "nvar1":${jm.nvar1}}`) causes a problem because
it's not a valid JSON. We need to somehow allow to use JMeter variable references in non-String
JSON values.
   This PR provides a conceptually simple solution:
   - If there's any JMeter variable references in a non-String JSON value, then replace the
JMeter variable reference with a JSON Reference-like expression temporarily and parse it into
a JSON Object.
   - Before serializing the GraphQL variables JSON object to a string, restore the temporary
JSON Reference-like expression to the original JMeter variable references.
   That is,
   - Step 1: User input for GraphQL variables:
     "var1": "hello",
     "var2": ${user.count}
   - Step 2: Temporarily replace it with JSON Reference-like expressions:
     "var1": "hello",
     "var2": {"$ref":"jmeter#/nonStringVariables/user.count"}
   - Step 3: Parse the string into JSONObject
   - Step 4: Before serializing the JSONObject or its parent JSONObject, restore the JMeter
variable references from the serialized json string:
     "var1": "hello",
     "var2": ${user.count}
   ## Motivation and Context
   See Bugzilla Id: 65108 .
   Also see PR #651 .
   ## How Has This Been Tested?
   - Related unit test is updated.
   - You can also test the demo JMeter script at xdocs/demos/SimpleGraphQLTestPlan.jmx:
   # Run ApolloGraphQL starwars-server, an open-source demo Apollo GraphQL server.
   ./gradlew runGui
   # open the JMeter script
   # Start the test and verify the test result.
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   ## Checklist:
   - [x] My code follows the [code style][style-guide] of this project.
   - [ ] I have updated the documentation accordingly.

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:

View raw message