Ensure remote connection established and

clean remote connection prior to leader cluster restart

Relates to #37681
This commit is contained in:
Martijn van Groningen 2019-02-26 09:05:49 +01:00
parent d42f422258
commit b159cc51c0
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 25 additions and 1 deletions

View File

@ -6,14 +6,18 @@
package org.elasticsearch.xpack.ccr;
import org.elasticsearch.action.admin.cluster.remote.RemoteInfoAction;
import org.elasticsearch.action.admin.cluster.remote.RemoteInfoRequest;
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.transport.RemoteConnectionInfo;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.CcrIntegTestCase;
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
import java.util.List;
import java.util.Locale;
import static java.util.Collections.singletonMap;
@ -66,6 +70,7 @@ public class RestartIndexFollowingIT extends CcrIntegTestCase {
equalTo(firstBatchNumDocs + secondBatchNumDocs));
});
cleanRemoteCluster();
getLeaderCluster().fullRestart();
ensureLeaderGreen("index1");
// Remote connection needs to be re-configured, because all the nodes in leader cluster have been restarted:
@ -82,11 +87,30 @@ public class RestartIndexFollowingIT extends CcrIntegTestCase {
});
}
private void setupRemoteCluster() {
private void setupRemoteCluster() throws Exception {
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
String address = getLeaderCluster().getMasterNodeInstance(TransportService.class).boundAddress().publishAddress().toString();
updateSettingsRequest.persistentSettings(Settings.builder().put("cluster.remote.leader_cluster.seeds", address));
assertAcked(followerClient().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
assertBusy(() -> {
List<RemoteConnectionInfo> infos =
followerClient().execute(RemoteInfoAction.INSTANCE, new RemoteInfoRequest()).get().getInfos();
assertThat(infos.size(), equalTo(1));
assertThat(infos.get(0).getNumNodesConnected(), equalTo(1));
});
}
private void cleanRemoteCluster() throws Exception {
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
updateSettingsRequest.persistentSettings(Settings.builder().put("cluster.remote.leader_cluster.seeds", (String) null));
assertAcked(followerClient().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
assertBusy(() -> {
List<RemoteConnectionInfo> infos =
followerClient().execute(RemoteInfoAction.INSTANCE, new RemoteInfoRequest()).get().getInfos();
assertThat(infos.size(), equalTo(0));
});
}
}