Skip to content
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

Get node ID from nodes info in REST tests #40052

Conversation

DaveCTurner
Copy link
Contributor

@DaveCTurner DaveCTurner commented Mar 14, 2019

We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that try to identify the master
node. Today they call GET /_cluster/state API and extract the master node ID
from the response. In fact many of these tests just want an arbitary node ID
(or perhaps a data node ID) so an alternative is to call GET _nodes or GET _nodes/data:true and obtain a node ID from the keys of the nodes map in the
response.

This change adds the ability for YAML-based REST tests to extract an arbitrary
key from a map so that they can obtain a node ID from the nodes info API
instead of using the master node ID from the cluster state API.

Relates #40047.

We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that need to identify the master
node. Today they call `GET /_cluster/state` API and extract the master node ID
from the response. An alternative that avoids the unstable cluster state API is
to call `GET _nodes/_master`: the master node ID is the unique key in the
`nodes` map in the response.

This change adds the ability for YAML-based REST tests to extract the unique
key of a singleton map so that they can obtain the master node ID from the
nodes info API instead of the cluster state API.
@DaveCTurner DaveCTurner added >enhancement WIP :Core/Infra/REST API REST infrastructure and utilities :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v8.0.0 v7.2.0 labels Mar 14, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@javanna
Copy link
Member

javanna commented Mar 15, 2019

Do we plan on removing the master node info from the cluster state output? I understand that cluster state is not a stable API but I wonder if/why we need to stop using it everywhere in our own tests? I would prefer if it could be replaced without adding new features to the yaml test runner I guess. cc @elastic/es-clients

@DaveCTurner
Copy link
Contributor Author

No, there's no plan to remove anything else from the output @javanna. This PR arose out of a recent discussion about some another breaking change to the cluster state API (see #40061) and grew into a need to identify any users of this API and if possible to migrate them to an API that we could guarantee to be stable.

As I see it, the choices for identifying the master node are either (a) carry on using the cluster state API, (b) add a whole new API endpoint just for this, or (c) adjust the test runner to support an alternative way to get the master node ID.

I looked a bit harder at how the tests were using the master node ID, and in many cases we're just using it as an easy way to get an arbitrary node ID, with no real interest in whether it's the master or not. For instance in the shrink/split tests we do the shrink/split on the master because there doesn't seem to be an easy way to pick another node ID, although really we should be picking an arbitrary data node and not the master at all. Perhaps that's the missing feature in the test runner?

@javanna
Copy link
Member

javanna commented Mar 18, 2019

Agreed, as far as I remember those tests just need any node. anybody @elastic/es-clients has a preference on how to move forward?

@DaveCTurner DaveCTurner removed the WIP label Mar 18, 2019
@DaveCTurner DaveCTurner changed the title Get master identity from nodes info in REST tests Get node ID from nodes info in REST tests Mar 18, 2019
@Mpdreamz
Copy link
Member

I quite like this feature. Can be used to make tests less rigid, I remember looking at other tests with @estolfo in the past that could have benefited from this as well. Can't recall the specific tests though.

@DaveCTurner DaveCTurner requested a review from javanna March 20, 2019 08:42
@DaveCTurner
Copy link
Contributor Author

Hearing no objections, and at least some support, I think we should proceed with this.

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM thanks @DaveCTurner . Shall we add a check that wherever we use the feature we also have a skip for it? We do it for other features in general to avoid breaking other runners tests without knowing.

@DaveCTurner
Copy link
Contributor Author

I do like your suggestion to fail tests if we use _arbitrary_key_ without having declared this feature, @javanna, but it looks like it involves an awful lot of plumbing to bring the declared features and the parsed path together into one place to perform this check. Perhaps I’m missing something? I could just look for the substring _arbitrary_key_ in the appropriate field of the SetSection perhaps? Could you take a look and see if you can find a better idea?

@javanna
Copy link
Member

javanna commented Mar 22, 2019

heya @DaveCTurner would it be possible to add the check to ClientYamlTestSuite#validateExecutableSections ? It should be similar to what we already have there, though this new feature is not just a feature of the do section like others, and this may complicate things. If it gets too complicated, I am fine with not performing this check.

@DaveCTurner DaveCTurner merged commit 7d2d140 into elastic:master Mar 27, 2019
@DaveCTurner DaveCTurner deleted the 2019-03-14-rest-tests-get-master-from-nodes-info branch March 27, 2019 15:19
@DaveCTurner
Copy link
Contributor Author

I'm declaring this to be too complicated. The trouble with adding it to validateExecutableSections is that it's hard to tell if we're using this feature in any of the SetSections in the test.

DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Mar 27, 2019
We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that try to identify the master
node. Today they call `GET /_cluster/state` API and extract the master node ID
from the response. In fact many of these tests just want an arbitary node ID
(or perhaps a data node ID) so an alternative is to call `GET _nodes` or `GET
_nodes/data:true` and obtain a node ID from the keys of the `nodes` map in the
response.

This change adds the ability for YAML-based REST tests to extract an arbitrary
key from a map so that they can obtain a node ID from the nodes info API
instead of using the master node ID from the cluster state API.

Relates elastic#40047.
DaveCTurner added a commit that referenced this pull request Mar 27, 2019
We discussed recently that the cluster state API should be considered
"internal" and therefore our usual cast-iron stability guarantees do not hold
for this API.

However, there are a good number of REST tests that try to identify the master
node. Today they call `GET /_cluster/state` API and extract the master node ID
from the response. In fact many of these tests just want an arbitary node ID
(or perhaps a data node ID) so an alternative is to call `GET _nodes` or `GET
_nodes/data:true` and obtain a node ID from the keys of the `nodes` map in the
response.

This change adds the ability for YAML-based REST tests to extract an arbitrary
key from a map so that they can obtain a node ID from the nodes info API
instead of using the master node ID from the cluster state API.

Relates #40047.
@colings86 colings86 added >test Issues or PRs that are addressing/adding tests and removed >enhancement labels Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. >test Issues or PRs that are addressing/adding tests v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants