-
Notifications
You must be signed in to change notification settings - Fork 180
feat: otter test quiescence #21945
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
Merged
Merged
feat: otter test quiescence #21945
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3c2a36f
working so far
lpetrovic05 a957b0d
a bit more
lpetrovic05 9e47994
Merge branch 'main' into 21302-otter-test-quiescence
lpetrovic05 53eb753
found problem
lpetrovic05 5026b55
made progress
lpetrovic05 2e17f25
done
lpetrovic05 274907b
s
lpetrovic05 b758e23
Merge branch 'main' into 21302-otter-test-quiescence
lpetrovic05 fc9bd9a
PR comments
lpetrovic05 eccdaa1
s
lpetrovic05 13c9cb5
Merge branch 'main' into 21302-otter-test-quiescence
lpetrovic05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...orm-sdk/consensus-otter-tests/src/testOtter/java/org/hiero/otter/test/QuiescenceTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| package org.hiero.otter.test; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.hiero.otter.fixtures.OtterAssertions.assertContinuouslyThat; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
| import java.time.Duration; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import org.hiero.consensus.model.quiescence.QuiescenceCommand; | ||
| import org.hiero.otter.fixtures.Network; | ||
| import org.hiero.otter.fixtures.OtterTest; | ||
| import org.hiero.otter.fixtures.TestEnvironment; | ||
| import org.hiero.otter.fixtures.TimeManager; | ||
| import org.hiero.otter.fixtures.result.SingleNodeConsensusResult; | ||
|
|
||
| public class QuiescenceTest { | ||
|
|
||
| @OtterTest | ||
| void quiescenceTest(@NonNull final TestEnvironment env) { | ||
| final int numberOfNodes = 4; | ||
|
|
||
| final Network network = env.network(); | ||
| network.addNodes(numberOfNodes); | ||
| final TimeManager timeManager = env.timeManager(); | ||
|
|
||
| // Setup continuous assertions | ||
| assertContinuouslyThat(network.newLogResults()).haveNoErrorLevelMessages(); | ||
| assertContinuouslyThat(network.newReconnectResults()).doNotAttemptToReconnect(); | ||
| assertContinuouslyThat(network.newConsensusResults()) | ||
| .haveEqualCommonRounds() | ||
| .haveConsistentRounds(); | ||
| assertContinuouslyThat(network.newMarkerFileResults()).haveNoMarkerFiles(); | ||
|
|
||
| // Start the network and wait a bit | ||
| network.start(); | ||
| timeManager.waitForCondition( | ||
| () -> network.newConsensusResults().allNodesAdvancedToRound(20), Duration.ofSeconds(120L)); | ||
|
|
||
| // Send quiescence command to all nodes | ||
| network.nodes().forEach(node -> node.sendQuiescenceCommand(QuiescenceCommand.QUIESCE)); | ||
| // Wait to ensure everything in the network has settled, all created events have been gossiped and processed | ||
| timeManager.waitFor(Duration.ofSeconds(5)); | ||
|
|
||
| assertThat(network.newConsensusResults().results().stream() | ||
| .mapToLong(SingleNodeConsensusResult::lastRoundNum) | ||
| .distinct() | ||
| .count()) | ||
| .withFailMessage("All nodes should have the same last round when quiesced") | ||
| .isEqualTo(1); | ||
| final long lastRoundWhenQuiesced = | ||
| network.newConsensusResults().results().getFirst().lastRoundNum(); | ||
|
|
||
| timeManager.waitFor(Duration.ofSeconds(10)); | ||
poulok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Assert that consensus has not advanced | ||
| network.newConsensusResults().results().stream() | ||
| .mapToLong(SingleNodeConsensusResult::lastRoundNum) | ||
| .forEach(r -> assertThat(r) | ||
| .withFailMessage("No node should have advanced rounds while quiesced") | ||
| .isEqualTo(lastRoundWhenQuiesced)); | ||
|
|
||
| // Test the quiescence breaking command | ||
| // This should create a single event, which we will verify with a log statement | ||
| network.nodes().getFirst().sendQuiescenceCommand(QuiescenceCommand.BREAK_QUIESCENCE); | ||
|
|
||
| final AtomicBoolean foundQBlog = network.nodes() | ||
poulok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .getFirst() | ||
| .newLogResult() | ||
| .onNextMatch(logEntry -> logEntry.message().contains("Created quiescence breaking event")); | ||
|
|
||
| timeManager.waitForCondition( | ||
| foundQBlog::get, | ||
| Duration.ofSeconds(10), | ||
poulok marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "Could not find the log message indicating a quiescence breaking event was created"); | ||
|
|
||
| // Stop quiescing all nodes | ||
| network.nodes().forEach(node -> node.sendQuiescenceCommand(QuiescenceCommand.DONT_QUIESCE)); | ||
| // Wait for all nodes to advance at least 20 rounds beyond the quiescence round | ||
| timeManager.waitForCondition( | ||
| () -> network.newConsensusResults().allNodesAdvancedToRound(lastRoundWhenQuiesced + 20), | ||
| Duration.ofSeconds(120L)); | ||
| network.shutdown(); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.