Skip to content
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 @@ -27,7 +27,6 @@
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.junit.Before;
import org.junit.ClassRule;

Expand All @@ -40,6 +39,7 @@
import static org.elasticsearch.test.ListMatcher.matchesList;
import static org.elasticsearch.test.MapMatcher.assertMap;
import static org.elasticsearch.test.MapMatcher.matchesMap;
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -594,7 +594,7 @@ record Listen(long timestamp, String songId, double duration) {
public void testLookupJoinIndexAllowed() throws Exception {
assumeTrue(
"Requires LOOKUP JOIN capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
);

Response resp = runESQLCommand(
Expand Down Expand Up @@ -685,7 +685,7 @@ public void testLookupJoinIndexAllowed() throws Exception {
public void testLookupJoinDocLevelSecurity() throws Exception {
assumeTrue(
"Requires LOOKUP JOIN capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
);

Response resp = runESQLCommand("dls_user", "ROW x = 40.0 | EVAL value = x | LOOKUP JOIN lookup-user2 ON value | KEEP x, org");
Expand Down Expand Up @@ -734,7 +734,7 @@ public void testLookupJoinDocLevelSecurity() throws Exception {
public void testLookupJoinFieldLevelSecurity() throws Exception {
assumeTrue(
"Requires LOOKUP JOIN capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
);

Response resp = runESQLCommand("fls_user2", "ROW x = 40.0 | EVAL value = x | LOOKUP JOIN lookup-user2 ON value");
Expand Down Expand Up @@ -792,7 +792,7 @@ public void testLookupJoinFieldLevelSecurity() throws Exception {
public void testLookupJoinFieldLevelSecurityOnAlias() throws Exception {
assumeTrue(
"Requires LOOKUP JOIN capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
);

Response resp = runESQLCommand("fls_user2_alias", "ROW x = 40.0 | EVAL value = x | LOOKUP JOIN lookup-second-alias ON value");
Expand Down Expand Up @@ -850,7 +850,7 @@ public void testLookupJoinFieldLevelSecurityOnAlias() throws Exception {
public void testLookupJoinIndexForbidden() throws Exception {
assumeTrue(
"Requires LOOKUP JOIN capability",
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
);

var resp = expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.test.rest.TestFeatureService;
import org.elasticsearch.xpack.esql.CsvSpecReader.CsvTestCase;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.ClassRule;
Expand All @@ -22,6 +21,7 @@

import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;

public class MixedClusterEsqlSpecIT extends EsqlSpecTestCase {
@ClassRule
Expand All @@ -43,11 +43,6 @@ public void extractOldClusterFeatures() {
}
}

protected static boolean oldClusterHasFeature(String featureId) {
assert oldClusterTestFeatureService != null;
return oldClusterTestFeatureService.clusterHasFeature(featureId);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused.


@AfterClass
public static void cleanUp() {
oldClusterTestFeatureService = null;
Expand All @@ -59,10 +54,9 @@ public MixedClusterEsqlSpecIT(
String testName,
Integer lineNumber,
CsvTestCase testCase,
String instructions,
Mode mode
String instructions
) {
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode);
super(fileName, groupName, testName, lineNumber, testCase, instructions);
}

@Override
Expand All @@ -87,12 +81,12 @@ protected boolean supportsInferenceTestService() {
}

@Override
protected boolean supportsIndexModeLookup() throws IOException {
return hasCapabilities(List.of(JOIN_LOOKUP_V12.capabilityName()));
protected boolean supportsIndexModeLookup() {
return hasCapabilities(adminClient(), List.of(JOIN_LOOKUP_V12.capabilityName()));
}

@Override
protected boolean supportsSourceFieldMapping() throws IOException {
protected boolean supportsSourceFieldMapping() {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.elasticsearch.xpack.esql.CsvTestsDataLoader;
import org.elasticsearch.xpack.esql.SpecReader;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
Expand All @@ -36,7 +35,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
Expand All @@ -58,7 +56,7 @@
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode.SYNC;
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -86,19 +84,7 @@ public class MultiClusterSpecIT extends EsqlSpecTestCase {
public static List<Object[]> readScriptSpec() throws Exception {
List<URL> urls = classpathResources("/*.csv-spec");
assertTrue("Not enough specs found " + urls, urls.size() > 0);
List<Object[]> specs = SpecReader.readScriptSpec(urls, specParser());

int len = specs.get(0).length;
List<Object[]> testcases = new ArrayList<>();
for (var spec : specs) {
for (Mode mode : List.of(SYNC)) { // No async, for now
Object[] obj = new Object[len + 1];
System.arraycopy(spec, 0, obj, 0, len);
obj[len] = mode;
testcases.add(obj);
}
}
return testcases;
return SpecReader.readScriptSpec(urls, specParser());
}

public MultiClusterSpecIT(
Expand All @@ -107,10 +93,9 @@ public MultiClusterSpecIT(
String testName,
Integer lineNumber,
CsvTestCase testCase,
String instructions,
Mode mode
String instructions
) {
super(fileName, groupName, testName, lineNumber, convertToRemoteIndices(testCase), instructions, mode);
super(fileName, groupName, testName, lineNumber, convertToRemoteIndices(testCase), instructions);
}

// TODO: think how to handle this better
Expand Down Expand Up @@ -152,7 +137,10 @@ protected void shouldSkipTest(String testName) throws IOException {
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_PLANNING_V1.capabilityName()));
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V9.capabilityName()));
if (testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName())) {
assumeTrue("LOOKUP JOIN not yet supported in CCS", hasCapabilities(List.of(ENABLE_LOOKUP_JOIN_ON_REMOTE.capabilityName())));
assumeTrue(
"LOOKUP JOIN not yet supported in CCS",
hasCapabilities(adminClient(), List.of(ENABLE_LOOKUP_JOIN_ON_REMOTE.capabilityName()))
);
}
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));
Expand Down Expand Up @@ -401,7 +389,7 @@ protected boolean supportsInferenceTestService() {

@Override
protected boolean supportsIndexModeLookup() throws IOException {
return hasCapabilities(List.of(JOIN_LOOKUP_V12.capabilityName()));
return hasCapabilities(adminClient(), List.of(JOIN_LOOKUP_V12.capabilityName()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.CsvSpecReader.CsvTestCase;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode;
import org.junit.ClassRule;

import java.io.IOException;
Expand All @@ -24,16 +23,8 @@ protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public EsqlSpecIT(
String fileName,
String groupName,
String testName,
Integer lineNumber,
CsvTestCase testCase,
String instructions,
Mode mode
) {
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode);
public EsqlSpecIT(String fileName, String groupName, String testName, Integer lineNumber, CsvTestCase testCase, String instructions) {
super(fileName, groupName, testName, lineNumber, testCase, instructions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.elasticsearch.xpack.esql.planner.PhysicalSettings;
import org.elasticsearch.xpack.esql.plugin.ComputeService;
import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode;
import org.junit.Before;
import org.junit.ClassRule;

Expand All @@ -37,16 +36,8 @@ protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}

public EsqlSpecIT(
String fileName,
String groupName,
String testName,
Integer lineNumber,
CsvTestCase testCase,
String instructions,
Mode mode
) {
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode);
public EsqlSpecIT(String fileName, String groupName, String testName, Integer lineNumber, CsvTestCase testCase, String instructions) {
super(fileName, groupName, testName, lineNumber, testCase, instructions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.test.TestClustersThreadFilter;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.esql.CsvSpecReader;
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode;
import org.elasticsearch.xpack.esql.qa.rest.generative.GenerativeForkRestTest;
import org.junit.ClassRule;

Expand All @@ -32,10 +31,9 @@ public GenerativeForkIT(
String testName,
Integer lineNumber,
CsvSpecReader.CsvTestCase testCase,
String instructions,
Mode mode
String instructions
) {
super(fileName, groupName, testName, lineNumber, testCase, instructions, mode);
super(fileName, groupName, testName, lineNumber, testCase, instructions);
}

@Override
Expand Down
Loading