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

ESQL: Introduce language versioning to REST API #106824

Merged
merged 30 commits into from
Apr 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1f45d65
Add version enum
alex-spies Mar 27, 2024
c4d5a8e
Parse + validate esql.version
alex-spies Mar 27, 2024
26b9fe6
Add tests
alex-spies Mar 27, 2024
887759a
Refactor EsqlVersion.toString
alex-spies Mar 27, 2024
da6c0e1
Make checkstyle happy
alex-spies Mar 27, 2024
8e6de63
Avoid forbidden APIs
alex-spies Mar 27, 2024
98b816f
Use proper emojis
alex-spies Mar 28, 2024
d5bef79
Add disambiguation counter to version
alex-spies Mar 28, 2024
f0a2aae
Make parsing stricter
alex-spies Mar 28, 2024
9e97e43
Rename esql.version -> version
alex-spies Mar 28, 2024
11ba353
Update docs/changelog/106824.yaml
alex-spies Mar 28, 2024
a29fc71
Remove obsolete TODO
alex-spies Mar 28, 2024
85576a7
Spotless
alex-spies Mar 28, 2024
5920994
Refactor month and numberThisMonth
alex-spies Apr 2, 2024
a633632
Add validation tests for non-snapshot builds
alex-spies Apr 2, 2024
c8c9684
Merge remote-tracking branch 'upstream/main' into esql-version
alex-spies Apr 2, 2024
de6304e
Merge remote-tracking branch 'upstream/main' into esql-version
alex-spies Apr 2, 2024
be3f255
Use randomization to test both sync/async
alex-spies Apr 2, 2024
5b15c30
Add empty version string to test
alex-spies Apr 2, 2024
c6f06db
Address feedback
alex-spies Apr 3, 2024
eb795fb
Improve assertions
alex-spies Apr 3, 2024
8a9c0f8
Rename nightly -> snapshot
alex-spies Apr 3, 2024
0b5fb1f
Add latest version to error message when missing
alex-spies Apr 3, 2024
962f16b
Add latest version to error message if invalid
alex-spies Apr 3, 2024
3b7c031
Add latest version in error if using snapshot
alex-spies Apr 3, 2024
20118c6
Remove emoji from error message
alex-spies Apr 3, 2024
037f1f7
Throw IAE instead of AssertionError
alex-spies Apr 3, 2024
ab3be62
Use rocket emoji for first released version
alex-spies Apr 3, 2024
b181c7c
Merge remote-tracking branch 'upstream/main' into esql-version
alex-spies Apr 3, 2024
acb2703
Fix test
alex-spies Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename nightly -> snapshot
alex-spies committed Apr 3, 2024
commit 8a9c0f8148ee0aca468b5abde6ec2c9ba7f17ce5
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ public ActionRequestValidationException validate() {
"[" + RequestXContent.ESQL_VERSION_FIELD + "] has invalid value [" + esqlVersion + "]",
validationException
);
} else if (version == EsqlVersion.NIGHTLY && onSnapshotBuild == false) {
} else if (version == EsqlVersion.SNAPSHOT && onSnapshotBuild == false) {
validationException = addValidationError(
"[" + RequestXContent.ESQL_VERSION_FIELD + "] with value [" + esqlVersion + "] only allowed in snapshot builds",
validationException
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ public enum EsqlVersion implements VersionId<EsqlVersion> {
/**
* Breaking changes go here until the next version is released.
*/
NIGHTLY(Integer.MAX_VALUE, 12, 99, "😴"),
SNAPSHOT(Integer.MAX_VALUE, 12, 99, "📷"),
PARTY_POPPER(2024, 4, "🎉");

static final Map<String, EsqlVersion> VERSION_MAP_WITH_AND_WITHOUT_EMOJI = versionMapWithAndWithoutEmoji();
@@ -90,7 +90,7 @@ public static EsqlVersion parse(String versionString) {
}

public String versionStringWithoutEmoji() {
return this == NIGHTLY ? "nightly" : Strings.format("%d.%02d.%02d", year, month, revision);
return this == SNAPSHOT ? "snapshot" : Strings.format("%d.%02d.%02d", year, month, revision);
}

@Override
@@ -100,6 +100,6 @@ public String toString() {

@Override
public int id() {
return this == NIGHTLY ? Integer.MAX_VALUE : (10000 * year + 100 * month + revision);
return this == SNAPSHOT ? Integer.MAX_VALUE : (10000 * year + 100 * month + revision);
}
}
Original file line number Diff line number Diff line change
@@ -192,8 +192,8 @@ public void testUnknownVersionIsNotValid() throws IOException {
assertThat(request.validate().getMessage(), containsString("[version] has invalid value [" + invalidVersionString + "]"));
}

public void testNightlyVersionIsOnlyValidOnSnapshot() throws IOException {
String esqlVersion = randomBoolean() ? "nightly" : "nightly.😴";
public void testSnapshotVersionIsOnlyValidOnSnapshot() throws IOException {
String esqlVersion = randomBoolean() ? "snapshot" : "snapshot.📷";
String json = String.format(Locale.ROOT, """
{
"version": "%s",
@@ -232,7 +232,7 @@ public void testMissingQueryIsNotValid() throws IOException {
String json = """
{
"columnar": true,
"version": "nightly"
"version": "snapshot"
}""";
EsqlQueryRequest request = parseEsqlQueryRequest(json, randomBoolean());
assertNotNull(request.validate());
Original file line number Diff line number Diff line change
@@ -18,20 +18,20 @@

public class EsqlVersionTests extends ESTestCase {
public void testVersionString() {
assertThat(EsqlVersion.NIGHTLY.toString(), equalTo("nightly.😴"));
assertThat(EsqlVersion.SNAPSHOT.toString(), equalTo("snapshot.📷"));
assertThat(EsqlVersion.PARTY_POPPER.toString(), equalTo("2024.04.01.🎉"));
}

public void testVersionId() {
assertThat(EsqlVersion.NIGHTLY.id(), equalTo(Integer.MAX_VALUE));
assertThat(EsqlVersion.SNAPSHOT.id(), equalTo(Integer.MAX_VALUE));
assertThat(EsqlVersion.PARTY_POPPER.id(), equalTo(20240401));

for (EsqlVersion version : EsqlVersion.values()) {
assertTrue(EsqlVersion.NIGHTLY.onOrAfter(version));
if (version != EsqlVersion.NIGHTLY) {
assertTrue(version.before(EsqlVersion.NIGHTLY));
assertTrue(EsqlVersion.SNAPSHOT.onOrAfter(version));
if (version != EsqlVersion.SNAPSHOT) {
assertTrue(version.before(EsqlVersion.SNAPSHOT));
} else {
assertTrue(version.onOrAfter(EsqlVersion.NIGHTLY));
assertTrue(version.onOrAfter(EsqlVersion.SNAPSHOT));
}
}