|
105 | 105 | import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; |
106 | 106 | import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; |
107 | 107 | import static org.elasticsearch.index.IndexSettings.INDEX_REFRESH_INTERVAL_SETTING; |
| 108 | +import static org.elasticsearch.index.query.QueryBuilders.boolQuery; |
108 | 109 | import static org.elasticsearch.index.query.QueryBuilders.matchQuery; |
109 | 110 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
110 | 111 | 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(); |
@@ -279,11 +294,7 @@ public void testFreshIndexUUID() { |
279 | 294 | Client client = client(); |
280 | 295 |
|
281 | 296 | logger.info("--> creating repository"); |
282 | | - assertAcked(client.admin().cluster().preparePutRepository("test-repo") |
283 | | - .setType("fs").setSettings(Settings.builder() |
284 | | - .put("location", randomRepoPath()) |
285 | | - .put("compress", randomBoolean()) |
286 | | - .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); |
| 297 | + assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings())); |
287 | 298 |
|
288 | 299 | createIndex("test"); |
289 | 300 | String originalIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID); |
@@ -327,11 +338,7 @@ public void testRestoreWithDifferentMappingsAndSettings() throws Exception { |
327 | 338 | Client client = client(); |
328 | 339 |
|
329 | 340 | logger.info("--> creating repository"); |
330 | | - assertAcked(client.admin().cluster().preparePutRepository("test-repo") |
331 | | - .setType("fs").setSettings(Settings.builder() |
332 | | - .put("location", randomRepoPath()) |
333 | | - .put("compress", randomBoolean()) |
334 | | - .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); |
| 341 | + assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings())); |
335 | 342 |
|
336 | 343 | logger.info("--> create index with foo type"); |
337 | 344 | assertAcked(prepareCreate("test-idx", 2, Settings.builder() |
|
0 commit comments