Test: do not copy secure settings when creating random directory service (#25297)
In tests, we sometimes create a random directory service and as part of that the IndexSettings get built again. When we build them again, we need to make sure we do not set the secure settings on the new IndexMetaData object that gets created as the node settings already have the secure settings and the index settings and node settings will be combined. If both have secure settings, the settings builder will throw an AlreadySetException.
This commit is contained in:
parent
4c5bd57619
commit
1a6491bc54
|
@ -97,7 +97,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
logger.debug("Using MockDirWrapper with seed [{}] throttle: [{}] crashIndex: [{}]", SeedUtils.formatSeed(seed),
|
||||
throttle, crashIndex);
|
||||
}
|
||||
delegateService = randomDirectorService(indexStore, path);
|
||||
delegateService = randomDirectoryService(indexStore, path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,9 +162,14 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
return w;
|
||||
}
|
||||
|
||||
private FsDirectoryService randomDirectorService(IndexStore indexStore, ShardPath path) {
|
||||
private FsDirectoryService randomDirectoryService(IndexStore indexStore, ShardPath path) {
|
||||
final IndexSettings indexSettings = indexStore.getIndexSettings();
|
||||
final IndexMetaData build = IndexMetaData.builder(indexSettings.getIndexMetaData()).settings(Settings.builder().put(indexSettings.getSettings()).put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), RandomPicks.randomFrom(random, IndexModule.Type.values()).getSettingsKey())).build();
|
||||
final IndexMetaData build = IndexMetaData.builder(indexSettings.getIndexMetaData())
|
||||
.settings(Settings.builder()
|
||||
.put(indexSettings.getSettings().getAsMap()) // do not copy the secure settings as they will be copied again later on!
|
||||
.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(),
|
||||
RandomPicks.randomFrom(random, IndexModule.Type.values()).getSettingsKey()))
|
||||
.build();
|
||||
final IndexSettings newIndexSettings = new IndexSettings(build, indexSettings.getNodeSettings());
|
||||
return new FsDirectoryService(newIndexSettings, indexStore, path);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue