Skip to content

Commit 33cd137

Browse files
committed
Fixed forbiddenAPI issues in CrossClustersQueryIT
1 parent 3e824b1 commit 33cd137

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
260260

261261
// missing concrete remote index is not fatal when skip_unavailable=true (as long as an index matches on another cluster)
262262
{
263-
String q = String.format("FROM %s,cluster-a:nomatch", localIndex);
263+
String q = Strings.format("FROM %s,cluster-a:nomatch", localIndex);
264264
try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
265265
assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
266266
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -282,7 +282,6 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
282282
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
283283
assertThat(executionInfo.isCrossClusterSearch(), is(true));
284284
assertThat(executionInfo.includeCCSMetadata(), equalTo(responseExpectMeta));
285-
System.err.println(executionInfo);
286285
assertExpectedClustersForMissingIndicesTests(
287286
executionInfo,
288287
List.of(
@@ -337,7 +336,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
337336

338337
// since at least one index of the query matches on some cluster, a wildcarded index on skip_un=true is not an error
339338
{
340-
String q = String.format("FROM %s,cluster-a:nomatch*", localIndex);
339+
String q = Strings.format("FROM %s,cluster-a:nomatch*", localIndex);
341340
try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
342341
assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
343342
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -441,7 +440,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
441440
// since cluster-a is skip_unavailable=true and at least one cluster has a matching indices, no error is thrown
442441
{
443442
// TODO solve in follow-on PR which does skip_unavailable handling at execution time
444-
// String q = String.format("FROM %s,cluster-a:nomatch,cluster-a:%s*", localIndex, remote1Index);
443+
// String q = Strings.format("FROM %s,cluster-a:nomatch,cluster-a:%s*", localIndex, remote1Index);
445444
// try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
446445
// assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
447446
// EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -475,7 +474,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
475474
// since cluster-a is skip_unavailable=true and at least one cluster has a matching indices, no error is thrown
476475
// cluster-a should be marked as SKIPPED with VerificationException
477476
{
478-
String q = String.format("FROM nomatch*,cluster-a:nomatch,%s:%s", REMOTE_CLUSTER_2, remote2Index);
477+
String q = Strings.format("FROM nomatch*,cluster-a:nomatch,%s:%s", REMOTE_CLUSTER_2, remote2Index);
479478
try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
480479
assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
481480
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -519,7 +518,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableTrue() {
519518
// since cluster-a is skip_unavailable=true and at least one cluster has a matching indices, no error is thrown
520519
// cluster-a should be marked as SKIPPED with a "NoMatchingIndicesException" since a wildcard index was requested
521520
{
522-
String q = String.format("FROM nomatch*,cluster-a:nomatch*,%s:%s", REMOTE_CLUSTER_2, remote2Index);
521+
String q = Strings.format("FROM nomatch*,cluster-a:nomatch*,%s:%s", REMOTE_CLUSTER_2, remote2Index);
523522
try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
524523
assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
525524
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -604,7 +603,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableFalse() {
604603

605604
// No error since local non-matching has wildcard and the remote cluster matches
606605
{
607-
String q = String.format("FROM nomatch*,%s:%s", REMOTE_CLUSTER_1, remote1Index);
606+
String q = Strings.format("FROM nomatch*,%s:%s", REMOTE_CLUSTER_1, remote1Index);
608607
try (EsqlQueryResponse resp = runQuery(q, requestIncludeMeta)) {
609608
assertThat(getValuesList(resp).size(), greaterThanOrEqualTo(1));
610609
EsqlExecutionInfo executionInfo = resp.getExecutionInfo();
@@ -646,7 +645,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableFalse() {
646645

647646
// query is fatal since cluster-a has skip_unavailable=false and has no matching indices
648647
{
649-
String q = String.format("FROM %s,cluster-a:nomatch*", localIndex);
648+
String q = Strings.format("FROM %s,cluster-a:nomatch*", localIndex);
650649
VerificationException e = expectThrows(VerificationException.class, () -> runQuery(q, requestIncludeMeta));
651650
assertThat(e.getDetailedMessage(), containsString("Unknown index [cluster-a:nomatch*]"));
652651

@@ -724,7 +723,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableFalse() {
724723
// Missing concrete index on skip_unavailable=false cluster is a fatal error, even when another index expression
725724
// against that cluster matches
726725
{
727-
String q = String.format("FROM %s,cluster-a:nomatch,cluster-a:%s*", localIndex, remote2Index);
726+
String q = Strings.format("FROM %s,cluster-a:nomatch,cluster-a:%s*", localIndex, remote2Index);
728727
IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> runQuery(q, requestIncludeMeta));
729728
assertThat(e.getDetailedMessage(), containsString("no such index [nomatch]"));
730729

@@ -739,7 +738,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableFalse() {
739738
// skip_unavailable=false cluster having no matching indices is a fatal error. This error
740739
// is fatal at plan time, so it throws VerificationException, not IndexNotFoundException (thrown at execution time)
741740
{
742-
String q = String.format("FROM %s*,cluster-a:nomatch,%s:%s*", localIndex, REMOTE_CLUSTER_2, remote2Index);
741+
String q = Strings.format("FROM %s*,cluster-a:nomatch,%s:%s*", localIndex, REMOTE_CLUSTER_2, remote2Index);
743742
VerificationException e = expectThrows(VerificationException.class, () -> runQuery(q, requestIncludeMeta));
744743
assertThat(e.getDetailedMessage(), containsString("Unknown index [cluster-a:nomatch]"));
745744

@@ -750,7 +749,7 @@ public void testSearchesAgainstNonMatchingIndicesWithSkipUnavailableFalse() {
750749

751750
// skip_unavailable=false cluster having no matching indices is a fatal error (even if wildcarded)
752751
{
753-
String q = String.format("FROM %s*,cluster-a:nomatch*,%s:%s*", localIndex, REMOTE_CLUSTER_2, remote2Index);
752+
String q = Strings.format("FROM %s*,cluster-a:nomatch*,%s:%s*", localIndex, REMOTE_CLUSTER_2, remote2Index);
754753
VerificationException e = expectThrows(VerificationException.class, () -> runQuery(q, requestIncludeMeta));
755754
assertThat(e.getDetailedMessage(), containsString("Unknown index [cluster-a:nomatch*]"));
756755

@@ -874,11 +873,7 @@ public void testSearchesWhereNonExistentClusterIsSpecifiedWithWildcards() {
874873
* This one is mostly focuses on took time values.
875874
*/
876875
public void testCCSExecutionOnSearchesWithLimit0() {
877-
Map<String, Object> setupMap = setupTwoClusters();
878-
boolean skipUnavailable = (Boolean) setupMap.get("remote.skip_unavailable");
879-
880-
System.err.println(skipUnavailable);
881-
876+
setupTwoClusters();
882877
Tuple<Boolean, Boolean> includeCCSMetadata = randomIncludeCCSMetadata();
883878
Boolean requestIncludeMeta = includeCCSMetadata.v1();
884879
boolean responseExpectMeta = includeCCSMetadata.v2();

0 commit comments

Comments
 (0)