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

Flaky RemoteClustersIT: Add assert busy to avoid race condition #11057

Merged
merged 3 commits into from
Nov 8, 2023
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 @@ -42,11 +42,13 @@
import org.opensearch.client.cluster.RemoteInfoRequest;
import org.opensearch.client.indices.CreateIndexRequest;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentFactory;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;
import java.util.concurrent.TimeUnit;


public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
Expand Down Expand Up @@ -112,7 +114,7 @@ public void testSniffModeConnectionFails() throws IOException {
assertFalse(rci.isConnected());
}

public void testHAProxyModeConnectionWorks() throws IOException {
public void testHAProxyModeConnectionWorks() throws Exception {
String proxyAddress = "haproxy:9600";
logger.info("Configuring remote cluster [{}]", proxyAddress);
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(Settings.builder()
Expand All @@ -121,12 +123,14 @@ public void testHAProxyModeConnectionWorks() throws IOException {
.build());
assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());

RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
logger.info("Connection info: {}", rci);
if (!rci.isConnected()) {
logger.info("Cluster health: {}", cluster1Client().cluster().health(new ClusterHealthRequest(), RequestOptions.DEFAULT));
}
assertTrue(rci.isConnected());
assertBusy(() -> {
RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
logger.info("Connection info: {}", rci);
if (!rci.isConnected()) {
logger.info("Cluster health: {}", cluster1Client().cluster().health(new ClusterHealthRequest(), RequestOptions.DEFAULT));
}
assertTrue(rci.isConnected());
}, 10, TimeUnit.SECONDS);

assertEquals(2L, cluster1Client().search(
new SearchRequest("haproxynosn:test2"), RequestOptions.DEFAULT).getHits().getTotalHits().value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void onResponse(Void v) {

@Override
public void onFailure(Exception e) {
logger.debug(
logger.error(
new ParameterizedMessage(
"failed to open remote connection [remote cluster: {}, address: {}]",
clusterAlias,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
// are on the cluster state thread and our custom future implementation will throw an
// assertion.
if (latch.await(10, TimeUnit.SECONDS) == false) {
logger.warn("failed to connect to new remote cluster {} within {}", clusterAlias, TimeValue.timeValueSeconds(10));
logger.error("failed to connect to new remote cluster {} within {}", clusterAlias, TimeValue.timeValueSeconds(10));

Check warning on line 273 in server/src/main/java/org/opensearch/transport/RemoteClusterService.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/transport/RemoteClusterService.java#L273

Added line #L273 was not covered by tests
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Expand Down
Loading