Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

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 @@ -183,6 +183,7 @@ public ClusterState execute(ClusterState currentState) {
throw new IllegalStateException("index [" + index.getName() + "] is not closed");
}
final IndexMetaData.Builder imdBuilder = IndexMetaData.builder(meta);
imdBuilder.settingsVersion(meta.getSettingsVersion() + 1);
final Settings.Builder settingsBuilder =
Settings.builder()
.put(currentState.metaData().index(index).getSettings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.equalTo;

public class FrozenIndexTests extends ESSingleNodeTestCase {

Expand Down Expand Up @@ -324,4 +325,19 @@ public void testUnfreezeClosedIndex() throws ExecutionException, InterruptedExce
assertEquals(IndexMetaData.State.OPEN,
client().admin().cluster().prepareState().get().getState().metaData().index("idx").getState());
}

public void testFreezeIndexIncreasesIndexSettingsVersion() throws ExecutionException, InterruptedException {
final String index = "test";
createIndex(index, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build());
client().prepareIndex(index, "_doc").setSource("field", "value").execute().actionGet();

final long settingsVersion = client().admin().cluster().prepareState().get()
.getState().metaData().index(index).getSettingsVersion();

XPackClient xPackClient = new XPackClient(client());
assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest(index)));
assertIndexFrozen(index);
assertThat(client().admin().cluster().prepareState().get().getState().metaData().index(index).getSettingsVersion(),
equalTo(settingsVersion + 1));
}
}