[CCR] Remove ccr related metadata between tests for single node tests too
This commit is contained in:
parent
b6750cf6c2
commit
92e34732f5
|
@ -105,30 +105,7 @@ public abstract class CCRIntegTestCase extends ESTestCase {
|
|||
public void afterTest() throws Exception {
|
||||
String masterNode = clusterGroup.followerCluster.getMasterName();
|
||||
ClusterService clusterService = clusterGroup.followerCluster.getInstance(ClusterService.class, masterNode);
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
clusterService.submitStateUpdateTask("purge-cluster-state", new ClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||
ClusterState.Builder newState = ClusterState.builder(currentState);
|
||||
newState.metaData(MetaData.builder(currentState.getMetaData())
|
||||
.removeCustom(AutoFollowMetadata.TYPE)
|
||||
.removeCustom(PersistentTasksCustomMetaData.TYPE)
|
||||
.build());
|
||||
return newState.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Exception e) {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
latch.await();
|
||||
removeCCRRelatedMetadataFromClusterState(clusterService);
|
||||
|
||||
try {
|
||||
clusterGroup.leaderCluster.beforeIndexDeletion();
|
||||
|
@ -286,6 +263,32 @@ public abstract class CCRIntegTestCase extends ESTestCase {
|
|||
return actionGet;
|
||||
}
|
||||
|
||||
static void removeCCRRelatedMetadataFromClusterState(ClusterService clusterService) throws Exception {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
clusterService.submitStateUpdateTask("remove-ccr-related-metadata", new ClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||
ClusterState.Builder newState = ClusterState.builder(currentState);
|
||||
newState.metaData(MetaData.builder(currentState.getMetaData())
|
||||
.removeCustom(AutoFollowMetadata.TYPE)
|
||||
.removeCustom(PersistentTasksCustomMetaData.TYPE)
|
||||
.build());
|
||||
return newState.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Exception e) {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
latch.await();
|
||||
}
|
||||
|
||||
static class ClusterGroup implements Closeable {
|
||||
|
||||
final InternalTestCluster leaderCluster;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.elasticsearch.xpack;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.license.LicenseService;
|
||||
|
@ -23,6 +24,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.xpack.CCRIntegTestCase.removeCCRRelatedMetadataFromClusterState;
|
||||
|
||||
public abstract class CCRSingleNodeTestCase extends ESSingleNodeTestCase {
|
||||
|
||||
|
@ -52,7 +54,10 @@ public abstract class CCRSingleNodeTestCase extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
@After
|
||||
public void remoteLocalRemote() {
|
||||
public void remoteLocalRemote() throws Exception {
|
||||
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||
removeCCRRelatedMetadataFromClusterState(clusterService);
|
||||
|
||||
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
|
||||
updateSettingsRequest.transientSettings(Settings.builder().put("cluster.remote.local.seeds", (String) null));
|
||||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
|
||||
|
|
Loading…
Reference in New Issue