checkly / public-roadmap

Checkly public roadmap. All planned features, updates and tweaks.
https://checklyhq.com
37 stars 7 forks source link

One API Check with Dynamic Parameters #187

Open walidrohiman opened 2 years ago

walidrohiman commented 2 years ago

💡 For general support requests and bug reports, please go to checklyhq.com/support

Is your feature request related to a problem? Please describe. Configuring one API Check with dynamic parameters

Describe the solution you'd like Be able to configure 1 API Check with different parameters, for example, having 1 API check that will run 20 times with 20 different values as parameter generating 20 different check results instead of configuring 20 different API Checks. The 20 different parameters values can be stored in a list, then the API check can loop in the list to generate 20 different results.

Describe alternatives you've considered

Additional context

alexnoyes commented 2 years ago

Hi @walidrohiman

This can already be achieved today with the use of setup scripts. https://www.checklyhq.com/docs/api-checks/setup-teardown-scripts/

Something like this would do the trick, however, probability has no memory, so you cannot guarantee you won't hit a different query string entry every time...

// define the array
const cars = ["Saab", "Volvo", "BMW", "Ford", "Volkswagen", "Toyota"];

// randomise the array and assign to variable 
var random = cars[Math.floor(Math.random()*cars.length)];

// add the token as a query parameters
request.queryParameters['manufacturer'] = random

You could even add faker.js into the mix, if you wanted to take randomisation to the next level. https://github.com/checkly/public-roadmap/issues/138 - https://www.npmjs.com/package/faker/v/5.5.3

This however, assumes you are hitting the API monitor as per your schedule and not running 20 different calls one after the other from within the script itself.

Cheers, Alex

walidrohiman commented 2 years ago

Hey Alex thanks for your comment.

But is there any way where I can configure the API check to trigger 20 different calls one after the other, to generate 20 results with the 20 different parameters, instead of having only a random result from the 20 values ?

Thanks Walid

tnolet commented 2 years ago

@walidrohiman thanks for reporting and @alexnoyes thanks for responding. I think I understand the problem and there is no real way to do exactly that what you describe:

  1. 20 parallel checks
  2. all generated from a specific data set

This is however an interesting case that could work with some basic primitives that we are investigating.

  1. Allow checks to run in parallel, instead of round robin as we do right now.
  2. Allow checks to be created from code. You could write a loop and have that generate the checks for you.

Alternatively, you could set some state in a 3rd party system (maybe an S3 bucket) that would inform the "loop" on which iteration it is. You would create a 1 minute API check with the setup script. It would fetch the state from S3 and based on that create the API checks parameters in the setup script.