Skip to content

Conversation

ldematte
Copy link
Contributor

@ldematte ldematte commented Feb 7, 2025

This PR adds a test to ensure that backports with a transport version change address this correctly, by creating a new transport version in the target branch.

@ldematte ldematte added >test Issues or PRs that are addressing/adding tests :Core/Infra/Transport API Transport client API v9.0.1 labels Feb 7, 2025
@ldematte ldematte requested a review from a team February 7, 2025 11:10
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Feb 7, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@thecoop
Copy link
Member

thecoop commented Feb 7, 2025

Could this be made generic to the branch it is on? Maybe using information in the version lookup csv? Then it can be backported to all extant branches

@ldematte
Copy link
Contributor Author

ldematte commented Feb 7, 2025

Could this be made generic to the branch it is on? Maybe using information in the version lookup csv? Then it can be backported to all extant branches

Isn't that self-fulfilling? AFAIK the version lookup csv is generated from TransportVersions, so adding a new version will add the entry to the CSV file? (or does this happen only during the release process, so it's guaranteed the file is "frozen"?)

@rjernst
Copy link
Member

rjernst commented Feb 7, 2025

or does this happen only during the release process

When we tag the git commit for the release, we add the mapping to the csv. For the current release, we use the current build version. But I'm not sure it will help here since we need to know the "base" version for the branch.

I think the assertion you want is "is the latest version a patch of the one this branch started with". Here you hardcode the first 9.0 constant. I don't know how we could do that without explicitly marking the constant (eg similar to min compat constant), but if we had such a constant, the test could rely on it.

*/
public void testMaximumAllowedTransportVersion() {
assertThat(
TransportVersions.LATEST_DEFINED.onOrBefore(TransportVersions.ELASTICSEARCH_9_0)
Copy link
Member

Choose a reason for hiding this comment

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

What is this check achieving? The latest will never be before a known transport constant, and if it would only be equal if there are no patches yet, but isPatchFrom would return true in that case anyways, so I think this is redundant.

@mark-vieira
Copy link
Contributor

I think the assertion you want is "is the latest version a patch of the one this branch started with". Here you hardcode the first 9.0 constant. I don't know how we could do that without explicitly marking the constant (eg similar to min compat constant), but if we had such a constant, the test could rely on it.

That wouldn't have caught the issue with 9.0 though, because it's not yet a released version, therefore no such entry in the CSV would exit, right?

@mark-vieira
Copy link
Contributor

I struggle to see how we can implement such a check in a way that relies only on inferences drawn from information in the current branch. It seems to me that by definition, a messed up backport, requires some information about forward branches. That doesn't rule out us implementing such a safeguard, but I don't think a standalone unit test in any given branch will provide us the safety we're looking for here.

@rjernst
Copy link
Member

rjernst commented Feb 7, 2025

If we knew the current branch was a release branch, then I think the check here will work. The intent is to ensure any new versions added are patches. If we "stash" the transport version at branching time (or, as we will soon do, create a new transport version at branching) as a constant similar to min compat version, then we can assert, as this test does, that the latest version is a patch of that stashed version.

I do agree that it's not complete, in that someone could still incorrectly add an earlier transport version. For that, having a cross branch check would be great, to validate the other views of what transport versions exist don't conflict with what we have locally.

@mark-vieira
Copy link
Contributor

If we knew the current branch was a release branch, then I think the check here will work.

Right. And we do know this. Essentially if the current version number doesn't end with 0 we know it's a bugfix branch and therefore a patch to an existing released minor.

@rjernst
Copy link
Member

rjernst commented Feb 8, 2025

Essentially if the current version number doesn't end with 0

We might also have patches before the first .0 is released, like we do not with 9.0.0.

@mark-vieira
Copy link
Contributor

mark-vieira commented Feb 8, 2025 via email

@ldematte
Copy link
Contributor Author

That wouldn't have caught the issue with 9.0 though, because it's not yet a released version, therefore no such entry in the CSV would exit, right?

I have the same feeling, that the information on the CSV is not "right" for this case.

If we "stash" the transport version at branching time (or, as we will soon do, create a new transport version at branching) as a constant similar to min compat version, then we can assert, as this test does, that the latest version is a patch of that stashed version.

++
Basically, we need to "tag" the constant that is hardcoded here in this test.
My proposal here: let me do this manually for 9.0, 8.18, 8.19, let's figure out how to do that and then implement as a follow-up. Wdyt?

@rjernst
Copy link
Member

rjernst commented Feb 10, 2025

My proposal here: let me do this manually for 9.0, 8.18, 8.19

SGTM, let's protect these immediately, and figure out as a followup how to ensure we don't need to keep changing the test on each new release branch creation.

Copy link
Member

@rjernst rjernst 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 the caveat of the redundancy I noted earlier.

@ldematte ldematte merged commit 546d184 into elastic:9.0 Feb 11, 2025
16 checks passed
@ldematte ldematte deleted the max-transport-version-test branch February 11, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Transport API Transport client API Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v9.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants