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: Stop sending version in tests (#108961) #108984

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -275,7 +273,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 @@ -357,7 +355,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 @@ -386,7 +384,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 @@ -412,7 +410,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 @@ -583,11 +581,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
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import static org.hamcrest.Matchers.equalTo;

public class RemoteClusterSecurityEsqlIT extends AbstractRemoteClusterSecurityTestCase {

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 @@ -690,9 +689,6 @@ protected Request esqlRequest(String command) throws IOException {
body.endObject();
}
}
// TODO: we should use the latest or a random version, even when new versions are released.
String version = Build.current().isSnapshot() ? "snapshot" : "2024.04.01";
body.field("version", 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
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ row wise and keep null:
body:
query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2'
columnar: false
version: 2024.04.01

- length: {columns: 8}
- match: {columns.0.name: "always_null"}
Expand Down Expand Up @@ -154,7 +153,6 @@ row wise and drop null:
body:
query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2'
columnar: false
version: 2024.04.01

- length: {all_columns: 8}
- match: {all_columns.0.name: "always_null"}
Expand Down Expand Up @@ -198,7 +196,6 @@ columnar and keep null:
body:
query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2'
columnar: true
version: 2024.04.01

- length: {columns: 8}
- match: {columns.0.name: "always_null"}
Expand Down Expand Up @@ -230,7 +227,6 @@ columnar and drop null:
body:
query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2'
columnar: true
version: 2024.04.01

- length: {all_columns: 8}
- match: {all_columns.0.name: "always_null"}
Expand Down
Loading