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

Fix CrossClusterEsqlRCSEnrichUnavailableRemotesIT failing tests #119977

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 @@ -24,11 +24,13 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.oneOf;

public class CrossClusterEsqlRCS1EnrichUnavailableRemotesIT extends AbstractRemoteClusterSecurityTestCase {
private static final AtomicBoolean SSL_ENABLED_REF = new AtomicBoolean();
Expand Down Expand Up @@ -185,8 +187,7 @@ private void esqlEnrichWithSkipUnavailableTrue() throws Exception {
Map<String, ?> failuresMap = (Map<String, ?>) remoteClusterFailures.get(0);

Map<String, ?> reason = (Map<String, ?>) failuresMap.get("reason");
assertThat(reason.get("type").toString(), equalTo("connect_transport_exception"));
assertThat(reason.get("reason").toString(), containsString("Unable to connect to [my_remote_cluster]"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could keep the check that the error message mentions my_remote_cluster (if that's the case) maybe without requiring all other stuff to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I'm not able to reproduce the failure, I'm hesitant to do that. We don't control what error messages come from the underlying transport layer, so testing for that doesn't test for anything we can change. The error message will be whatever the transport layer decides it wants it to be depending on what exact sequence of transport issues happened (and there can be many different errors from disconnected clusters). The key point of this test is that it reports some sort of disconnected/transport error rather than an ESQL verification exception which is what it was doing before Pawan's fix.

assertThat(reason.get("type").toString(), oneOf("node_disconnected_exception", "connect_transport_exception"));
} finally {
fulfillingCluster.start();
closeFulfillingClusterClient();
Expand All @@ -202,7 +203,11 @@ private void esqlEnrichWithSkipUnavailableFalse() throws Exception {

String query = "FROM to-be-enr*,my_remote_cluster:to-be-enr* | ENRICH " + randomFrom(modes) + ":employees-policy | LIMIT 10";
ResponseException ex = expectThrows(ResponseException.class, () -> client().performRequest(esqlRequest(query)));
assertThat(ex.getMessage(), containsString("connect_transport_exception"));

assertThat(
ex.getMessage(),
anyOf(containsString("connect_transport_exception"), containsString("node_disconnected_exception"))
);
} finally {
fulfillingCluster.start();
closeFulfillingClusterClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.oneOf;

public class CrossClusterEsqlRCS2EnrichUnavailableRemotesIT extends AbstractRemoteClusterSecurityTestCase {
private static final AtomicReference<Map<String, Object>> API_KEY_MAP_REF = new AtomicReference<>();
Expand Down Expand Up @@ -205,8 +207,7 @@ private void esqlEnrichWithSkipUnavailableTrue() throws Exception {
Map<String, ?> failuresMap = (Map<String, ?>) remoteClusterFailures.get(0);

Map<String, ?> reason = (Map<String, ?>) failuresMap.get("reason");
assertThat(reason.get("type").toString(), equalTo("connect_transport_exception"));
assertThat(reason.get("reason").toString(), containsString("Unable to connect to [my_remote_cluster]"));
assertThat(reason.get("type").toString(), oneOf("node_disconnected_exception", "connect_transport_exception"));
} finally {
fulfillingCluster.start();
closeFulfillingClusterClient();
Expand All @@ -222,7 +223,10 @@ private void esqlEnrichWithSkipUnavailableFalse() throws Exception {

String query = "FROM to-be-enr*,my_remote_cluster:to-be-enr* | ENRICH " + randomFrom(modes) + ":employees-policy | LIMIT 10";
ResponseException ex = expectThrows(ResponseException.class, () -> performRequestWithRemoteSearchUser(esqlRequest(query)));
assertThat(ex.getMessage(), containsString("connect_transport_exception"));
assertThat(
ex.getMessage(),
anyOf(containsString("connect_transport_exception"), containsString("node_disconnected_exception"))
);
} finally {
fulfillingCluster.start();
closeFulfillingClusterClient();
Expand Down