|
12 | 12 | import org.elasticsearch.ElasticsearchSecurityException;
|
13 | 13 | import org.elasticsearch.action.ActionListener;
|
14 | 14 | import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
| 15 | +import org.elasticsearch.cluster.ClusterState; |
| 16 | +import org.elasticsearch.cluster.ClusterStateUpdateTask; |
| 17 | +import org.elasticsearch.cluster.metadata.MetaData; |
| 18 | +import org.elasticsearch.cluster.service.ClusterService; |
15 | 19 | import org.elasticsearch.common.logging.Loggers;
|
16 | 20 | import org.elasticsearch.common.unit.TimeValue;
|
17 | 21 | import org.elasticsearch.plugins.Plugin;
|
|
23 | 27 | import org.elasticsearch.xpack.ccr.action.FollowIndexAction;
|
24 | 28 | import org.elasticsearch.xpack.ccr.action.PutAutoFollowPatternAction;
|
25 | 29 | import org.elasticsearch.xpack.ccr.action.ShardFollowNodeTask;
|
| 30 | +import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; |
| 31 | +import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; |
26 | 32 |
|
27 | 33 | import java.util.Collection;
|
28 | 34 | import java.util.Collections;
|
@@ -127,6 +133,40 @@ public void onFailure(final Exception e) {
|
127 | 133 | }
|
128 | 134 |
|
129 | 135 | public void testAutoFollowCoordinatorLogsSkippingAutoFollowCoordinationWithNonCompliantLicense() throws Exception {
|
| 136 | + // Update the cluster state so that we have auto follow patterns and verify that we log a warning in case of incompatible license: |
| 137 | + CountDownLatch latch = new CountDownLatch(1); |
| 138 | + ClusterService clusterService = getInstanceFromNode(ClusterService.class); |
| 139 | + clusterService.submitStateUpdateTask("test-add-auto-follow-pattern", new ClusterStateUpdateTask() { |
| 140 | + |
| 141 | + @Override |
| 142 | + public ClusterState execute(ClusterState currentState) throws Exception { |
| 143 | + AutoFollowPattern autoFollowPattern = |
| 144 | + new AutoFollowPattern(Collections.singletonList("logs-*"), null, null, null, null, null, null, null, null); |
| 145 | + AutoFollowMetadata autoFollowMetadata = new AutoFollowMetadata( |
| 146 | + Collections.singletonMap("test_alias", autoFollowPattern), |
| 147 | + Collections.emptyMap() |
| 148 | + ); |
| 149 | + |
| 150 | + ClusterState.Builder newState = ClusterState.builder(currentState); |
| 151 | + newState.metaData(MetaData.builder(currentState.getMetaData()) |
| 152 | + .putCustom(AutoFollowMetadata.TYPE, autoFollowMetadata) |
| 153 | + .build()); |
| 154 | + return newState.build(); |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { |
| 159 | + latch.countDown(); |
| 160 | + } |
| 161 | + |
| 162 | + @Override |
| 163 | + public void onFailure(String source, Exception e) { |
| 164 | + latch.countDown(); |
| 165 | + fail("unexpected error [" + e.getMessage() + "]"); |
| 166 | + } |
| 167 | + }); |
| 168 | + latch.await(); |
| 169 | + |
130 | 170 | final Logger logger = LogManager.getLogger(AutoFollowCoordinator.class);
|
131 | 171 | final MockLogAppender appender = new MockLogAppender();
|
132 | 172 | appender.start();
|
|
0 commit comments