Skip to content

Add Cluster Coordination Serialisation Tests#142755

Merged
elasticsearchmachine merged 11 commits intoelastic:mainfrom
joshua-adams-1:spacetime-join-status
Mar 30, 2026
Merged

Add Cluster Coordination Serialisation Tests#142755
elasticsearchmachine merged 11 commits intoelastic:mainfrom
joshua-adams-1:spacetime-join-status

Conversation

@joshua-adams-1
Copy link
Copy Markdown
Contributor

MessagesTests contained a number of serialisation tests for various classes in cluster/coordination. This commit introduces individual serialisation tests for each of them to provide greater test coverage. It also introduces PublishRequestTests since PublishRequest only had a single unit test before

Replaces MessagesTests, which contains a single hashcode test for a
number of cluster/coordination classes, with individual serialisation
test suites with greater coverage
@joshua-adams-1 joshua-adams-1 self-assigned this Feb 20, 2026
@joshua-adams-1 joshua-adams-1 added >test Issues or PRs that are addressing/adding tests :Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. labels Feb 20, 2026
@joshua-adams-1
Copy link
Copy Markdown
Contributor Author

joshua-adams-1 commented Feb 25, 2026

As a note, these tests were added via LLM during spacetime, and since the tests heavily rely on randomisation, the newly added tests have been run a couple of thousand times to ensure there are no failure paths

@joshua-adams-1 joshua-adams-1 marked this pull request as ready for review February 25, 2026 12:08
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Feb 25, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Member

@pxsalehi pxsalehi left a comment

Choose a reason for hiding this comment

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

There are some inconsistencies and verbosity I guess due to this being LLM-generated. I've left a few suggestions but it would apply to the other classes too. Please address those before merging.

Comment on lines +34 to +36
DiscoveryNode sourceNode = create();
long term = randomNonNegativeLong();
long version = randomNonNegativeLong();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can probably just inline these in the call.

switch (field) {
case 0 -> sourceNode = randomValueOtherThan(sourceNode, DiscoveryNodeUtils::create);
case 1 -> term = randomValueOtherThan(term, ESTestCase::randomNonNegativeLong);
default -> version = randomValueOtherThan(version, ESTestCase::randomNonNegativeLong);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typically we leave default for the invalid case and throw an assertion.


public class DiscoveryNodeUtils {

public static DiscoveryNode create() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe instead call this randomDiscoveryNode() ?

DiscoveryNode masterCandidateNode = instance.getMasterCandidateNode();
long term = instance.getTerm();

int field = between(0, 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd prefer something like (w/ or w/o else):

if (randomBoolean()) {
  return new ...
}
return new ...

@joshua-adams-1 joshua-adams-1 added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This pull request restructures test coverage for Elasticsearch cluster coordination messages. Eight new wire-serialization test classes are introduced, each extending AbstractWireSerializingTestCase to validate serialization/deserialization for specific message types: ApplyCommitRequest, JoinRequest, Join, PreVoteRequest, PreVoteResponse, PublishResponse, PublishWithJoinResponse, and StartJoinRequest. A dedicated PublishRequestTests class validates PublishRequest behavior. The monolithic MessagesTests class, which previously tested multiple message types, is removed. A randomDiscoveryNode() utility method is added to DiscoveryNodeUtils in the test framework to support randomized test instance generation.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch spacetime-join-status
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

@elasticsearchmachine elasticsearchmachine merged commit f54fed2 into elastic:main Mar 30, 2026
37 checks passed
@joshua-adams-1 joshua-adams-1 deleted the spacetime-join-status branch March 30, 2026 13:34
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
`MessagesTests` contained a number of serialisation tests for various
classes in `cluster/coordination`. This commit introduces individual
serialisation tests for each of them to provide greater test coverage.
It also introduces `PublishRequestTests` since `PublishRequest` only had
a single unit test before
mouhc1ne pushed a commit to shmuelhanoch/elasticsearch that referenced this pull request Mar 31, 2026
`MessagesTests` contained a number of serialisation tests for various
classes in `cluster/coordination`. This commit introduces individual
serialisation tests for each of them to provide greater test coverage.
It also introduces `PublishRequestTests` since `PublishRequest` only had
a single unit test before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants