Fail at generating Command sequences less often #633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://gist.github.com/jonaskoelker/ac60ded3a310b8f0fb548a1eda9f8859 and https://gist.github.com/jonaskoelker/b4a1d00a3da97c6d56e7b3d8fee02716.
Without this change, the
BoundedQueueSpec
would fail at command generation unless you added.retryUntil(cmd => cmd.preCondition(state))
to the end ofgenCommand
. With this change, command generation no longer fails.I found one semi-related discussion at #568. However that issue gets resolved, I don't think that has any bearing on whether retrying in a Commands context is a good idea or not: while it's reasonable to expect
listOfN
to satisfy some sensible properties (e.g.listOfN(1, g)
fails with the same probability asg
, and I supposelistOfN(k, g)
succeeds with probabilityp^k
wherep
is the success probability ofg
), I would prefer the thing-similar-to-listOfN done inCommands
to be more concerned about convenience in the form of a high success rate and dealing with the sequential data dependency due to state threading through a sequence of commands.I can think of one argument against doing this: the user can always add
.retryUntil(cmd => cmd.preCondition(state))
themselves, but why not scrap that boilerplate for them? It's not obvious to me what the existing code does better.I picked the number
100
somewhat arbitrarily: I guess (without having measured) that it's large enough to paper over most practically occurring generation failures and small enough to not be a performance nuisance if some generator always fails.