|
104 | 104 | import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; |
105 | 105 | import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; |
106 | 106 | import static org.elasticsearch.index.IndexSettings.INDEX_REFRESH_INTERVAL_SETTING; |
| 107 | +import static org.elasticsearch.index.query.QueryBuilders.boolQuery; |
107 | 108 | import static org.elasticsearch.index.query.QueryBuilders.matchQuery; |
108 | 109 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
109 | 110 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAliasesExist; |
@@ -135,15 +136,29 @@ protected Collection<Class<? extends Plugin>> nodePlugins() { |
135 | 136 | MockRepository.Plugin.class); |
136 | 137 | } |
137 | 138 |
|
| 139 | + private Settings randomRepoSettings() { |
| 140 | + Settings.Builder repoSettings = Settings.builder(); |
| 141 | + repoSettings.put("location", randomRepoPath()); |
| 142 | + if (randomBoolean()) { |
| 143 | + repoSettings.put("compress", randomBoolean()); |
| 144 | + } |
| 145 | + if (randomBoolean()) { |
| 146 | + repoSettings.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES); |
| 147 | + } else { |
| 148 | + if (randomBoolean()) { |
| 149 | + repoSettings.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES); |
| 150 | + } else { |
| 151 | + repoSettings.put("chunk_size", (String) null); |
| 152 | + } |
| 153 | + } |
| 154 | + return repoSettings.build(); |
| 155 | + } |
| 156 | + |
138 | 157 | public void testBasicWorkFlow() throws Exception { |
139 | 158 | Client client = client(); |
140 | 159 |
|
141 | 160 | logger.info("--> creating repository"); |
142 | | - assertAcked(client.admin().cluster().preparePutRepository("test-repo") |
143 | | - .setType("fs").setSettings(Settings.builder() |
144 | | - .put("location", randomRepoPath()) |
145 | | - .put("compress", randomBoolean()) |
146 | | - .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); |
| 161 | + assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings())); |
147 | 162 |
|
148 | 163 | createIndex("test-idx-1", "test-idx-2", "test-idx-3"); |
149 | 164 | ensureGreen(); |
@@ -308,11 +323,7 @@ public void testFreshIndexUUID() { |
308 | 323 | Client client = client(); |
309 | 324 |
|
310 | 325 | logger.info("--> creating repository"); |
311 | | - assertAcked(client.admin().cluster().preparePutRepository("test-repo") |
312 | | - .setType("fs").setSettings(Settings.builder() |
313 | | - .put("location", randomRepoPath()) |
314 | | - .put("compress", randomBoolean()) |
315 | | - .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); |
| 326 | + assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings())); |
316 | 327 |
|
317 | 328 | createIndex("test"); |
318 | 329 | String originalIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID); |
@@ -356,11 +367,7 @@ public void testRestoreWithDifferentMappingsAndSettings() throws Exception { |
356 | 367 | Client client = client(); |
357 | 368 |
|
358 | 369 | logger.info("--> creating repository"); |
359 | | - assertAcked(client.admin().cluster().preparePutRepository("test-repo") |
360 | | - .setType("fs").setSettings(Settings.builder() |
361 | | - .put("location", randomRepoPath()) |
362 | | - .put("compress", randomBoolean()) |
363 | | - .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); |
| 370 | + assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings())); |
364 | 371 |
|
365 | 372 | logger.info("--> create index with foo type"); |
366 | 373 | assertAcked(prepareCreate("test-idx", 2, Settings.builder() |
|
0 commit comments