-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Close nodes properly in Coordinator tests #44967
Close nodes properly in Coordinator tests #44967
Conversation
Today closing a `ClusterNode` in an `AbstractCoordinatorTestCase` uses `onNode()` so has no effect if the node is not in the current list of nodes. It also discards the `Runnable` it creates without having run it, so has no effect anyway. This commit makes these tests much stricter about properly closing the nodes started during `Coordinator` tests, by tracking the persisted states that are opened, and adds an assertion to catch the trappy requirement that the closing node still belongs to the cluster.
I strongly recommend looking at this with whitespace changes hidden. Rather than +1007/-901 it's more like +175/-69. |
coordinator.stop(); | ||
clusterService.stop(); | ||
//transportService.stop(); // does blocking stuff :/ | ||
clusterService.close(); | ||
coordinator.close(); | ||
//transportService.close(); // does blocking stuff :/ | ||
}); | ||
}).run(); |
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.
oops 👿
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
final Cluster cluster = new Cluster(randomIntBetween(2, 5)); // 1-node cluster doesn't do any serialization | ||
cluster.runRandomly(); | ||
cluster.stabilise(); | ||
try (Cluster cluster = new Cluster(randomIntBetween(2, 5))) { // 1-node cluster doesn't do any serialization |
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.
this is not true anymore. Perhaps we should amend this test.
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.
Good point, this is fine for 1-node clusters too now. Addressed in 92a02b7.
Today closing a `ClusterNode` in an `AbstractCoordinatorTestCase` uses `onNode()` so has no effect if the node is not in the current list of nodes. It also discards the `Runnable` it creates without having run it, so has no effect anyway. This commit makes these tests much stricter about properly closing the nodes started during `Coordinator` tests, by tracking the persisted states that are opened, and adds an assertion to catch the trappy requirement that the closing node still belongs to the cluster.
Today closing a `ClusterNode` in an `AbstractCoordinatorTestCase` uses `onNode()` so has no effect if the node is not in the current list of nodes. It also discards the `Runnable` it creates without having run it, so has no effect anyway. This commit makes these tests much stricter about properly closing the nodes started during `Coordinator` tests, by tracking the persisted states that are opened, and adds an assertion to catch the trappy requirement that the closing node still belongs to the cluster.
Today closing a
ClusterNode
in anAbstractCoordinatorTestCase
usesonNode()
so has no effect if the node is not in the current list of nodes.It also discards the
Runnable
it creates without having run it, so has noeffect anyway.
This commit makes these tests much stricter about properly closing the nodes
started during
Coordinator
tests, by tracking the persisted states that areopened, and adds an assertion to catch the trappy requirement that the closing
node still belongs to the cluster.