Skip to content

Commit

Permalink
TransportClusterState - Changed the assert expectation to include for…
Browse files Browse the repository at this point in the history
… case where the local node has the latest cluster-state
  • Loading branch information
rajiv-kv committed Mar 11, 2024
1 parent aff33ff commit 75c82c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ protected void clusterManagerOperation(
? clusterState -> true
: clusterState -> clusterState.metadata().version() >= request.waitForMetadataVersion();

// action will be executed on local node, if either the request is local only (or) the local node has the same cluster-state as
// ClusterManager
final Predicate<ClusterState> acceptableClusterStateOrNotMasterPredicate = request.local()
? acceptableClusterStatePredicate
: acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedClusterManager() == false);
|| !state.nodes().isLocalNodeElectedClusterManager()
? acceptableClusterStatePredicate
: acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedClusterManager() == false);

if (acceptableClusterStatePredicate.test(state)) {
ActionListener.completeWith(listener, () -> buildResponse(request, state));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ public void testTermCheckNoMatchWithClusterManager() throws ExecutionException,
CapturingTransport.CapturedRequest termCheckRequest = transport.capturedRequests()[0];
assertTrue(termCheckRequest.node.isClusterManagerNode());
assertThat(termCheckRequest.action, equalTo("cluster:monitor/term"));
GetTermVersionResponse termVersionResponse = new GetTermVersionResponse(
GetTermVersionResponse noMatchResponse = new GetTermVersionResponse(
new ClusterStateTermVersion(
clusterService.state().getClusterName(),
clusterService.state().stateUUID(),
clusterService.state().metadata().clusterUUID(),
clusterService.state().term(),
clusterService.state().version() - 1
)
);
transport.handleResponse(termCheckRequest.requestId, termVersionResponse);
transport.handleResponse(termCheckRequest.requestId, noMatchResponse);
assertFalse(listener.isDone());

assertThat(transport.capturedRequests().length, equalTo(2));
Expand Down

0 comments on commit 75c82c9

Please sign in to comment.