Skip to content

Commit

Permalink
ESQL: Stop sending version in tests (#108961)
Browse files Browse the repository at this point in the history
Now that `version` is no longer required anywhere we can stop sending it
in all of our tests.

Closes #108957
  • Loading branch information
nik9000 committed May 23, 2024
1 parent 05302f2 commit 23efbf0
Show file tree
Hide file tree
Showing 31 changed files with 9 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public class HeapAttackIT extends ESRestTestCase {

static volatile boolean SUITE_ABORTED = false;

private static String ESQL_VERSION = "2024.04.01";

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
Expand Down Expand Up @@ -156,7 +154,7 @@ private Response groupOnManyLongs(int count) throws IOException {
}

private StringBuilder makeManyLongs(int count) {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM manylongs\\n| EVAL i0 = a + b, i1 = b + i0");
for (int i = 2; i < count; i++) {
query.append(", i").append(i).append(" = i").append(i - 2).append(" + ").append(i - 1);
Expand Down Expand Up @@ -187,7 +185,7 @@ public void testHugeConcat() throws IOException {
}

private Response concat(int evals) throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM single | EVAL str = TO_STRING(a)");
for (int e = 0; e < evals; e++) {
query.append("\n| EVAL str=CONCAT(")
Expand Down Expand Up @@ -224,7 +222,7 @@ public void testHugeManyConcat() throws IOException {
* Tests that generate many moderately long strings.
*/
private Response manyConcat(int strings) throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM manylongs | EVAL str = CONCAT(");
query.append(
Arrays.stream(new String[] { "a", "b", "c", "d", "e" })
Expand Down Expand Up @@ -276,7 +274,7 @@ public void testTooManyEval() throws IOException {
}

private Response manyEval(int evalLines) throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM manylongs");
for (int e = 0; e < evalLines; e++) {
query.append("\n| EVAL ");
Expand Down Expand Up @@ -358,7 +356,7 @@ public void testFetchTooManyBigFields() throws IOException {
* Fetches documents containing 1000 fields which are {@code 1kb} each.
*/
private void fetchManyBigFields(int docs) throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM manybigfields | SORT f000 | LIMIT " + docs + "\"}");
Response response = query(query.toString(), "columns");
Map<?, ?> map = responseAsMap(response);
Expand Down Expand Up @@ -387,7 +385,7 @@ public void testAggTooManyMvLongs() throws IOException {
}

private Response aggMvLongs(int fields) throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM mv_longs | STATS MAX(f00) BY f00");
for (int f = 1; f < fields; f++) {
query.append(", f").append(String.format(Locale.ROOT, "%02d", f));
Expand All @@ -413,7 +411,7 @@ public void testFetchTooManyMvLongs() throws IOException {
}

private Response fetchMvLongs() throws IOException {
StringBuilder query = startQueryWithVersion(ESQL_VERSION);
StringBuilder query = startQuery();
query.append("FROM mv_longs\"}");
return query(query.toString(), "columns");
}
Expand Down Expand Up @@ -584,11 +582,9 @@ public void assertRequestBreakerEmpty() throws Exception {
});
}

private static StringBuilder startQueryWithVersion(String version) {
private static StringBuilder startQuery() {
StringBuilder query = new StringBuilder();
query.append("{\"version\":\"" + version + "\",");
query.append("\"query\":\"");

query.append("{\"query\":\"");
return query;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private Response runAsync(String user, String command) throws IOException {
}
XContentBuilder json = JsonXContent.contentBuilder();
json.startObject();
json.field("version", ESQL_VERSION);
json.field("query", command);
addRandomPragmas(json);
json.field("wait_for_completion_timeout", timeValueNanos(randomIntBetween(1, 1000)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import static org.hamcrest.Matchers.equalTo;

public class EsqlSecurityIT extends ESRestTestCase {
static String ESQL_VERSION = "2024.04.01.🚀";

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
Expand Down Expand Up @@ -355,7 +353,6 @@ protected Response runESQLCommand(String user, String command) throws IOExceptio
}
XContentBuilder json = JsonXContent.contentBuilder();
json.startObject();
json.field("version", ESQL_VERSION);
json.field("query", command);
addRandomPragmas(json);
json.endObject();
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugin/esql/qa/server/mixed-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,16 @@ def supportedVersion = bwcVersion -> {
return bwcVersion.onOrAfter(Version.fromString("8.11.0"));
}

// Versions on and after 8.14.0 will get a `version` parameter
def versionRequired = bwcVersion -> {
return bwcVersion == Version.fromString("8.14.0");
}

BuildParams.bwcVersions.withWireCompatible(supportedVersion) { bwcVersion, baseName ->
def javaRestTest = tasks.register("v${bwcVersion}#javaRestTest", StandaloneRestIntegTestTask) {
usesBwcDistribution(bwcVersion)
systemProperty("tests.old_cluster_version", bwcVersion)
systemProperty("tests.version_parameter_required", versionRequired(bwcVersion))
maxParallelForks = 1
}

def yamlRestTest = tasks.register("v${bwcVersion}#yamlRestTest", StandaloneRestIntegTestTask) {
usesBwcDistribution(bwcVersion)
systemProperty("tests.old_cluster_version", bwcVersion)
systemProperty("tests.version_parameter_required", versionRequired(bwcVersion))
testClassesDirs = sourceSets.yamlRestTest.output.classesDirs
classpath = sourceSets.yamlRestTest.runtimeClasspath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ public RequestObjectBuilder pragmas(Settings pragmas) throws IOException {

public RequestObjectBuilder build() throws IOException {
if (isBuilt == false) {
if ("true".equals(System.getProperty("tests.version_parameter_required"))) {
builder.field("version", "2024.04.01");
}
builder.endObject();
isBuilt = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public void testMissingQueryIsNotValid() throws IOException {
public void testPragmasOnlyValidOnSnapshot() throws IOException {
String json = """
{
"version": "2024.04.01",
"query": "ROW x = 1",
"pragma": {"foo": "bar"}
}
Expand All @@ -222,7 +221,6 @@ public void testPragmasOnlyValidOnSnapshot() throws IOException {
public void testTablesKeyword() throws IOException {
String json = """
{
"version": "2024.04.01",
"query": "ROW x = 1",
"tables": {"a": {"c:keyword": ["a", "b", null, 1, 2.0, ["c", "d"], false]}}
}
Expand Down Expand Up @@ -254,7 +252,6 @@ public void testTablesKeyword() throws IOException {
public void testTablesInteger() throws IOException {
String json = """
{
"version": "2024.04.01",
"query": "ROW x = 1",
"tables": {"a": {"c:integer": [1, 2, "3", null, [5, 6]]}}
}
Expand Down Expand Up @@ -283,7 +280,6 @@ public void testTablesInteger() throws IOException {
public void testTablesLong() throws IOException {
String json = """
{
"version": "2024.04.01",
"query": "ROW x = 1",
"tables": {"a": {"c:long": [1, 2, "3", null, [5, 6]]}}
}
Expand Down Expand Up @@ -312,7 +308,6 @@ public void testTablesLong() throws IOException {
public void testManyTables() throws IOException {
String json = """
{
"version": "2024.04.01",
"query": "ROW x = 1",
"tables": {
"t1": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import static org.hamcrest.Matchers.equalTo;

public class RemoteClusterSecurityEsqlIT extends AbstractRemoteClusterSecurityTestCase {
private static final String ESQL_VERSION = "2024.04.01";

private static final AtomicReference<Map<String, Object>> API_KEY_MAP_REF = new AtomicReference<>();
private static final AtomicReference<Map<String, Object>> REST_API_KEY_MAP_REF = new AtomicReference<>();
private static final AtomicBoolean SSL_ENABLED_REF = new AtomicBoolean();
Expand Down Expand Up @@ -767,7 +765,6 @@ protected Request esqlRequest(String command) throws IOException {
body.endObject();
}
}
body.field("version", ESQL_VERSION);
body.endObject();
Request request = new Request("POST", "_query");
request.setJsonEntity(org.elasticsearch.common.Strings.toString(body));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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

- match: { columns.0.name: "emp_no" }
- match: { columns.0.type: "long" }
Expand All @@ -42,8 +41,6 @@
esql.query:
body:
query: 'FROM test | sort emp_no | eval x1 = concat(ip1, ip2), x2 = coalesce(x1, "255.255.255.255"), x3 = to_ip(x2) | keep emp_no, x*'
version: 2024.04.01

- match: { columns.0.name: "emp_no" }
- match: { columns.0.type: "long" }
- match: { columns.1.name: "x1" }
Expand Down Expand Up @@ -111,7 +108,6 @@
esql.query:
body:
query: 'from index* metadata _index | limit 5 | sort _index desc'
version: 2024.04.01
- match: { columns.0.name: http.headers }
- match: { columns.0.type: unsupported }
- match: { columns.1.name: http.headers.location }
Expand Down Expand Up @@ -174,7 +170,6 @@
esql.query:
body:
query: 'from npe_single_value* | stats x = avg(field1) | limit 10'
version: 2024.04.01
- match: { columns.0.name: x }
- match: { columns.0.type: double }
- length: { values: 1 }
Expand All @@ -184,7 +179,6 @@
esql.query:
body:
query: 'from npe_single_value* | stats x = avg(field2) | limit 10'
version: 2024.04.01
- match: { columns.0.name: x }
- match: { columns.0.type: double }
- length: { values: 1 }
Expand All @@ -194,7 +188,6 @@
esql.query:
body:
query: 'from npe_single_value* | stats x = avg(field3) | limit 10'
version: 2024.04.01
- match: { columns.0.name: x }
- match: { columns.0.type: double }
- length: { values: 1 }
Expand Down Expand Up @@ -238,7 +231,6 @@
esql.query:
body:
query: 'from idx_with_date_ip_txt | where id == 1 | eval x = date_format(text, date), y = date_extract(text2, date), p = date_parse(text, "2024-03-14") | keep x, y, p | limit 1'
version: 2024.04.01
- match: { columns.0.name: x }
- match: { columns.0.type: keyword }
- match: { columns.1.name: y }
Expand All @@ -252,7 +244,6 @@
esql.query:
body:
query: 'from idx_with_date_ip_txt | where id > 1 | eval x = cidr_match(ip, text) | sort id | keep id, x | limit 2'
version: 2024.04.01
- match: { columns.0.name: id }
- match: { columns.0.type: long }
- match: { columns.1.name: x }
Expand Down Expand Up @@ -296,7 +287,6 @@
esql.query:
body:
query: 'from idx_with_multivalues | eval b = mv_dedupe(boolean), k = mv_dedupe(keyword), i = mv_dedupe(integer), l = mv_dedupe(long), d = mv_dedupe(double) | keep b, k, i, l, d | limit 1'
version: 2024.04.01
- match: { columns.0.name: b }
- match: { columns.0.type: boolean }
- match: { columns.1.name: k }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ setup:
esql.query:
body:
query: 'from test'
version: 2024.04.01

- match: {columns.0.name: "color"}
- match: {columns.0.type: "keyword"}
Expand All @@ -140,7 +139,6 @@ setup:
esql.query:
body:
query: 'from test | sort count | limit 1'
version: 2024.04.01

- match: {columns.1.name: "count"}
- match: {columns.1.type: "long"}
Expand All @@ -153,7 +151,6 @@ setup:
body:
query: 'from test | keep data | sort data | limit 2'
columnar: true
version: 2024.04.01

- match: {columns.0.name: "data"}
- match: {columns.0.type: "long"}
Expand All @@ -165,7 +162,6 @@ setup:
esql.query:
body:
query: 'from test | eval x = count + 7 | sort x | limit 1'
version: 2024.04.01

- match: {columns.0.name: "color"}
- match: {columns.1.name: "count"}
Expand All @@ -183,7 +179,6 @@ setup:
esql.query:
body:
query: 'from test | sort time | eval x = data + 1, y = data_d + count, z = x + y | keep data, x, y, z, time | limit 2'
version: 2024.04.01

- match: {columns.0.name: "data"}
- match: {columns.0.type: "long"}
Expand Down Expand Up @@ -214,7 +209,6 @@ setup:
body:
query: 'from test | sort time | limit 2 | keep count'
columnar: true
version: 2024.04.01

- length: {columns: 1}
- match: {columns.0.name: "count"}
Expand All @@ -228,7 +222,6 @@ setup:
body:
query: 'from test | sort time desc | limit 2 | keep count'
columnar: true
version: 2024.04.01

- length: {columns: 1}
- match: {columns.0.name: "count"}
Expand All @@ -242,7 +235,6 @@ setup:
body:
query: 'from test | sort time | limit 2 | keep count | eval x = count + 1'
columnar: true
version: 2024.04.01

- length: {columns: 2}
- match: {columns.0.name: "count"}
Expand All @@ -260,7 +252,6 @@ setup:
body:
query: 'from test | sort time | limit 2 | keep count | eval x = count + 1 | keep x'
columnar: true
version: 2024.04.01

- length: {columns: 1}
- match: {columns.0.name: "x"}
Expand All @@ -274,7 +265,6 @@ setup:
esql.query:
body:
query: 'from test | limit 10 | sort time | limit 1'
version: 2024.04.01

- length: {columns: 6}
- length: {values: 1}
Expand All @@ -288,7 +278,6 @@ setup:
body:
query: 'row a = ? | eval b = ?, c = 1 + ?'
params: ["foo", 15, 10]
version: 2024.04.01

- length: {columns: 3}
- match: {columns.0.name: "a"}
Expand All @@ -308,7 +297,6 @@ setup:
body:
query: 'from test | where color == ? and count == ? and time == ? | keep data, count, color'
params: ["green", 44, 1674835275193]
version: 2024.04.01

- length: {columns: 3}
- match: {columns.0.name: "data"}
Expand All @@ -327,7 +315,6 @@ setup:
body:
query: 'from test | eval x = ?, y = ?, z = ?, t = ?, u = ?, v = ? | keep x, y, z, t, u, v | limit 3'
params: [{"value": 1, "type": "keyword"}, {"value": 2, "type": "double"}, null, true, 123, {"value": 123, "type": "long"}]
version: 2024.04.01

- length: {columns: 6}
- match: {columns.0.name: "x"}
Expand Down
Loading

0 comments on commit 23efbf0

Please sign in to comment.