-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[Zen2] Randomized testing of CoordinationState #32242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pinging @elastic/es-distributed |
ping @DaveCTurner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I asked for a couple of tiny changes, but definitely no need for a review.
Seems to reliably achieve at least a handful of commits during the run, which is enouraging for coverage. I've run thousands of repeats without failing an assertion, so maybe the maths works!
} | ||
} | ||
|
||
// check system invariants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It caught me out that this can happen outside the loop, but on closer inspection the invariants checked are both monotonic so it's sufficient to check them at the end. I think this is worth a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, fixed in 711447b
@@ -752,6 +759,11 @@ public void testVoteCollection() { | |||
}); | |||
} | |||
|
|||
public void testSafety() { | |||
Cluster cluster = new Cluster(randomIntBetween(1, 5)); | |||
cluster.runRandomly(10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ suggests to inline this constant, and while I'm here I suggest to inline cluster
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 711447b
throw new CoordinationStateRejectedException("node not available"); | ||
} else { | ||
final Object payload = message.payload; | ||
if (payload instanceof StartJoinRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay for dynamic dispatching ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
Simulates a random run of a cluster with multiple CoordinationState instances (each representing one node), passing messages back and forth, and asserting that the overall system satisfies a given set of safety properties.
Follow-up to #32171