Skip to content

ESQL: Impersonate an old client in upgrade tests#107497

Closed
nik9000 wants to merge 3 commits intoelastic:mainfrom
nik9000:esql_old_client_if_mixed
Closed

ESQL: Impersonate an old client in upgrade tests#107497
nik9000 wants to merge 3 commits intoelastic:mainfrom
nik9000:esql_old_client_if_mixed

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Apr 15, 2024

In the ESQL quests for upgrading from older versions of Elasticsearch this will pretend to be and old version of the elasticsearch client and not send a version in the body. Old clients will instead default to the first version of ESQL. This should allow us to run these tests even when version is required.

Tests against newer versions of Elasticsearch will then specify a version.

In the ESQL quests for upgrading from older versions of Elasticsearch
this will pretend to be and old version of the elasticsearch client and
not send a `version` in the body. Old clients will instead default to
the first version of ESQL. This should allow us to run these tests even
when `version` is required.

Tests against newer versions of Elasticsearch will then specify a
`version`.
return result;
}

private static ExecutableSection modifyExecutableSection(ExecutableSection e) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Remove version from all esql requests if we're running against before 8.14

}

@Override
protected ClientYamlTestClient initClientYamlTestClient(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Send the old client signature if we're before 8.14.

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Apr 15, 2024

run elasticsearch-ci/part-2

Copy link
Copy Markdown
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

This is great, thanks @nik9000 .

Only nit is that I think the yaml tests should also run against the snapshot version, otherwise we never know if a change in snapshot invalidates an existing test.

This shouldn't hold this up, though, I'll try to address this in #107433.

esql.query:
body:
query: 'FROM test | sort emp_no | eval ip = to_ip(coalesce(ip1.keyword, "255.255.255.255")) | keep emp_no, ip'
version: 2024.04.01
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm, maybe the version should be randomized once there's multiple versions?

This is okay, but in #107433 I added the version programmatically, which may be the better approach to deal with this (or not, if we're okay with the yaml tests not applying to snapshot and later versions).


// Versions on and after 8.14 will get a `version` parameter
def versionUnsupported = bwcVersion -> {
return bwcVersion.before(Version.fromString("8.14.0"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could be 8.13.3, so that once 8.13.3 is released, we at least run tests against mixed clusters with 8.13.3 nodes the intended way.

public RequestObjectBuilder build() throws IOException {
if (isBuilt == false) {
if (version != null) {
builder.field("version", version);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: that's a much better solution than my previous approach.

Comment on lines +128 to +131
if ("false".equals(System.getProperty("tests.version_parameter_unsupported"))) {
EsqlVersion version = randomFrom(EsqlSpecTestCase.VERSIONS);
this.version = randomBoolean() ? version.toString() : version.versionStringWithoutEmoji();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: would move that out of the builder and into the actual test logic; could be confusing that the builder relies on global state in the constructor.

Comment on lines +78 to +81
for (Map<String, Object> body : doSection.getApiCallSection().getBodies()) {
body.remove("version");
// TODO if the version isn't the earliest we should skip the test - ES isn't going to support it.
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is cool, thanks!

@alex-spies
Copy link
Copy Markdown
Contributor

Update: since my PR already touches all YAML tests, I cherry-picked this into my PR here.

The difference is that my PR sets the version programmatically rather than pinning it in each individual YAML test.

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Apr 23, 2024

This was incorporated into another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants