Limit the maximum number of values reuse in consume
#4085
Labels
enhancement
it's not broken, but we want it to be better
consume
#4085
Context & Description
I have a use case in Schemathesis where I'd like to reuse the same bundle value up to N times in a single state machine execution. The context is that stateful tests in Schemathesis make "linked" API calls and I'd like to reduce the number of API calls that seemingly do not provide much usefulness but consume the test budget.
At the moment there are a few options:
consume
. This is the status quo and from what I observe, state machines tend to overuse the same value. For example, Schemathesis makes a POST call and creates a new resource, then the same resource is used in way too many same calls, e.g. in 10 consecutive DELETE calls. For this use case, 2 DELETE calls will be useful (to detect use after free), but 10 is likely not.consume
. In this case, it becomes problematic to detect use after free, as there is no way to use the same value from a bundle and make e.g. 2 DELETE calls or DELETE -> GETNote that this tends to happen more in the early state machine executions, then, the sequences become more diverse. However, as each transition involves an API call, the cost of each transition is quite high (I observed responses with an average latency of 0.8-1s in one of the APIs I work with), therefore I'd like to avoid making unnecessary calls.
Proposed solution
Support "counting"
consume
, which will track the number of usages per value in a bundle and remove it only after the limit is reached.The API could be like this:
Let me know what you think about the approach and if any easier ways could achieve the main goal of reducing the number of undesired transitions (looks like implementing preconditions manually could be somewhat more complicated).
The text was updated successfully, but these errors were encountered: