ifesdjeen commented on code in PR #3459:
URL: https://github.com/apache/cassandra/pull/3459#discussion_r1716548771
##########
test/harry/main/org/apache/cassandra/harry/checker/ModelChecker.java:
##########
@@ -43,138 +45,173 @@ public ModelChecker()
public void run() throws Throwable
{
- run(Integer.MAX_VALUE, System.currentTimeMillis());
+ run(0, Long.MAX_VALUE, new JdkRandomEntropySource(88));
}
- public void run(int maxSteps, long seed) throws Throwable
+ public void run(int minSteps, long maxSteps) throws Throwable
{
+ run(minSteps, maxSteps, new JdkRandomEntropySource(88));
+ }
+
+ public void run(int minSteps, long maxSteps, EntropySource entropySource)
throws Throwable
+ {
+ assert exitCondition != null : "Exit condition is not specified";
assert init != null : "Initial condition is not specified";
- Ref<STATE> state = new Ref<>(init);
- EntropySource entropySource = new JdkRandomEntropySource(new
Random(seed));
+ Ref<Pair<STATE, SUT>> state = new Ref<>(init, Pair.unchanged());
if (beforeAll != null)
- beforeAll.accept(state.get());
+ state.map((s) -> beforeAll.next(s.l, s.r, entropySource));
for (int i = 0; i < maxSteps; i++)
{
- if (exitCondition != null && exitCondition.test(state.get()))
+ if (i > minSteps && exitCondition.test(state.get()))
return;
// TODO: add randomisation / probability for triggering a specific
step
steps.get(entropySource.nextInt(steps.size())).execute(state,
entropySource.derive());
- for (Precondition<STATE> invariant : invariants)
+ for (Precondition<STATE, SUT> invariant : invariants)
invariant.test(state.get());
}
if (afterAll != null)
- afterAll.accept(state.get());
+ state.map((s) -> beforeAll.next(s.l, s.r, entropySource));
Review Comment:
oh yes, thank you for spotting!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]