Skip to content

Conversation

@nielsbauman
Copy link
Contributor

As preparation for running the cluster state API on the local node, we need to update these tests that currently depend on that API running on (and waiting for) the master node.

Relates #127212

As preparation for running the cluster state API on the local node, we
need to update these tests that currently depend on that API running on
(and waiting for) the master node.

Relates elastic#127212
@nielsbauman nielsbauman requested a review from DaveCTurner June 7, 2025 17:54
@nielsbauman nielsbauman added >test Issues or PRs that are addressing/adding tests Team:Distributed Coordination Meta label for Distributed Coordination team v9.1.0 :Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. labels Jun 7, 2025
@elasticsearchmachine
Copy link
Collaborator

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

}

/**
* Waits for all nodes in the cluster to have a consistent view of which node is currently the master.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A "consistent view" is maybe not the right phrasing as it's not technically consistent (i.e. other cluster states can come in after that moment), but I couldn't come up with a better phrasing. Suggestions are welcome.

);
entries.add(new NamedWriteableRegistry.Entry(NamedDiff.class, ModelRegistryMetadata.TYPE, ModelRegistryMetadata::readDiffFrom));

doEnsureClusterStateConsistency(new NamedWriteableRegistry(entries));
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I'd forgotten that these tests explicitly customize this method. I'd like to get some opinion from the ML team about whether they think this stuff is all adequately covered elsewhere before just removing it like this.

We could instead make doEnsureClusterStateConsistency just pick any of the states it observes as the "master" state - there's no real need for it to have come from the actual master. Since an external test cluster only has one client, it's not really checking consistency across the cluster any more with this change but it is at least checking that it round-trips through its wire representation faithfully. I suspect there's value in such a test, given that all this ML-specific customization relates to named writeables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is at least checking that it round-trips through its wire representation faithfully

Since we're only able to obtain one cluster state (i.e. the one from the single client the external test cluster exposes), what "round trip" would we be testing exactly? We can check the "one way trip" of serializing the cluster state to XContent, but we don't have any other cluster state to compare it to. We could parse the XContent back to a cluster state, but this doesn't feel like the right place to test cluster state SerDer. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

org.elasticsearch.test.ESIntegTestCase#doEnsureClusterStateConsistency round-trips the state through its transport representation again - see the calls to ClusterState.Builder.toBytes and ClusterState.Builder.fromBytes therein.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some round-trip assertion logic to MlINativeIntegTestCase. I put it there instead of EsIntegTestCase as that is the only usage of ExternalTestCluster (and no new usages should be created as it's deprecated), so we avoid some complexity in EsIntegTestCase. Let me know what you think.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@nielsbauman nielsbauman enabled auto-merge (squash) June 16, 2025 12:52
@nielsbauman nielsbauman merged commit 19a4ed0 into elastic:main Jun 16, 2025
17 of 18 checks passed
@nielsbauman nielsbauman deleted the cs-master-dep branch June 16, 2025 14:04
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Jul 10, 2025
Nodes that are not publish quorum may not have applied the latest update
when awaitMasterNode returns. This PR fixes it by waiting for the
desired number of nodes.

Relates: elastic#129118
Resolves: elastic#130883
elasticsearchmachine pushed a commit that referenced this pull request Jul 10, 2025
The original cluster should be properly formed before the tests kick
off. This PR ensures that.

Relates: #129118 Resolves: #130883 Resolves: #130979
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
The original cluster should be properly formed before the tests kick
off. This PR ensures that.

Relates: elastic#129118 Resolves: elastic#130883 Resolves: elastic#130979
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 17, 2025
The original cluster should be properly formed before the tests kick
off. This PR ensures that.

Relates: elastic#129118 Resolves: elastic#130883 Resolves: elastic#130979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. Team:Distributed Coordination Meta label for Distributed Coordination team >test Issues or PRs that are addressing/adding tests v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants