Skip to content

Conversation

@DiannaHohensee
Copy link
Contributor

Closes ES-12633

@DiannaHohensee DiannaHohensee self-assigned this Sep 23, 2025
@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.2.0 labels Sep 23, 2025
@DiannaHohensee DiannaHohensee added :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) Team:Distributed Coordination Meta label for Distributed Coordination team >non-issue and removed needs:triage Requires assignment of a team area label labels Sep 23, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor cosmetic nits

Making utility methods for the repetitive set-up will keep the body of the test method focused on the behaviour being tested.

(handler, request, channel, task) -> channel.sendResponse(
new NodeUsageStatsForThreadPoolsAction.NodeResponse(harness.thirdDiscoveryNode, thirdNodeUtilHotSpottingNodeStats)
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this could be DRY'd, e.g.

mockNodeUsageStats(harness.thirdDiscoveryNode, thirdNodeUtilHotSpottingNodeStats)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, done! 93a133a

harness.thirdDataNodeName
);
channel.sendResponse(instance.new NodeResponse(harness.thirdDataNodeId, 0, List.of(), List.of()));
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this ^^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍 4978f5b & 3e5604e

Level.DEBUG,
"Desired balance computation for * is completed, scheduling reconciliation"
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this ? ^^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done 👍 9a5fe8d

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, perhaps you meant the whole MockLog.awaitLogger statement? It looks more concise with MockLog.SeenEventExpectation modularized. I think I prefer to see the actions that the test is taking -- refreshClusterInfo and updateClusterSettings -- so I left that alone.

(handler, request, channel, task) -> channel.sendResponse(
new NodeUsageStatsForThreadPoolsAction.NodeResponse(harness.thirdDiscoveryNode, thirdNodeNonHotSpottingNodeStats)
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY ☝️

harness.thirdDataNodeName
);
channel.sendResponse(instance.new NodeResponse(harness.thirdDataNodeId, 0, List.of(), List.of()));
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

Level.DEBUG,
"Desired balance updated for *"
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️

TimeValue.timeValueMillis(queueLatencyThresholdMillis)
)
// Essentially disable rebalancing so that testing can see Decider change outcomes.
.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 1000f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could you use EnableAllocationDecider#CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING to be more explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that looks better 👍 592cd08


if (logger.isTraceEnabled()) {
logger.trace(explanation);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think we need to wrap this in the conditional, log4j will do that immediately inside logger.trace(...). Explicit checks like this are only useful to avoid expensive pre-calculation or fetching that may be required for the log message. Here we're just passing in a string that already exists (i.e. zero cost).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, copy-paste for the fail 🙂 Fixed 👍 2fe4115

Copy link
Contributor Author

@DiannaHohensee DiannaHohensee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Good idea to modularize the transport action overrides, it looks better now.

(handler, request, channel, task) -> channel.sendResponse(
new NodeUsageStatsForThreadPoolsAction.NodeResponse(harness.thirdDiscoveryNode, thirdNodeUtilHotSpottingNodeStats)
)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, done! 93a133a

harness.thirdDataNodeName
);
channel.sendResponse(instance.new NodeResponse(harness.thirdDataNodeId, 0, List.of(), List.of()));
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍 4978f5b & 3e5604e

Level.DEBUG,
"Desired balance computation for * is completed, scheduling reconciliation"
)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done 👍 9a5fe8d

Level.DEBUG,
"Desired balance computation for * is completed, scheduling reconciliation"
)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, perhaps you meant the whole MockLog.awaitLogger statement? It looks more concise with MockLog.SeenEventExpectation modularized. I think I prefer to see the actions that the test is taking -- refreshClusterInfo and updateClusterSettings -- so I left that alone.

TimeValue.timeValueMillis(queueLatencyThresholdMillis)
)
// Essentially disable rebalancing so that testing can see Decider change outcomes.
.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 1000f)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that looks better 👍 592cd08


if (logger.isTraceEnabled()) {
logger.trace(explanation);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, copy-paste for the fail 🙂 Fixed 👍 2fe4115

@DiannaHohensee DiannaHohensee merged commit 9fb01e1 into elastic:main Oct 1, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants