We have an end point that uses azure functions to get the results. Sometimes we get the results almost instantly and sometimes we get the results after 10 s or 20 s.
I m wondering if there is a better way to test those endpoints using postman or do you use a different tool for testing the end points that relies on the durable functions.This solution works ok but is not reliable always.
statusCode = responseCode.code;
var result = JSON.parse(responseBody);
var maxNumberOfTries = 24;
var sleepBetweenTries = 5000;
if (!pm.environment.get("collection_tries")) {
pm.environment.set("collection_tries", 1);
}
console.log(result);
tests["Status code is 200"] = statusCode == environment["status_OK"];
if (result.abc.length == 0) {
if (pm.environment.get("collection_tries") <= maxNumberOfTries && statusCode == 200) {
var tries = parseInt(pm.environment.get("collection_tries"), 10);
pm.environment.set("collection_tries", tries + 1);
setTimeout(function () { }, sleepBetweenTries);
postman.setNextRequest(pm.info.requestId);
}
else {
pm.environment.unset("collection_tries");
console.log("Exceeded all attempts to check ABC");
tests["ABC exist"] = false;
}
} else {
pm.environment.unset("collection_tries");
tests["ABC exist"] = true;
var abcid = result._id;