Reputation: 59
My team needs to add load testing for our GraphQL API, and we decided to use JMeter because it is supported by Azure Load Testing.
We have several graphql files that define queries like this:
request.graphql
query Foo($id: Long!) {
name
time
}
With corresponding test.json files used for unit testing that defines the query name, variables for the request, and an assert that contains the expected response from our API
request.test.json
[
{
"Query": "Foo",
"Variables": {
"id": 001
},
"Assert": {
"name": "bar",
"time": "01/01/1999"
}
}
]
We have dozens of these unit tests that we want to use for load testing our API using JMeter. How would we dynamically load our queries, variables, and assertions using JMeter, and load that into Azure Load Testing?
This is currently my very basic test plan with one graphql HTTP request. I want to avoid manually adding every single query, so that the queries in load tests get updated when a graphql and test.json file gets changed for our API.
Upvotes: 0
Views: 116
Reputation: 168002
Take a look at:
The idea is to point the Directory Listing Config to the folder where your files containing GraphQL queries live. It will pick up the next file on each iteration of each virtual user and return the path to the file.
Then you can read the content of your file using the aforementioned __FileToString() function directly in the sampler's body:
Upvotes: 0